Raspberrypi Current and Temperature Sensor Adaptor
- 1 RPICT Series
- 2 First time use
- 3 Current Sensor
- 4 Voltage Sensor
- 5 Temperature Sensor
- 6 Power Supply
- 7 View/Record data
- 7.1 Using plain Linux terminal - CAT command
- 7.2 Using InfluxDB and Grafana
- 7.3 Using Home Assistant - home-assistant.io
- 7.4 Using OpenHAB Domoticz HomeGenie mycontroller.org Jeedom
- 7.5 Using Node-Red
- 7.6 Using JSON request
- 7.7 Using Emoncms
- 7.8 Using Python basic script
- 8 Flashing the firmware / Upload Sketch
- 9 Developing Arduino Sketch
- 10 Enclosures
- 11 Related Articles and Howto
- 12 Playground
- 13 Third Party Developments
RPICT series are a range of Raspberrypi hat for AC current sensor (CT) and temperature sensor. This page introduces generalities concerning the RPICT series. Information for each individual board can be found below.
All RPICT board connect to the GPIO connector and provide data via the serial port. An Arduino programmable microcontroller (ATtiny84 or Atmega328) operates the board. Source code for the microcontroller is freely available.
There are various options for logging and viewing the data. Most commonly used are Emoncms and Influxdb with Grafana. Using your own Python script is also possible.
- Raspberrypi Smart Meter.
- Internet of Things.
- Data Logging.
- Real Time Monitoring.
- Home Automation.
Raspberrypi Stackable Boards
V 2 & 3
- RPICT4V3 version 2 & 3 - 4 CT 3 AC Voltage.
- RPICT7V1 version 2 & 3 - 7 CT 1 AC Voltage. [No longer sold]
- RPICT8 version 2 & 3 - 8 CT. [No longer sold]
- RPI_T8 - 8 temperatures.
Raspberrypi for 5A output CT
- RPI LCT3V1 - 3CT 1 Voltage for large CT.
- RPI LCT4V3 - 3CT 3 Voltage for large CT.
- RPI_LCT8 - 8CT for large CT.
- RPIZ_CT3V1 - 3 CT 1 AC Voltage. Raspberrypi Zero.
- RPIZ_CT3T1 - 3 CT 1 Temperature. Raspberrypi Zero.
- RPIZCT4V3T2 - Rpi Zero 4 CT 3 AC Voltage 2 Temperature (RTD & DS18B20)
|RPI_T8||-||-||8||Slave 1 only|
|RPI_LCT4V3||4||3||-||One board stack only|
|RPI_LCT8||8||-||-||One board stack only|
\* AC Voltage
First time use
Insert on Raspberrypi
Insert the RPICT board on the Raspberrypi GPIO as shown above. The picture is a RPI3B but all other Raspberrypi are also compatible.
The RPICT boards gets power from the Raspberrypi. Just connect the USB power adaptor to the Raspberrypi as normal.
If using Raspberry Pi OS follow the guide below to get the Raspberrypi ready for use with the RPICT.
- The board is sold ready to go with firmware and configuration already loaded.
- Make sure to test all sensors with the cat command before changing the configuration.
- Carefully read the Frequently Asked Questions
Any current sensor with current output is compatible. Note there are considerations for the burden resistor which scales the range of measured current. We recommend the sensor below to start with.
- SCT-013-000 100A/50mA
- SCT-019 200A/33mA
- SCT-006 20A/25mA
- SCT-024 400A/100mA
- SCT-031 600A/100mA
Connector: 3.5mm Jack
The range is determined by the burden resistor fitted on the RPICT unit.
The default range is 100A on all RPICT series which correspond to a burden resistor of 24 or 27 Ohm.
More details about the input range and the burden resistor is given in the links below.
- For RPICT3T1 RPICT3V1 RPICT4T4v2.5
- For RPICT7V1 RPICT8 and RPICT4V3 V4
- For RPICT7V1 RPICT8 RPICT4V3 V5
CT sensors only measures Alternating Currents (AC). Refer to sensor ACS715 for DC current.
Only RPICT7V1 Version 4 and RPI_DCV8 can support voltage output CT. SCT-013-xxx other than SCT-013-000 and any voltage output CT are not supported for all other boards.
To evaluate the power of an installation a voltage sensor is not strictly necessary. Power can be estimated using an estimated fixed voltage (usually 240 or 110V). Voltage sensor becomes necessary if you wish to measure more accurately Real Power, Apparent Power and Power Factor. The combination of a voltage sensor with a CT sensor will also provide the direction of power (import/export).
In any case power readings with voltage sensor are more precise and consistent. They also have much lower noise and are better for low power readings.
The RPICT series are shipped using a basic calibration for the voltage port. A calibration would be needed if you feel the measured voltage is not accurate enough against another well trusted measuring device (scope, multimeter). Use this page to calibrate the voltage port.
AC/AC Voltage Sensor
We offer a set of AC/AC transformers to measure Voltage. These units can be easily plug in a main wall socket. No wiring is required.
The three different models we recommend are:
The ZMPT101B module is a voltage module to be wired. It measures voltages up to 250V and can be mounted on DIN rails.
The temperature sensor is the DS18B20.
Temperature sensors come with various connectors.
3 pin Molex
This applies for board RPIZCT4V3T1 and RPIZCT4V3T2.
This applies for boards RPICT3T1 RPICT4T4 and RPIZ_CT3T1. Connectors are screw terminals. Temperature probe should present bare wires for connecting.
Our DS18B20 Junction board requires bare wires for connection.
The raspberrypi should use the usual micro-usb PSU.
The RPICT series do not need any extra PSU. Power for the RPICT is taken from the Raspberrypi GPIO.
In the most basic use the RPICT series only output a serial string. It is down to the user to collect this data string and record/view as needed. We offer below various way to achieve this.
- Using cat command.
- Using Influxdb and Grafana.
- Using a Json request.
- Using Emonhub tool from Emoncms.
- Using a Python script.
Using plain Linux terminal - CAT command
This option reads data output from a linux terminal using the cat command. Direct reading of the serial port.
Note: This is the most basic usage. We highly recommend to make use of this first before anything else.
Before hand make sure you have followed this guide if you are using the Rasbian image.
Let's use the RPICT3T1 as an example. The format of the output is as shown below. Powers in W. Temperature in deg Celsius. For any other RPICT unit refer to its specific page to know the default output format.
nodeid power1 power2 power3 temperature
Log in the Raspberrypi using ssh and issue the commands
stty -echo -F /dev/ttyAMA0 raw speed 38400 cat /dev/ttyAMA0
The terminal should then show something like this below
pi@raspberrypi ~ $ cat /dev/ttyAMA0 11 46.23 52.25 126.56 19.46 11 47.43 52.28 129.60 19.54 11 48.90 53.88 131.22 19.89
To figure out which channel correspond to which measured value refer to the specific board dedicated page.
Note. If using the emonpi image run the command below before the stty command.
sudo /etc/init.d/emonhub stop
Using InfluxDB and Grafana
InfluxDB is an open source project backed by Influxdata. It is all free if you install on your own server. Only a hosted solution is payable.
InfluxDB on its own is just a database ready to store the data. Data can be viewed with Grafana or directly inside Influxdb.
See this guide proposing a solution to send data to an Influxdb database.
Using Home Assistant - home-assistant.io
Follow this guide below for Homeassistant.
Using OpenHAB Domoticz HomeGenie mycontroller.org Jeedom
We have not yet documented any of these platform yet. Please contact us to notify your interest in using them with RPICT series board.
Jeedom. Credit to tlierdotfr on Github for making a plugin for Jeedom.
See the link below for an example using Node-Red.
Using JSON request
The Raspberrypi can be setup to serve Json requests on http.
Preliminaries. This is for a Raspbian default image. This guide should be completed first.
Issue the commands below. This installs a http server. Configure it and setup the binary of emonwrt3. Emonwrt3 aims to save the data into a rolling database.
sudo apt-get install lighttpd sudo wget lechacal.com/repo/emonwrt3/lighttpd.conf -O /etc/lighttpd/lighttpd.conf sudo /etc/init.d/lighttpd restart wget lechacal.com/repo/emonwrt3/emonwrt3_rpi_armhf_v1.0.1.deb sudo dpkg -i emonwrt3_rpi_armhf_v1.0.1.deb
Once complete you should be able to request the json data using the address below.
Modify last=1 to the number of records you need to acquire. Remove the variable altogether to obtain all data (default limit is 128 records).
Emoncms is a very complete and user friendly interface. Emonhub is used to forward the data from the RPICT to the Emoncms service. We also show some alternatives below.
Using Emonhub format - Emonpi image [Recommended]
If you are using this option then you should download the emonpi image from this link below.
Flash this image onto a SD card. Once the Raspberrypi powered up point your web browser to http://emonpi. Then modify the emonhub configuration as shown below.
Delete or backup the entire content of Emonhub configuration and replace with this one below.
[hub] ### loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL ### see here : http://docs.python.org/2/library/logging.html loglevel = DEBUG #(default:WARNING) [interfacers] [[SerialDirect]] Type = EmonHubSerialInterfacer [[[init_settings]]] com_port = /dev/ttyAMA0 com_baud = 38400 [[[runtimesettings]]] pubchannels = ToEmonCMS, [[emoncmsorg]] Type = EmonHubEmoncmsHTTPInterfacer [[[init_settings]]] [[[runtimesettings]]] subchannels = ToEmonCMS, #url = http://localhost/emoncms #uncomment to save on local pi apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx senddata = 1 # Enable sending data to Emoncms.org sendstatus = 1 # Enable sending WAN IP to Emoncms.org MyIP > https://emoncms.org/myip/list sendinterval= 30 # Bulk send interval to Emoncms.org in seconds [nodes] [] nodename = my_RPICT7V1 [[[rx]]] names = RP1, RP2, RP3, RP4, RP5, RP6, RP7, Irms1, Irms2, Irms3, Irms4,Irms5,Irms6,Irms7,Vrms scales = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 units =W,W,W,W,W,W,W,mA,mA,mA,mA,mA,mA,mA,V datacode = 0
Replace the apikey with the one given by your Emoncms account. Use the Read and Write key.
Modify the [] entry as needed. Refer to the board specific page to modify the last part of the config where it starts with node ID.
Using Emonhub format - Raspbian image [Alternative Option]
It is possible to use a native Rapbian image and install only emonhub to forward the data. In this case you will miss the web interface to the raspberrypi. For this follow the guide below.
Using the gateway tool to forward the data [Alternative Option]
We are proposing a basic script template which can be installed as below.
Get the lcl-gateway tool and install it this way.
wget lechacal.com/RPICT/tools/lcl-gateway_1.3.0_armhf.deb sudo dpkg -i lcl-gateway_1.3.0_armhf.deb
Edit the lcl-gateway.conf file to reflect your own setting. Content is self explanatory.
sudo nano /etc/lcl-gateway.conf
Insert the RPICT and run
Using Python basic script
Using the same sketch as mentioned above a python script can be used to work with the data. The example script below will be a good starting point.
First of all make sure you have python-serial package installed
$ sudo apt-get install python-serial
Then copy the following into an executable file and run it.
#!/usr/bin/python import serial ser = serial.Serial('/dev/ttyAMA0', 38400) try: while 1: response = ser.readline() z = response.split(" ") if len(z)>=3: print "Power 1: %s Watts" % z print "Power 2: %s Watts" % z print "Power 3: %s Watts" % z print "Temperature: %s Degrees" % z[:-2] except KeyboardInterrupt: ser.close()
The above example is for the RPICT3T1 board. If using a different RPICT refer to the page of that particular board.
Flashing the firmware / Upload Sketch
There is no need to flash the firmware (sketch) if you have just purchased the unit. They are sold ready to run. There is no need to reflash the microcontroller if you wish to change parameters. The board can be configured using the Raspberrypi. See relevant configuration documentation for this.
The reasons one would flash a new firmware are:
- Update to a new version.
- Flash your own sketch.
The onboard microcontroller can be re-programmed using the Arduino IDE software and an AVR programmer. We recommend our NanoProg programmer for this.
RPICT series come with 2 type of microcontrollers. Attiny84 and Atmega328p. See below.
RPICT4T4, RPICT3V1, RPICT3T1, RPIZ_CT3V1, RPIZ_CT3T1
These boards use attiny84 mcu.
This link is a tutorial to upload Arduino sketches to the Attiny84. .
RPICT8, RPICT7V1, RPICT4V3, RPIZ_CT4V3T2
These boards use atmega328p mcu.
Developing Arduino Sketch
There is no need to know how to program or even flash any firmware to use any of the RPICT series. They all come with a ready to use firmware (or Arduino sketch). Nevertheless it is possible to modify or edit your own arduino sketch. RPICT series are well inclined for this purpose.
To make things easier we have developed the RPICTlib. It contain functions to easily compute all aspect of AC signal such as RMS value or Active Power and more.
The link below is an introduction to this library with plain simple examples.
Some RPICT have enclosures available as 3D printed product.
Related Articles and Howto
Third Party Developments
All of the links below are not managed by LeChacal. We think they might be of interest if you need inspiration.