Difference between revisions of "Raspberrypi Current and Temperature Sensor Adaptor"

From lechacal
Jump to: navigation, search
(Current Sensor)
Line 239: Line 239:
CT sensors only measures Alternative Currents (AC). Refer to sensor [[ACS715_Sensor | ACS715]] for DC current.
CT sensors only measures Alternating Currents (AC). Refer to sensor [[ACS715_Sensor | ACS715]] for DC current.
Do not be tempted to use voltage output SCT sensor like SCT-013-030 or similar. All these SCT are SCT-013-000 with a burden resistor fitted inside them. However this is clearly not the best option as they are scaled for 1V output. Arduino microcontroller use 3.3V or 5V. We fit the burden resistor on the RPICT series for optimum scaling.
Do not be tempted to use voltage output SCT sensor like SCT-013-030 or similar. All these SCT are SCT-013-000 with a burden resistor fitted inside them. However this is clearly not the best option as they are scaled for 1V output. Arduino microcontroller use 3.3V or 5V. We fit the burden resistor on the RPICT series for optimum scaling.

Revision as of 08:32, 15 January 2020

IMG 1125 small.png
IMG 1128 small.png

RPICT Series

RPICT series are a set 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 & 400A or more CT

Raspberrypi Zero

  • RPIZ_CT3V1 - 3 CT 1 AC Voltage. Raspberrypi Zero.
  • RPIZ_CT3T1 - 3 CT 1 Temperature. Raspberrypi Zero.
  • RPIZCT4V3T1 - Rpi Zero 4 CT 3 AC Voltage 1 Temperature

Model #CT #Volt* #Temp Stackable
RPICT3T1 3 - 1 No
RPICT3V1 3 1 - No
RPICT4T4 4 - 4 No
RPICT4V3 v1 4 3 - No
RPICT4V3_v2.0 4 3 - Yes
RPICT7V1_v2.0 7 1 - Yes
RPICT8 8 - - Yes
RPIZCT4V3T1 4 3 1 n/a
RPI_T8 - - 8 Slave 1 only
RPI_LCT4V3 4 3 - One board stack only
RPI_LCT8 8 - - One board stack only

\* AC Voltage

Insert on Raspberrypi

Insert board here.png

Power is provided from the Raspberrypi. There is no need for extra power supply.

First Time use

If using Raspbian OS follow the guide below to get the Raspberrypi ready for use with the RPICT.

Howto setup Raspbian for serial read

Also carefully read the FAQ below.

Frequently Asked

Current Sensor


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.

Recommended sensor:

  • SCT-013-000 100A/50mA
  • SCT-019 200A/33mA
  • SCT-006 20A/25mA

Connector: 3.5mm Jack

Measured range

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 Ohm. The table below shows alternative ranges with their associated burden resistor values. The range is for rms value.

Sensor Range
(Rms Amps)
Burden Resistor
Calibration Coefficient
SCT-019-000 200 33 181.82
SCT-013-000 100 24 83.33
60 39 51.28
50 47 42.55
30 75 26.67
25 91 21.98
20 120 16.67
SCT-006-000 20 47 17.02

SCT-013-xxx other than SCT-013-000 are not supported. Likewise for any voltage output CT. Use the current output SCT with adequate burden resistor instead.


CT sensors only measures Alternating Currents (AC). Refer to sensor ACS715 for DC current.

Do not be tempted to use voltage output SCT sensor like SCT-013-030 or similar. All these SCT are SCT-013-000 with a burden resistor fitted inside them. However this is clearly not the best option as they are scaled for 1V output. Arduino microcontroller use 3.3V or 5V. We fit the burden resistor on the RPICT series for optimum scaling.

Voltage Sensor

An AC/AC adaptor is used to measure Voltage. We have a set of recommended adaptors:

  • UK: 77DB-06-09
  • EU: 77DE-06-09
  • US: 77DA-10-09

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.

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).

Temperature Sensor


The temperature sensor is the DS18B20.

Temperature sensors come with various connectors.

3 pin Molex

This applies for board RPIZCT4V3T1.

Bare wires

This applies for boards RPICT3T1 and RPICT4T4. Connectors are screw terminals. Temperature probe should present bare wires for connecting.

