4-20 mA signal measurement with Arduino

Поделиться
HTML-код
  • Опубликовано: 1 окт 2024
  • In this video I show you how to measure the output signal of a 4-20 mA-type sensor and convert it into some values using an Arduino. You will learn how to build a "current to voltage" circuit with a simple protection (Zener diode) and you will also learn how you can customize my source code to convert the signal of any sensor into a human-readable format.
    Please don't forget to subscribe!
    Schematics, drawings and source code:
    curiousscienti...
    If you want to buy the parts I used in the video and support me at the same time, you can use the affiliate links I provide on my website:
    curiousscienti...

Комментарии • 54

  • @isidoromaich7226
    @isidoromaich7226 3 года назад +2

    I always have read about the 4-20mA protocol here and there but I knew nothing about it... now I know, thanks

    • @CuriousScientist
      @CuriousScientist  3 года назад

      Actually, I have never worked with the either. That's why I needed to simulate the current with the potmeter. But, I got an interesting question related to these 4-20 mA systems and I thought I could make a video on it because I could not find proper resources.

  • @fiedler6185
    @fiedler6185 5 месяцев назад

    Sorry to be a late-comer to the party. And a rank Newbie at that, struggling to grasp Arduino use. Your video appears to sort out about 90% of the questions I have about reading a 4-20 mA loop pressure sensor, except that the simulation with a pot still requires 3 wires, and the sensor has only 2. .y sensor wants 24v, and the Arduino clearly doesn't. My understanding was they must share a common ground? Does that require some other Isolation of circuits?

    • @CuriousScientist
      @CuriousScientist  5 месяцев назад

      Hi! There's no such thing as late coming here, I try to answer all comments, even if it is under an old video. The components should share common ground. Otherwise, it can happen that their ground (0 V) is slightly different which could lead to wrong readings. The ground does not need any insulation. The Arduino's max input voltage is 5 V. Pay attention to this!

  • @timoteomeccanicatecnologia
    @timoteomeccanicatecnologia 2 года назад +1

    Hi. What library did you use to write the values on this display? I can't print float variable on my oled. Thanks.

    • @CuriousScientist
      @CuriousScientist  2 года назад +1

      Hi! It is in the code that I shared on my website. Also, printing float is always a mess with displays with Arduino. I have explained it in several videos how to solve it. Look for the dtostrf() function.

    • @timoteomeccanicatecnologia
      @timoteomeccanicatecnologia 2 года назад +1

      @@CuriousScientist thanks! I'll check it out!

  • @emrekasm8638
    @emrekasm8638 2 года назад

    Thx for the video !
    Whats the point of 100 ohm. what happens if i remove it and short cut there? just 250 or 220 ohm and just zener diode parallel to resistant
    The outputs stay the same without 100 ohm.just put zener and res. Parallel to another

    • @CuriousScientist
      @CuriousScientist  2 года назад

      Hi! The 100 Ohm resistor is there to limit the current in conjunction with the Zener diode. It protects the input of the Arduino or AD-converter.

  • @omaral-gallab7735
    @omaral-gallab7735 Год назад

    nice, sir, please, how can i use Arduino nano to get a micro amp? and where is the diagram of circuit. thanks

    • @CuriousScientist
      @CuriousScientist  Год назад

      Hi! What do you mean by micro amp? Have you tried using Google?

  • @mimoa21
    @mimoa21 Год назад

    Hi. Is it possible to measure frequency of the signal with this device?

    • @CuriousScientist
      @CuriousScientist  Год назад

      Hi! Sure, you can measure frequency with an Arduino. But there are limitations.

  • @Stannis24
    @Stannis24 2 года назад

    Hi and sorry for the inconvenience, I have a similar problem in which I want to measure a current between 0-50mA, accuracy 1mA, DC, same scenario, can you help me with a schematic? Thx!

    • @CuriousScientist
      @CuriousScientist  2 года назад

      Hi! Have you checked my website? There's a link in the description of the video.

  • @JelloPal
    @JelloPal 2 года назад

    Very nice video! But how to isolate them? If having 4 analogues

  • @JelloPal
    @JelloPal 2 года назад

    Hi mate. Very well explained. What is the easiest way to add isolation to the circuit?

    • @CuriousScientist
      @CuriousScientist  2 года назад

      Hi and thanks! Which part exactly are you interested in isolating? Do you want to isolate the whole circuit from the MCU? Or do you want to isolate the signal from the circuit? Maybe a simple 1:1 transformer could do the job.

  • @carloscosta362
    @carloscosta362 2 года назад +1

    Very very good explanantion. Thanks a lot for that. I used this, to connect a Industrial Position Transmitters to the arduino. In the for loop i change only the 5 millisecond delay with the millis() function like follows
    " if (millis() - range_t > 5) {
    for (int i = 0; i < 100; i++) {
    rawADCValue += analogRead(ADC_Pin);
    }
    range_t = millis();
    }
    "
    and i realised decimal values displayed at the Oled are nearly stable using delay. Using the millis i have some fluttering at the decimal values displayed on the Oled.
    I am using the millis wrong for this case? How i can display stable values on the Oled using the millis()?
    Thanks

    • @CuriousScientist
      @CuriousScientist  2 года назад +1

      Hi and thanks!
      The code snippet you sent is not doing the same thing as my code. I added the delay *after* reading the ADC and not after finishing the for() loop... I added it because I wanted to let the ADC to settle after each reading to avoid funny values. Since the code is not time critical, I used the delay() instead of implementing the non-blocking millis(). 100 times 5 ms is still just half a second which is, I think a sufficient update frequency for the display. If the display is fluttering, then you might want to add the millis() part to the printLCD() function.

    • @carloscosta362
      @carloscosta362 2 года назад

      @@CuriousScientist you are right. But like follow it would be after the reading of the ADC?
      "
      for (int i = 0; i < 100; i++) //Do 100 readings
      {
      if (millis() - range_t > 5) {
      rawADCValue += analogRead(ADC_Pin);
      range_t = millis();
      }
      }
      "
      In my code is time critical and i do not want tu use the blocking delay.

    • @CuriousScientist
      @CuriousScientist  2 года назад +1

      Why don't you just test it? :)

    • @carloscosta362
      @carloscosta362 2 года назад +1

      @@CuriousScientist Yes i will... :) After testing it , i will tell something. Again thanks a lot. Waiting for some more videos from you. Continue like this.

    • @CuriousScientist
      @CuriousScientist  2 года назад +1

      Thanks, I will continue. Btw, the code you showed will probably not work properly.

  • @semakzl4524
    @semakzl4524 2 года назад

    Can we do this method to receive measurement data from industry sensor which has 4-20mA output without using rs232 or rs485 serial protohol?

    • @CuriousScientist
      @CuriousScientist  2 года назад

      Isn't that what I did here? If I understood your question correctly... The output is directly measured by an Arduino and the data can be forwarded to a computer via USB.

    • @semakzl4524
      @semakzl4524 2 года назад +1

      @@CuriousScientist Yes actually your video is almost relative with my question but my sensor which I'll use for my project is high level of precision to measure. So I didn't put it my mind, fortunately I've found rs232 laser measurement sensor. Btw you always answer my question when i ask thank you very much for this. :)))

    • @CuriousScientist
      @CuriousScientist  2 года назад

      I answer every single comment one by one. And based on the details of the question I reply with the same detail.
      If you need higher precision, just use an external 16-bit or 24-bit ADC to measure the voltage. But of course you have to make sure that your sensor can provide the signal in the required resolution as well.

    • @semakzl4524
      @semakzl4524 2 года назад

      @@CuriousScientist You are really the best I'll search what you said thank you so much for all your answers.

  • @darraghross4310
    @darraghross4310 2 года назад

    Hey can you do a video on using an arduino to output a 4 to 20ma source and simulate. Such as what a fluke process meter would do.

    • @CuriousScientist
      @CuriousScientist  2 года назад

      Hi! Sorry but I don't make videos on request for free. You can simulate this by dropping different voltage values across a known resistor. You can use a DAC to control the voltage.

    • @Nine_883
      @Nine_883 8 месяцев назад

      @@CuriousScientist It's not free. We are watching your content and that makes you money. You may know electronics, but you don't know much about business and circuit builder is a scam. Tinkercad is better a for Arduino and it's free.

  • @smferreiro2610
    @smferreiro2610 2 года назад

    Worked like charm!
    Thank you!

  • @dickschweiger289
    @dickschweiger289 2 года назад +2

    Thank you Very much, Good explanation

    • @CuriousScientist
      @CuriousScientist  2 года назад

      You are welcome!

    • @dickschweiger289
      @dickschweiger289 2 года назад +1

      Another question: Are you German ?
      Because everything you do seems to be in perfect order ha ha.

    • @CuriousScientist
      @CuriousScientist  2 года назад

      @@dickschweiger289 Hi! I am not German. But I am a scientist (by profession), so I've learnt how to keep things in order. :D

  • @arctytyz
    @arctytyz Год назад

    Very cool and clean code !