4-20mA sensor explained with a simple Arduino example!

  Рет қаралды 35,252

Werewolf Wu

Werewolf Wu

Жыл бұрын

How does a 4-20mA sensor work? How to use it with an Arduino? In this video we explain what a 4-20mA sensor does and how to connect it to an Arduino with a simple example.
Github link: github.com/WerewolfWu/420mAse...
Have a question / comment / suggestion? Let me know in the comment section, let's talk!

Пікірлер: 77
@silasdenny3267
@silasdenny3267 Жыл бұрын
Thank you for the video, it is very helpful. I am working on connecting the same sensor to an esp32 and this helps me a lot.
@werewolfwu
@werewolfwu Жыл бұрын
Glad you found it useful Silas!
@youtuuba
@youtuuba Жыл бұрын
Werewolf Wu, good job on the explanations. I am also pleased that I am not the only one who hates it when manufacturers and individuals fail to follow the rules for upper and lower case letters when showing metric values. I even worked with a company for several years where the engineers knew better, but the company 'hard rule' was that all printing on drawings and stamped onto products MUST be in upper case, so milli always became mega, etc.
@werewolfwu
@werewolfwu 11 ай бұрын
Mega Amps!
@marcelogouveia9614
@marcelogouveia9614 10 ай бұрын
I built a "very analog" LED bargraph water level indicator. (A vertical pvc pipe set-up with 10 reed switches outside "encapsulated in silicone" inside the 1' pvc pipe a Styrofoam float with a neodymium magnet on top) Besides the disadvantages of a myriad of wires (I used cat6 cables) the water would eventually seep through the silicone and cause "erroneous readings" This will help me set-up a single wire pair to the sensor, now I will have to figure out what IC to use to feed the LED bargraph. Thank you so much! 😊
@werewolfwu
@werewolfwu 9 ай бұрын
Glad you found it useful!
@pacochavarria1036
@pacochavarria1036 Жыл бұрын
thanks for making this kind of videos, I am working with pressure sensors from 0 -15 Psi, and they return me from 4 -20 mA. This information will be very helpful to connect it to an Arduino MEGA 2560, Thank you for helping me and I will be following you to see what more content you make. Thank you.
@werewolfwu
@werewolfwu Жыл бұрын
Hello Paco: glad you found it useful!
@sagarkuthe8302
@sagarkuthe8302 6 ай бұрын
Have you took a trail with pressure sensor with ardunio mega. Is it showing correct feedback? Please reply.
@AlexTechWiz
@AlexTechWiz Жыл бұрын
Thank you for your well-explained video about a 4-20 mA sensor hooked to an Arduino.
@werewolfwu
@werewolfwu Жыл бұрын
Glad you found it useful! Hope you are successful with your project! I'm incorporating these sensors into my 12,500 gallon rainwater collection project right now.
@AlexTechWiz
@AlexTechWiz Жыл бұрын
@@werewolfwu In my case, I am designing a Personal Weather Station, the anemometer and the vane both are 4-20mA. Your video helped me a lot to understand the hook-up and calculations, etc. In the meantime, I am using a 4-20mA simulator to get the calculations right before hooking the anemometer and vane, for example, the vane at 8mA (25%) should indicate 90°, at 12 mA (50%) 180°, etc. You are right, in my case, a 160Ω is the magic resistor value for a 3.2V ESP32 Controller. Here is one problem I solved after I watched your video: I was using two power supplies, one for the ESP32 and one for the 4-20mA simulator, that did not work because the grounds MUST be all connected together. I scaled down the 12V to 5V for the ESP32, same ground all over, bingo! Problem solved. Once again, thank you. Happy new year!
@werewolfwu
@werewolfwu Жыл бұрын
That sounds like a great project! Interfacing with the real world and all! Happy new year to you too!
@bounceurabdelaziz4973
@bounceurabdelaziz4973 Жыл бұрын
Thank you very much, great video, greetings for you from Algeria 🇩🇿
@werewolfwu
@werewolfwu Жыл бұрын
Thank you! Glad you found it useful!
@dimitrimodderman2215
@dimitrimodderman2215 3 ай бұрын
Thanks! Thanks to your video i was able to hook up a 16Bar pressure sensor to my arduino. For some reason my pressure was running from 4mA to 12mA full scale. Also first time i measured 2mA with 0 pressure, after having applied pressure 1 time , funny enough it showed 3.95mA when no pressure was applied. So then it was working as expected. But the max stayed 12mA. The same sensor PT506 exists also in a 25Bar version, maybe they mislabeled mine? However after changing the formule it worked like a charm and the Arduino showed what i was reading on the pressure regulator. Thanks your video was awesome and clear and helped me how to connect 2 wire sensors. So i learned something new. Much appreciated!
@werewolfwu
@werewolfwu 2 күн бұрын
Glad you found it useful!
@ChristianGrau92
@ChristianGrau92 Жыл бұрын
Thank you so much, i have been looking for this exact info a long time! Finally i maybe can use this to get my remote readings with a 4G simcard board
@werewolfwu
@werewolfwu Жыл бұрын
Glad you found it to be useful!
@ChristianGrau92
@ChristianGrau92 9 ай бұрын
@@werewolfwuCorrect me if i'm wrong but didn't you miss a black cable in your picture of the drawing going from the 24v to sensor?
@werewolfwu
@werewolfwu 8 ай бұрын
@@ChristianGrau92 Hello! Sorry for the late reply. There are only two wires connected to the sensor: red and orange. The best way to internalize the working mode of these sensors is to treat them as "smart" resistors, that adjust itself so that the current flowing through them "happens to" scale perfectly with whatever they are sensing. The common arrangement of "red for power black for ground plus some signals" does not apply to these sensors. Hope this helps!
@Steve-xb7dn
@Steve-xb7dn 4 ай бұрын
This is a great video, thanks
@werewolfwu
@werewolfwu 2 күн бұрын
Glad you found it useful!
@TheUnofficialMaker
@TheUnofficialMaker Жыл бұрын
great job, thanks for making the code available. Now, for an IoT example using esp32...
@werewolfwu
@werewolfwu 11 ай бұрын
:-)
@CATiNBRALSTARS
@CATiNBRALSTARS 4 ай бұрын
Can you make a video connecting Pixsys on a pressure sensor please?
@ouat2004
@ouat2004 Жыл бұрын
Thank you for your video. Would you be able to provide the model of LCD display you are using?
@werewolfwu
@werewolfwu Жыл бұрын
Yes! It's amazing that if you search for LCD screens with i2c for Arduino on the internet, there's pretty much only one kind of model that's available, perhaps with different sizes. And that's what I'm using. I actually don't know what I should call it. I only know that all the sellers sell the same thing and all the libraries that you can find in Arduino are actually just slightly different from each other!
@VictorPang-iq4yh
@VictorPang-iq4yh 8 ай бұрын
Hi Werewolf, thank you for sharing such a good content. Btw, do u have the follow up topic on ADC? Thank you!
@werewolfwu
@werewolfwu 8 ай бұрын
Which specific aspect of ADC? Perhaps I can help you out in the comment section first. Let me know what you'd like to know about ADCs. We'll see who answers it better: human or AI.
@PhG1961
@PhG1961 Жыл бұрын
Waw, cool !
@werewolfwu
@werewolfwu Жыл бұрын
Glad you found it useful!
@mirzokhidabdirakhimov8339
@mirzokhidabdirakhimov8339 Жыл бұрын
Thank you so much for your video with a good explanation. I am also working on getting data from the industrial sensor but not getting the same data as the sensor display shows. Could you please help me with it without LCD? Thank you in advance.
@werewolfwu
@werewolfwu Жыл бұрын
Glad it helped!
@petargostovic5295
@petargostovic5295 11 ай бұрын
Hi, thank you for detailed explanation. Do you have idea how can we wire two (or more) sensors like this? How to isolate inputs? Thank you.
@werewolfwu
@werewolfwu 11 ай бұрын
You would need one power supply and 2 return paths to carry two signals.
@caffeinatedinsanity2324
@caffeinatedinsanity2324 Ай бұрын
4-20mA is also nice for fault detection
@werewolfwu
@werewolfwu 2 күн бұрын
Indeed!
@ninepuchar1
@ninepuchar1 Жыл бұрын
May I ask what model of 5V to 24V converter are you using?
@werewolfwu
@werewolfwu Жыл бұрын
It's a generic module that I bought off Jeff Bezos' establishment. Similar things can be found on all sorts of online retailers, simply search for "5V to 24V converter". Required power level is low, a 50mA output capacity (or higher) is enough.
@reginsamueladelantar7838
@reginsamueladelantar7838 Жыл бұрын
Hello! I have a Differential Pressure Transducer (Setra M260 Multi-Sense) and I want to read its output value using Arduino. Can you help me with the code if possible? Thanks! I'm looking forward
@werewolfwu
@werewolfwu Жыл бұрын
Not sure if that's a 4-20mA type sensor, that being said you can probably find what you need on Google. Good luck!
@iniinfoboss3463
@iniinfoboss3463 Жыл бұрын
is it the same way when using a magnesense pressure sensor?
@werewolfwu
@werewolfwu Жыл бұрын
should be!
@diegomestrecam7674
@diegomestrecam7674 Жыл бұрын
If my tank level sensor is a resistive sensor (240-30 ohms) its the same as 4-20mA sensor system?
@werewolfwu
@werewolfwu Жыл бұрын
Hello Diego: if your sensor is a resistive one, it is definitely NOT the same as 4-20mA sensor. You can still use a similar circuit as shown with minimal modification: simply form a resistive divider with your sensor (which is a resistor) and another resistor (say around 100ohms), and sense the divided voltage compared to the reference. This way you get the ratio between the resistors, and hence the resistance value. A little math is needed but not too hard.
@Steve-xb7dn
@Steve-xb7dn 4 ай бұрын
Where's a video about calibrating this sensor?
@darraghross4310
@darraghross4310 Жыл бұрын
Hey can you make a video on how to output 4 to 20ma from an arduino as a source or simulate
@werewolfwu
@werewolfwu Жыл бұрын
Hello Darragh: What you are asking for is essentially the output portion of an actual 4-20mA sensor. There are many ways to create a current source with digital control. e.g. a current DAC or a voltage DAC with a regulating feedback loop etc. If you don't need a lot of resolution, you may want to look at something like Max5550. If you do require a lot of resolution, search for "16 bit current DAC" and there are tons of options out there.
@darraghross4310
@darraghross4310 Жыл бұрын
@Werewolf Wu yeah what I am trying see if I can do is use an arduino to drive a 4 to 20 ma positioner.
@darraghross4310
@darraghross4310 Жыл бұрын
Thanks and great videos
@werewolfwu
@werewolfwu Жыл бұрын
My humble suggestion would be to use some kind of USB to I2C/SPI converter to control the current DAC on your dev bench. This makes the development easier. Once you have the control of the DAC verified, you can code that into an Arduino of sorts if your application requires it.
@TheUnofficialMaker
@TheUnofficialMaker Жыл бұрын
@@darraghross4310 glad it helped!
@danielfernandes2813
@danielfernandes2813 Жыл бұрын
Jeff's establishment 😂😂
@werewolfwu
@werewolfwu 11 ай бұрын
because it is :-)
@estradacantu
@estradacantu Жыл бұрын
Use 250 ohms and convert to 1-5VDC
@werewolfwu
@werewolfwu Жыл бұрын
I would politely caution against using 250Ohms for 5V operation: the "5V" on Arduino is often QUITE OFF from 5V. E.g. if the "5V" is actually 4.5V, you'll lose quite a bit of measurement range. In my very humble opinion, it is much better to have a little bit more quantization noise than losing a chunk of measurement range.
@shuvrasaha297
@shuvrasaha297 Жыл бұрын
Hi can you please share the code?
@werewolfwu
@werewolfwu Жыл бұрын
I'm working on uploading it! I'll reply back here once I have it uploaded together with the next video.
@werewolfwu
@werewolfwu Жыл бұрын
github.com/WerewolfWu/420mAsensor
@mateomenvielle6858
@mateomenvielle6858 Жыл бұрын
hello can you share your arduino code ? please
@werewolfwu
@werewolfwu Жыл бұрын
Of course! I'll reply back once I put it into the cloud.
@werewolfwu
@werewolfwu Жыл бұрын
github.com/WerewolfWu/420mAsensor
@Livenewme
@Livenewme Жыл бұрын
Much cheaper replacement for scata and smart boxes
@werewolfwu
@werewolfwu 11 ай бұрын
indeed!
@n-p2048
@n-p2048 Жыл бұрын
1:20 MA 😂
@werewolfwu
@werewolfwu Жыл бұрын
I know right?
@frenchcreekvalley
@frenchcreekvalley Жыл бұрын
Oh. It's just a pressure sensor, I guess.
@werewolfwu
@werewolfwu Жыл бұрын
Yes it is!
@destinationunknown675
@destinationunknown675 6 ай бұрын
I got it from Jeff Bezos establishment was actually funny. (Amazon) 😂😂😂
@werewolfwu
@werewolfwu 6 ай бұрын
😂😂😂 Didn't want to directly name the establishment
@mfx1
@mfx1 Жыл бұрын
You keep blaming the "$40 sensor" when it's more likely your measurement accuracy that's at fault the Arduino ADC isn't particularly accurate/linear and has pretty poor resolution you'd usually use a proper 4-20mA interface IC but even then you still need a decent ADC. Another useful feature of 4-20mA loops is fault detection, you can tell if the wiring is short/open circuit or if a service tech didn't plug it back in properly.
@werewolfwu
@werewolfwu Жыл бұрын
It's just a joke man... besides It's trivial to calibrate the zero level and gain etc...
@grmcentralkenyatv3409
@grmcentralkenyatv3409 Жыл бұрын
Assuming you put the sensor in a tank and the height keeps changing when there is no water change (water addition or substraction). What could be problem if you are using a 24v battery
@werewolfwu
@werewolfwu Жыл бұрын
Hello GRM Central Kenya TV: If your reading keeps changing while the water level is not changing, then I would start by swapping out the sensor... :-) These sensors are enclosed micro computer systems, it's quite possible to be broken...
@medelghaba4551
@medelghaba4551 Жыл бұрын
Thanks for the video,I have built the same circuit with a water flow sensor, but the output signal has a fluctuation.how can i fix this problème i used ESP32
@werewolfwu
@werewolfwu Жыл бұрын
Start with power supply, follow the signal flow, check power supply and signal flow chains at every point.
4-20 mA Current Loop - History, Why, Advantages, Disadvantages
14:52
Instrumentation Tools
Рет қаралды 166 М.
Now THIS is entertainment! 🤣
00:59
America's Got Talent
Рет қаралды 39 МЛН
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 60 МЛН
Пранк пошел не по плану…🥲
00:59
Саша Квашеная
Рет қаралды 5 МЛН
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 38 МЛН
Using the 555 Timer
42:18
DroneBot Workshop
Рет қаралды 984 М.
4-20mA Industrial Pressure Sensor, Arduino IoT
29:34
EETech_Fix
Рет қаралды 38 М.
How to Interface Industrial Sensors with Arduino Nano
6:27
OnosTech
Рет қаралды 50 М.
3 Tricks for getting a Better ADC for FREE! (Arduino)
9:18
Werewolf Wu
Рет қаралды 1,4 М.
Arduino PLC
38:21
Jakob Sagatowski
Рет қаралды 251 М.
Hacker's Guide to UART Root Shells
17:40
Flashback Team
Рет қаралды 470 М.
Sensors - which one to use
17:06
Electronoobs
Рет қаралды 1,3 МЛН
Now THIS is entertainment! 🤣
00:59
America's Got Talent
Рет қаралды 39 МЛН