Cooking Hacks Forum
https://www.cooking-hacks.com/forum/

4-20mA current loop board with Raspberry pi using Node Red
https://www.cooking-hacks.com/forum/viewtopic.php?f=44&t=9050
Page 1 of 1

Author:  mgirdner [ Sat Jul 30, 2016 11:16 pm ]
Post subject:  4-20mA current loop board with Raspberry pi using Node Red

I am trying to figure out how to use the Libelium 4-20mA board to read 4-20mA sensors and get the data into Node Red on the Raspberry Pi. I have been able to get the 4-20mA board to read the sensor using the 4-20mA board and the Arduino Bridge board, but can't seem to figure out how to get the Raspberry Pi to read the data into a Node Red program. Does anyone know if any tutorial or where I can find more information on how to do this? I am not a programmer by trade but have messed with Arduino and Raspberry Pi for a while now so I do know some things, just not enough to get done what I want in this case.

Author:  libelium-dev [ Mon Aug 01, 2016 7:55 am ]
Post subject:  Re: 4-20mA current loop board with Raspberry pi using Node R

Hello mgirdner,
Sorry about that but we are not experience with Node Red. Maybe any user could help you.
Regards

Author:  mgirdner [ Wed Aug 03, 2016 12:31 am ]
Post subject:  Re: 4-20mA current loop board with Raspberry pi using Node R

I have decided to start by using an Arduino Uno to read the 4-20mA board and got that working fine. I can then use the Pi to read the Uno's serial port and I send the data that way. What I found when I got this working that a 0-20mA input to the board is giving me an integer reading of 0 to 670 using the readChannel command, not the 0 to 1023 that the specs say. Any reason it wouldn't output 0-1023 for 0-20mA?

Author:  libelium-dev [ Wed Aug 03, 2016 7:55 am ]
Post subject:  Re: 4-20mA current loop board with Raspberry pi using Node R

Hello mgirdner,
Quote:
I found when I got this working that a 0-20mA input to the board is giving me an integer reading of 0 to 670 [..]

It is not normal.
Can you test the examples provided with the library?. Please post some pictures of your hardware configuration to check it visually.
Regards.

Author:  mgirdner [ Thu Aug 04, 2016 2:21 pm ]
Post subject:  Re: 4-20mA current loop board with Raspberry pi using Node R

Here is a link to pictures of my setup:

https://www.dropbox.com/sh/3wj4fanboq6j ... 75d0a?dl=0

I am using a Fluke 4-20mA calibrator to supply the current to the test rig so I know the mA is correct. I am powering the Arduino with an external power supply. I have tried the "basic" test program on all four analog input channels with the same result - with small variations in the integer readings as would be expected.

The readCurrent command gives the correct mA reading, but the readChannel only gives 670 to 676 or so on the 20mA input and 130 to 133 on the 4mA input. Any ideas on why this is happening?

Author:  libelium-dev [ Fri Aug 05, 2016 7:36 am ]
Post subject:  Re: 4-20mA current loop board with Raspberry pi using Node R

Hello mgirdner,

Your readings are correct. Te full scale of the ADC is 5V(1024) -> 30,30mA. You can increment the maximun channel current to 30,30mA. At 20mA the voltage in the adc is Vadc=R * 20mA= 165 *0,02=3V3. This means that at 20mA the ADC reads 3,3/5*1024 = 675,84.
This over current full scale is for 3V3 boards compatibility.

You can improve the precision adjusting the end scale to 20mA in two ways:
1.- Working with an arduino 3V3 board.
2.- Giving an external reference of 3V3 to the arduino AREF pin and merge this line in your code:
Code:
analogReference(EXTERNAL);

and modify the readVoltage() procedure to:
Code:
float currentLoop::readVoltage(uint8_t channel)
{
   return (readChannel(channel) * 3.3 /1023);
}



Check this URL:
https://www.arduino.cc/en/Reference/AnalogReference

Regards.

Author:  mgirdner [ Fri Aug 05, 2016 3:21 pm ]
Post subject:  Re: 4-20mA current loop board with Raspberry pi using Node R

Thanks, I used the 3.3 VDC pin on the Arduino to the AREF pin and the readChannel now returns 1020 at 20mA - I am doing all scaling in the Pi so I don't need the readVoltage or readCurrent commands in the Arduino.

Author:  libelium-dev [ Mon Aug 08, 2016 7:40 am ]
Post subject:  Re: 4-20mA current loop board with Raspberry pi using Node R

Hello mgirdner;
You are welcome, thanks by your contribution and good luck with your project.
Regards.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/