Power Supply

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.

View/Record data

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 scrypt.

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.

As an example the output from the RPICT3T1 adaptor board will be in the format below. power in kw. temperature in deg celsius.


Log in the Raspberrypi using ssh and issue the commands

stty -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

See another alternative here. Using plink
See also. Recording RPICT Serial stream on local file

Using InfluxDB and Grafana

GRAFANA 001.png

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.

See this guide proposing a solution to send data to an Influxdb database.
Example Using InfluxDB.

Also see
Install an InfluxDB Grafana stack on a Raspberrypi

For a readily hosted solution with Influxdb/Grafana see Corlysis.

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).

The web browser will show the data as below. Number of channels will depend on the unit used. Our example here as 4 channels CH_00 to CH_03.
Json req emonwrt3 01.png

Using Emoncms

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.

### 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)


  Type = EmonHubSerialInterfacer
      com_port = /dev/ttyAMA0
      com_baud = 38400
     pubchannels = ToEmonCMS,

   Type = EmonHubEmoncmsHTTPInterfacer
       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


  nodename = my_RPICT7V1
     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 [[11]] 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 [Not Recommended]

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.

Use Emonhub with RPICT

Using the gateway tool to forward the data [Not Recommended]

We are proposing a basic script template which can be installed as below.

wget lechacal.com/RPICT/tools/lcl-gateway.py.zip
unzip lcl-gateway.py.zip
wget lechacal.com/RPICT/tools/gateway.conf
sudo apt-get install python-requests

Edit the gateway.conf file to reflect your own setting. Content will be self explanatory.

nano 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.

import serial
ser = serial.Serial('/dev/ttyAMA0', 38400)

       while 1:
               response = ser.readline()
               z = response.split(" ")
               if len(z)>=3:
                       print "Power 1: %s Watts" % z[1]
                       print "Power 2: %s Watts" % z[2]
                       print "Power 3: %s Watts" % z[3]
                       print "Temperature: %s Degrees" % z[4][:-2]
except KeyboardInterrupt:

The above example is for the RPICT3T1 board. If using a different RPICT refer to the page of that particular board.


Spiotrealtime 001.png

Download and install SPIOT on a given server. This could be the raspberrypi itself.

From the downloaded archive there is a directory called rpi containing python scripts and configuration file. Copy all these files on the raspberrypi (if not already there).

Make sure all .py files are executable:

$ chmod 755 *.py

Open the spiot.config file and modify the csv_forward section. port and hostname variable will be the most important ones for a first test. Keep apikey and node as they are to follow this example.

port = /dev/ttyAMA0
hostname = myserver/spiot
apikey = qbG31dQxFlG55mNM8G5ZTFkF0mrUbWg5
node = 20
baud = 38400

Then run the spiot_csv.py utility.


Then point your webbrowser to the link below:


The last 5 minutes of the first channel will be shown on a graph.

Flashing the firmware / Upload Sketch

The onboard microcontroller can be re-programmed using the Arduino IDE software and an AVR programmer.

There is no need to reflash the microcontroller if you wish to change parameters for the following boards: RPICT7V1 version 2, RPICT4V3 version 2, RPICT8, RPICT3T1, RPICT3V1, RPICT4T4.

For other type of boards such as RPICT7V1 model 1, RPICT4V3 model 1 the only way to modify parameters is to modify the sketch and upload it to the microcontroller. This would applies for changing output format (csv/emoncms) or calibration values.


This link is a tutorial to upload Arduino sketches to the Attiny84. .


Upload Arduino sketch to Atmega328.



Some RPICT have enclosures available as 3D printed product.

See the shop item for
RPICT3T1 Enclosure
RPICT8 Enclosure
RPICT7V1 Enclosure
RPICT4V3 Enclosure

Related Howto

Frequently Asked

Howto setup Raspbian for serial read

Example Using InfluxDB

How to calibrate the Voltage Port


Use Emonhub with RPICT

Burden Resistor calculation

How to program an Attiny85 or Attiny84

RPICT Online Config Generator


Transform a RPICT into a web scope

Noise level test RPICT V2&3

RPICT and Node-Red hosted on Raspberrypi


External Resources

An enclosure alternative for RPICT7V1