RPI420MA - 4/20mA sensor hat for Raspberry Pi
The RPI420MA interface up to seven 4/20mA sensors with a Raspberry Pi.
Data are sent on the serial port of the Raspberry Pi and are easily read from a terminal or with a Python script.
Hardware connections
There are 7 4/20mA port. These are screw terminal connections marked with Positive and Negative ends.
The hat also include a port for external power supply required to supply the sensors. This must be a 12V DC power supply unit. They can be found here.
Pi setup
Please follow the guide below to setup the Raspberry Pi.
Howto setup Raspbian for serial read
Firmware configuration
The configuration can be dumped in a file using the command
lcl-rpict-config.py
The configuration is locate inside /tmp/rpict.conf.
The content of the file looks like this.
[main]
format = 3
nodeid = 11
output_rate = 5000
resistor = 100.0
nsamples = 20
subsample = 100
SCALES = 1.0 1.0 1.0 1.0 1.0 1.0 1.0
OFFSETS = 0.0 0.0 0.0 0.0 0.0 0.0 0.0
You can modify these parameters.
Format Unused.
nodeid Identifies the device in a network. Keep it as 11 if not needed.
output_rate In milliseconds indicate how often data are sent over the serial port.
resistor Must be left by default.
nsamples Number of samples to acquire per burst. 100 samples is the default.
SCALES This is the scaling factor for the sensor reading. The first in the list is for S1. As scale of 1.0 and an offset of 0.0 means the output will be the current in milliamps and is expected to be between 4mA and 20mA. This allows to adjust for the reading to represent physical values instead of currents.
OFFSETS This is the offset for the sensor reading.
The modified config can be written to the hat using
lcl-rpict-config.py -w /tmp/rpict.conf
Reading the output
The output of the hat can be read with a simple command
lcl-run
Here is an example of the output below.
11 3.99 0.00 0.00 0.00 0.00 0.00 0.00
11 3.97 0.00 0.00 0.00 0.00 0.00 0.00
11 3.96 0.00 0.00 0.00 0.00 0.00 0.00
11 3.99 0.00 0.00 0.00 0.00 0.00 0.00
Each line appears every 5 seconds or any value set in the output_rate.
In the example only the first port has a sensor and it is reading nearly 4mA which is the lowest value. All other ports are disconnected.