I have attached a 4…20 mA waterlevel sensor (0 - 0.4 bar, operates from 10 - 30 V) to a 4-20 mA Current Receiver and am logging the values with python script running on a Raspberry Pi via one of your I2C-Interfaces for Raspberry Pi.
gain factor
Which gain factor should I use? I am currently running with the gain factor 1 but I think this does not use the full resolution of the ADC. Is there a formula to calculate the gain factor?
single ended vs differential
I only get reasonable readings if I use “single ended” altough I would have expected that the circuit above is a differential measurement
calculate min/max values
How do I calculate the correct values from the ADC for the equivalents of 0, 4 and 20 mA to correctly scale to the physical value?
At the moment I get the following measurements:
96 : sensor is not attached
3250: Sensor value 0
6350: 0.1 bar (1/4 of the sensors max)
I can’t currently measure the sensors maximum value but estimate the ADC reading to be about 15664
use external voltage
Currently the sensor is running of the 16 V provided by the Current Receiver. Is it possible to use an external voltage? This would enable me to run the sensor with 12 V from a battery.
Hello Bhaskar,
thanks for the fast reply, everything is working now.
I had used the code you linked to as a starting point and was unsure about the gain. A comment says to use a gain factor of 2 but actually a gain factor of 1 is used later in the program. I will from now on use the gain factor of 2.
On board power is ok for now but I may at some time come back to this point as external power would probably help to save some power (At the moment: 12 V battery -> 5 V Raspberry Pi -> 16 V voltage for the sensor).
@Bhaskar I would like to use the 2-Channel 4-20 mA Current Loop Receiver 16-Bit ADS1115 I2C Mini Module with a Pycom Lopy device, I do not know which library should I use (lopy is a micropython device), or what i2c registers in the module should I read, do you could help me to indicate the correct direction?
Thanks for the information, but it does not work for me because they are different devices, this only has 2 4-20mA channels, and the micropython commands from the Lopy are different. Even connecting it to Lopy and scan for it on the bus I could not find it.
this are my initial code, but don’t find the device
from machine import I2C
# configure the I2C bus
i2c = I2C(0, I2C.MASTER, baudrate=100000)
i2c.scan() # returns list of slave addresses
this is what returns:
>>> Running e:\Pycom\projects\ReadI2C4-20mA\main.py
>>>
>>>
╝╝>
Pycom MicroPython 1.18.1.r1 [v1.8.6-849-b0520f1] on 2018-08-29; LoPy with ESP32
Type "help()" for more information.