Raspberrypi Current and Temperature Sensor Adaptor: Difference between revisions

From lechacal
Jump to navigation Jump to search
 
(197 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Image:IMG_1125_small.png | right | 300px]]
[[Image:IMG_1125_small.png | right | 300px | alt="AC monitoring"]]
[[Image:IMG_1128_small.png | right | 300px]]
[[Image:IMG_0535_small.png | right | 300px | alt="Raspberrypi Smart Meter"]]


{{#seo:
|title=RPICT Series - Raspberrypi Hat for AC monitoring
|title_mode=append
|keywords=Raspberrypi,Alternating Current, Smart meter, Rapsberrypi Hat, Raspberrypi Smart Meter
|description=RPICT series allow for monitoring of AC power lines. Both in single and 3 phase.
}}


=RPICT Series=
=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.
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.
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.
Line 17: Line 23:
* Real Time Monitoring.
* Real Time Monitoring.
* Home Automation.
* Home Automation.


'''Raspberrypi'''
'''Raspberrypi'''
* [[RPICT3T1]]  - 3 CT 1 Temperature.
* [[RPICT3T1]]  - 3 CT 1 Temperature.
* [[RPICT3V1]] - 3 CT 1 AC Voltage.
* [[RPICT3V1]] - 3 CT 1 AC Voltage.
* [[RPICT4V3]] - 4 CT 3 AC Voltage.
* [[RPICT4T4 | RPICT4T4 version 2.5]] - 4 CT 4 Temperature.
* [[RPICT4V3_v2.0]] - 4 CT 3 AC Voltage.
 
* [[RPICT4T4]] - 4 CT 4 Temperature.
'''Raspberrypi Stackable Boards'''<br>
* [[RPICT7V1_v2.0]] - 7 CT 1 AC Voltage.
'''V 2 & 3'''
* [[RPICT8]] - 8 CT.
* [[RPICT4V3_v2.0 | RPICT4V3 version 2 & 3]] - 4 CT 3 AC Voltage.
* [[RPI_T8]] - 8 temperatures.
* [[RPICT7V1_v2.0 | RPICT7V1 version 2 & 3]] - 7 CT 1 AC Voltage. [No longer sold]
* [[RPICT8 | RPICT8 version 2 & 3]] - 8 CT. [No longer sold]


'''V 4'''
* [[RPICT7V1 Version 4]]
* [[RPICT7V1 Version 4]]


'''Raspberrypi & 400A or more CT'''
'''V 5'''
* [[RPICT7V1 Version 5]]
* [[RPICT4V3 Version 5]]
* [[RPICT8 Version 5]]
* [[RPICT4T4 Version 5]]
* [[RPICT4W3T1]]
 
'''Temperature Only'''
* [[RPI_T8]] - 8 temperatures.
 
'''Raspberrypi for 5A output CT'''
* [[RPI LCT3V1]] - 3CT 1 Voltage for large CT.
* [[RPI LCT3V1]] - 3CT 1 Voltage for large CT.
* [[RPI LCT4V3]] - 3CT 3 Voltage for large CT.
* [[RPI LCT4V3]] - 3CT 3 Voltage for large CT.
Line 39: Line 56:
* [[RPIZ_CT3V1]] - 3 CT 1 AC Voltage. Raspberrypi Zero.
* [[RPIZ_CT3V1]] - 3 CT 1 AC Voltage. Raspberrypi Zero.
* [[RPIZ_CT3T1]] - 3 CT 1 Temperature. Raspberrypi Zero.
* [[RPIZ_CT3T1]] - 3 CT 1 Temperature. Raspberrypi Zero.
* [[RPIZCT4V3T1]] - Rpi Zero 4 CT 3 AC Voltage 1 Temperature
* [[RPIZCT4V3T2]] - Rpi Zero 4 CT 3 AC Voltage 2 Temperature (RTD & DS18B20)
 


'''with relays'''
* [[RPICT3T1_RLY2]] - 3 CT 1 Temperature 2 Relays
* [[RPICT3V1_RLY2]] - 3 CT 1 AC Voltage 2 Relays


{| class="wikitable"  
{| class="wikitable"  
Line 74: Line 93:
| -
| -
| 4
| 4
| No
|
|
|-
| [[RPICT4V3]] v1
| 4
| 3
| -
| No
| No
|
|
Line 155: Line 166:
<br>
<br>


=Insert on Raspberrypi=
=First time use=
 
===Insert on Raspberrypi===


[[Image:Insert_board_here.png]]
[[Image:Insert_board_here.png]]


Power is provided from the Raspberrypi. There is no need for extra power supply.
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.


===First Time use===
===Raspberrypi Configuration===
If using Raspbian OS follow the guide below to get the Raspberrypi ready for use with the RPICT.<br>
If using [https://www.raspberrypi.org/downloads/raspberry-pi-os/ Raspberry Pi OS] follow the guide below to get the Raspberrypi ready for use with the RPICT.<br>


[[Howto setup Raspbian for serial read]]
[[Howto setup Raspbian for serial read]]


Also carefully read the FAQ below.
===Next steps===
* The board is sold ready to go with firmware and configuration already loaded.
* Make sure to test all sensors with the cat or lcl-run command before changing the configuration.
* Carefully read the FAQ below
 
[[Frequently Asked | FAQ - Frequently Asked Questions]]


[[Frequently Asked]]
===First configuration===
 
[[First Configuration RPICT]]


=Current Sensor=
=Current Sensor=


[[File:IMG_0773.jpg | right | 240px]]
[[File:269.jpg | right | 240px]]


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.  
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.  
Line 180: Line 202:
* SCT-019    200A/33mA
* SCT-019    200A/33mA
* SCT-006      20A/25mA
* SCT-006      20A/25mA
* SCT-024    400A/100mA
* SCT-031    600A/100mA


Connector: 3.5mm Jack
Connector: 3.5mm Jack
Line 185: Line 209:
==Measured range==
==Measured range==


The range is determined by the burden resistor fitted on the RPICT unit.  
The range is determined by the burden resistor fitted on the RPICT unit. At purchase time this is selected using the parameter ''rating'' in the shop.


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 default range is 100A on all RPICT series which correspond to a burden resistor of 24 or 27 Ohm. Other ratings (or ranges) can be selected at purchase time.
The range is for rms value.


{| class="wikitable"
More details about the input range and the burden resistor is given in the links below.
|+
|-
!Sensor
!Range<br> (Rms Amps)
!Burden Resistor<br> (Ohm)
!Calibration Coefficient<br> (theoretical)
|-
| '''SCT-019-000'''
| 200
| 33
| 181.82
|-
| rowspan=6 | '''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.
* For RPICT3T1 RPICT3V1 RPICT4T4v2.5 and also RPICT8/RPICT7V1/RPICT4V3 in version 3<br>
[[Gen3 Passive Component Setup]]<br>
* For RPICT7V1 RPICT8 and RPICT4V3 in version 4<br>
[[Gen4 Passive Component Setup]]<br>
* For RPICT7V1 RPICT8 RPICT4V3 in version 5<br>
[[Gen5 Passive Component Setup]]<br>


==Notes==
==Notes==


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


=Voltage Sensor=
=Voltage Sensor=


An AC/AC adaptor is used to measure Voltage. We have a set of recommended adaptors:
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).
* UK: 77DB-06-09
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).
* EU: 77DE-06-09
 
* US: 77DA-10-09
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 [[ Calibration VCAL ICAL PHASECAL |this page ]] to calibrate the voltage port.<br>
 
 
===AC/AC Voltage Sensor===
 
====Low Voltage < 250V====
 
The three models available depending on mains power type:
* UK: [http://lechacalshop.com/gb/internetofthing/24-acac-adaptor-voltage-sensor-for-rpict-series.html 77DB-06-09]
* EU: [http://lechacalshop.com/gb/internetofthing/29-acac-adaptor-voltage-sensor-for-rpict-series.html 77DE-06-09]
* US: [http://lechacalshop.com/gb/internetofthing/54-usacac.html 77DA-10-09]
 
[[File:Acac-adaptor-voltage-sensor-for-rpict-series.jpg | 300px]]
 
These units can be easily plug in a main wall socket. No wiring is required.
 
Three units are needed to monitor 3 phase.
 
====High Voltage up to 1500V====
 
[https://lechacalshop.com/gb/voltage/117-tv30gb-ac-voltage-sensor.html TV30GB]
 
[[File:P1000476.JPG small.png | 300px]]
 
The TV30GB can read Voltages up to 1500V. Wiring required.
 
Three units are needed to monitor 3 phase.
 
===ZMPT101B Module===
 
The ZMPT101B module is a voltage module to be wired. It measures voltages up to 250V and can be mounted on DIN rails.
 
'''For single phase:''' [[ZMPT101B_Module_1x_v2]]
 
[[File:IMG_0665_small.png | 250px]]


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 [[ How to calibrate the Voltage Port|this page ]] to calibrate the voltage port.<br>
'''For three phase:''' [[ZMPT101B_Module_3x_v4]]


[[File:P1000448.JPG_small.png | 250px]]


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).
[[File:No_zmpt.jpeg | 125px]] Do not use these ZMPT module sold on the market. They do not scale against the RPICT units and the presence of a potentiometer make them unreliable.
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=
=Temperature Sensor=
Line 264: Line 285:
Temperature sensors come with various connectors.
Temperature sensors come with various connectors.


==3 pin Molex==
===3 pin Molex===
This applies for board RPIZCT4V3T1.
This applies for board RPIZCT4V3T1 and RPIZCT4V3T2.


==Bare wires==
===Bare wires===
This applies for boards RPICT3T1 and RPICT4T4. Connectors are screw terminals. Temperature probe should present bare wires for connecting.
This applies for boards RPICT3T1 RPICT4T4 and RPIZ_CT3T1. Connectors are screw terminals. Temperature probe should present bare wires for connecting.
 
Our [http://lechacalshop.com/gb/internetofthing/80-ds18b20-junction-board.html DS18B20 Junction board] requires bare wires for connection.


=Power Supply=
=Power Supply=
Line 284: Line 307:
* Using a Json request.
* Using a Json request.
* Using Emonhub tool from Emoncms.
* Using Emonhub tool from Emoncms.
* Using a Python scrypt.
* Using a Python script.




Line 294: Line 317:
Before hand make sure you have followed  [[Howto setup Raspbian for serial read |this guide]] if you are using the Rasbian image.<br>
Before hand make sure you have followed  [[Howto setup Raspbian for serial read |this guide]] if you are using the Rasbian image.<br>


As an example the output from the RPICT3T1 adaptor board will be in the format below. power in kw. temperature in deg celsius.
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.


  power1,power2,power3,temperature
  nodeid power1 power2 power3 temperature


Log in the Raspberrypi using ssh and issue the commands
Log in the Raspberrypi using ssh and issue the commands


  stty -F /dev/ttyAMA0 raw speed 38400
  stty -echo -F /dev/ttyAMA0 raw speed 38400
  cat /dev/ttyAMA0
  cat /dev/ttyAMA0


Line 316: Line 339:


See another alternative here. [[Using plink]]<br>
See another alternative here. [[Using plink]]<br>
See also. [[Recording RPICT Serial stream on local file]]
 
To record the data in a text file see [[Recording RPICT Serial stream on local file]]


==Using InfluxDB and Grafana==
==Using InfluxDB and Grafana==
Line 323: Line 347:
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 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.
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.<br>
See this guide proposing a solution to send data to an Influxdb database.<br>
[[Example Using InfluxDB]].


Also see<br>
[[Forward to Influxdb from RPICT]]
 
See also<br>
[[Install an InfluxDB Grafana stack on a Raspberrypi]]
[[Install an InfluxDB Grafana stack on a Raspberrypi]]


For a readily hosted solution with Influxdb/Grafana see [https://corlysis.com Corlysis].
==Using Home Assistant - home-assistant.io==
 
Follow this guide below for Homeassistant.
 
[[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 [https://github.com/tlierdotfr/jeedom-plugin-rpict plugin for Jeedom].
 
==Using Node-Red==
 
See the link below for an example using Node-Red.
 
[[RPICT_and_Node-Red_hosted_on_Raspberrypi]]


==Using JSON request==
==Using JSON request==
Line 354: Line 395:
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.<br>
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.<br>
[[File:Json_req_emonwrt3_01.png]]
[[File:Json_req_emonwrt3_01.png]]


==Using Emoncms==
==Using Emoncms==
Line 362: Line 401:
Emonhub is used to forward the data from the RPICT to the Emoncms service. We also show some alternatives below.
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]===
===Emoncms and RPICT on the same Raspberry===
If you are using this option then you should download the emonpi image from this link below.
 
https://github.com/openenergymonitor/emonpi/wiki/emonSD-pre-built-SD-card-Download-&-Change-Log
 
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]
[[Emoncms and RPICT on the same Raspberry]]
### 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]
<nowiki>[[SerialDirect]]</nowiki>
  Type = EmonHubSerialInterfacer
  [[[init_settings]]]
      com_port = /dev/ttyAMA0
      com_baud = 38400
    [[[runtimesettings]]]
      pubchannels = ToEmonCMS,
<nowiki>[[emoncmsorg]]</nowiki>
    Type = EmonHubEmoncmsHTTPInterfacer
    [[[init_settings]]]
    [[[runtimesettings]]]
        subchannels = ToEmonCMS,
        #url = http://localhost/emoncms #uncomment to save on local pi
        <span style="color: red">apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span>
        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]
<nowiki>[[11]]</nowiki>
  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.<br>
===Forward to a remote Emoncms server===
Modify the <nowiki>[[11]]</nowiki> entry as needed. Refer to the board specific page to modify the last part of the config where it starts with node ID.
There are 2 ways to do this. The first one is using our gateway tool called lcl-gateway. The second one involves installing Emonhub alone.
====lcl-gateway====


===Using Emonhub format - Raspbian image [Not Recommended]===
Get the lcl-gateway tool and install it this way.
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]]
wget https://github.com/lechacal/lcl-gateway.py/releases/download/v2.1.0/lcl-gateway_2.1.0_armhf.deb
sudo dpkg -i lcl-gateway_2.1.0_armhf.deb


===Using the gateway tool to forward the data [Not Recommended]===
Edit the lcl-gateway.conf file to reflect your own setting. Content is self explanatory.


We are proposing a basic script template which can be installed as below.
sudo nano /etc/lcl-gateway.conf


wget lechacal.com/RPICT/tools/lcl-gateway.py.zip
Insert the RPICT and run
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
  /usr/local/bin/lcl-gateway.py -d


Insert the RPICT and run
====Emonhub====
 
An alternative way is to install Emonhub on the raspberry. See this guide.
./lcl-gateway.py
[[Use Emonhub with RPICT]]


==Using Python basic script==
==Using Python basic script==
Line 437: Line 430:
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.
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
First of all make sure you have python3-serial package installed


  $ sudo apt-get install python-serial
  $ sudo apt-get install python3-serial


Then copy the following into an executable file and run it.
Then copy the following into an executable file and run it.


  #!/usr/bin/python
<syntaxhighlight lang="python">
  #!/usr/bin/python3
  import serial
  import serial
  ser = serial.Serial('/dev/ttyAMA0', 38400)
  ser = serial.Serial('/dev/ttyAMA0', 38400)
Line 449: Line 443:
  try:
  try:
         while 1:
         while 1:
                 response = ser.readline()
                 # Read one line from the serial buffer
                 z = response.split(" ")
                line = ser.readline().decode().strip()
                # Create an array of the data
                 z = line.split(" ")
                # Print it nicely
                 if len(z)>=3:
                 if len(z)>=3:
                         print "Power 1: %s Watts" % z[1]
                         print("Power 1: %s Watts" % z[1])
                         print "Power 2: %s Watts" % z[2]
                         print("Power 2: %s Watts" % z[2])
                         print "Power 3: %s Watts" % z[3]
                         print("Power 3: %s Watts" % z[3])
                         print "Temperature: %s Degrees" % z[4][:-2]
                         print("Temperature: %s Degrees" % z[4])
  except KeyboardInterrupt:
  except KeyboardInterrupt:
         ser.close()
         ser.close()
</syntaxhighlight>




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


==Full Output Firmware==


For the most advanced user who code things themselves and do not use any readily made platforms like emoncms or influxdb we have a special firmware that produces an output with the most complete information.


==Using SPIOT==
[[RPICT Full Output Firmware]]


This firmware brings in the additional features
* Relative timestamping to MCU boot time.
* One line per computation result. This means that data computed together are packed together and not mixed with other computation results.
* Data are sent along with the ports and level information that was used to compute them. This alleviate the need to know a user defined data field format.


[[File:Spiotrealtime_001.png | right | 300px]]
=Flashing the firmware / Upload Sketch=


Download and install [[SPIOT | SPIOT]] on a given server. This could be the raspberrypi itself.
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.


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).
The reasons one would flash a new firmware are:
* Update to a new version.
* Flash your own sketch.


Make sure all .py files are executable:
The onboard microcontroller can be re-programmed using the Arduino IDE software and an AVR programmer. We recommend our [[NanoProg_v1 | NanoProg]] programmer for this.


  $ chmod 755 *.py
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.


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.
[http://lechacal.com/wiki/index.php/How_to_program_an_Attiny85_or_Attiny84 This link] is a tutorial to upload Arduino sketches to the Attiny84. .


[csv_forward]
===RPICT8, RPICT7V1, RPICT4V3, RPIZ_CT4V3T2===
port = /dev/ttyAMA0
These boards use atmega328p mcu.
hostname = myserver/spiot
apikey = qbG31dQxFlG55mNM8G5ZTFkF0mrUbWg5
node = 20
baud = 38400


Then run the spiot_csv.py utility.
[[Upload Arduino sketch to Atmega328]].
 
$./spiot_csv.py


Then point your webbrowser to the link below:
=Developing Arduino Sketch=
http://myserver/spiot/realtime.html?apikey=qbG31dQxFlG55mNM8G5ZTFkF0mrUbWg5&node=20&fields=f001


The last 5 minutes of the first channel will be shown on a graph.
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.


=Flashing the firmware / Upload Sketch=
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 onboard microcontroller can be re-programmed using the Arduino IDE software and an AVR programmer.
The link below is an introduction to this library with plain simple examples.
 
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.
==RPICT4T4, RPICT3V1, RPICT3T1, RPICT4V3 version1==
[http://lechacal.com/wiki/index.php/How_to_program_an_Attiny85_or_Attiny84 This link] is a tutorial to upload Arduino sketches to the Attiny84. .


==RPICT8, RPICT7V1, RPICT4V3==
[[RPICTlib]]
[[Upload Arduino sketch to Atmega328]].


=Enclosures=
=Enclosures=
Line 515: Line 512:
See the shop item for<br>
See the shop item for<br>
[http://lechacalshop.com/gb/internetofthing/48-enclosure-kit-for-rpict3t1.html RPICT3T1 Enclosure]<br>
[http://lechacalshop.com/gb/internetofthing/48-enclosure-kit-for-rpict3t1.html RPICT3T1 Enclosure]<br>
[http://lechacalshop.com/gb/internetofthing/43-enclosure-kit-for-rpict7v1.html RPICT3V1 Enclosure (uses the same as RPICT7V1)]<br>
[http://lechacalshop.com/gb/internetofthing/44-enclosure-kit-for-rpict8.html RPICT8 Enclosure]<br>
[http://lechacalshop.com/gb/internetofthing/44-enclosure-kit-for-rpict8.html RPICT8 Enclosure]<br>
[http://lechacalshop.com/gb/internetofthing/43-enclosure-kit-for-rpict7v1.html RPICT7V1 Enclosure]<br>
[http://lechacalshop.com/gb/internetofthing/43-enclosure-kit-for-rpict7v1.html RPICT7V1 Enclosure]<br>
[http://lechacalshop.com/gb/internetofthing/41-enclosure-kit-for-rpict4v3.html RPICT4V3 Enclosure]<br>
[http://lechacalshop.com/gb/internetofthing/41-enclosure-kit-for-rpict4v3.html RPICT4V3 Enclosure]<br>


=Related Howto=
=Related Articles and Howto=


[[Frequently Asked]]
[[Frequently Asked]]


[[Howto setup Raspbian for serial read]]
[[Howto setup Raspbian for serial read]]
[[First time troubleshoot for RPICT]]
[[Upload Arduino sketch from Raspberrypi to RPICT]]


[[Example Using InfluxDB]]
[[Example Using InfluxDB]]
[[How to calibrate the Voltage Port]]


[[Calibration VCAL ICAL PHASECAL]]
[[Calibration VCAL ICAL PHASECAL]]
Line 537: Line 537:
[[How to program an Attiny85 or Attiny84]]
[[How to program an Attiny85 or Attiny84]]


[[RPICT Online Config Generator]]
[[RPICT Online Config Generator | RPICT Online Config Generator (old)]]
 
[[RPICT_configuration_web_tool | RPICT Configuration Web Tool (new)]]
 
[[RPICT Fundamentals]]
 
[[Remote terminal access with tmate]]
 
[[Upgrading to sketch version 4]]
 
[[Burn bootloader on RPICT Atmega with Arduino UNO]]


=Playground=
=Playground=


[[Transform a RPICT into a web scope]]
[[Transform a RPICT into a web scope]]
[[Noise level test RPICT V2&3]]


[[RPICT and Node-Red hosted on Raspberrypi]]
[[RPICT and Node-Red hosted on Raspberrypi]]
Line 549: Line 557:
[[RPICT and MQTT]]
[[RPICT and MQTT]]


=External Resources=
[[Compute Energy used using a RPICT]]
 
[[Timestamping with RPICT]]
 
=Third Party Developments=
 
All of the links below are not managed by LeChacal. We think they might be of interest if you need inspiration.<br>
Contact us if you want your project to be added to the list below.


[https://www.thingiverse.com/thing:3586158 An enclosure alternative for RPICT7V1]
[https://www.thingiverse.com/thing:3586158 An enclosure alternative for RPICT7V1]
[https://github.com/km6wye/myPower 'myPower' Power monitoring and logging developed by KM6WYE]
[https://github.com/ned-kelly/docker-lechacal-homeassistant Homeassistant module]
[https://gist.github.com/mitchellrj/86722a2120d66abefd7d6eecc390b4fc An exporter for Prometheus on Github]
[https://github.com/cdtx/rpict3t1_mqtt for RPICT3T1 to MQTT]
[https://gtricot.github.io/rpict-mqtt/#/introduction/ rpict-mqtt / A package delivering MQTT support for RPICT]
[https://www.mdpi.com/2079-9292/11/22/3788 A Low-Cost and Do-It-Yourself Device for Pumping Monitoring in Deep Aquifers]

Latest revision as of 13:40, 6 December 2023

"AC monitoring"
"Raspberrypi Smart Meter"


RPICT Series

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.

Applications

  • Raspberrypi Smart Meter.
  • Internet of Things.
  • Data Logging.
  • Real Time Monitoring.
  • Home Automation.

Raspberrypi

Raspberrypi Stackable Boards
V 2 & 3

V 4

V 5

Temperature Only

Raspberrypi for 5A output CT

Raspberrypi Zero

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

with relays

Model #CT #Volt* #Temp Stackable
RPICT3T1 3 - 1 No
RPICT3V1 3 1 - No
RPICT4T4 4 - 4 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


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.

Raspberrypi Configuration

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

Howto setup Raspbian for serial read

Next steps

  • The board is sold ready to go with firmware and configuration already loaded.
  • Make sure to test all sensors with the cat or lcl-run command before changing the configuration.
  • Carefully read the FAQ below

FAQ - Frequently Asked Questions

First configuration

First Configuration RPICT

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
  • SCT-024 400A/100mA
  • SCT-031 600A/100mA

Connector: 3.5mm Jack

Measured range

The range is determined by the burden resistor fitted on the RPICT unit. At purchase time this is selected using the parameter rating in the shop.

The default range is 100A on all RPICT series which correspond to a burden resistor of 24 or 27 Ohm. Other ratings (or ranges) can be selected at purchase time.

More details about the input range and the burden resistor is given in the links below.

  • For RPICT3T1 RPICT3V1 RPICT4T4v2.5 and also RPICT8/RPICT7V1/RPICT4V3 in version 3

Gen3 Passive Component Setup

  • For RPICT7V1 RPICT8 and RPICT4V3 in version 4

Gen4 Passive Component Setup

  • For RPICT7V1 RPICT8 RPICT4V3 in version 5

Gen5 Passive Component Setup

Notes

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.

Voltage Sensor

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

Low Voltage < 250V

The three models available depending on mains power type:

These units can be easily plug in a main wall socket. No wiring is required.

Three units are needed to monitor 3 phase.

High Voltage up to 1500V

TV30GB

The TV30GB can read Voltages up to 1500V. Wiring required.

Three units are needed to monitor 3 phase.

ZMPT101B Module

The ZMPT101B module is a voltage module to be wired. It measures voltages up to 250V and can be mounted on DIN rails.

For single phase: ZMPT101B_Module_1x_v2

For three phase: ZMPT101B_Module_3x_v4

Do not use these ZMPT module sold on the market. They do not scale against the RPICT units and the presence of a potentiometer make them unreliable.

Temperature Sensor

The temperature sensor is the DS18B20.

Temperature sensors come with various connectors.

3 pin Molex

This applies for board RPIZCT4V3T1 and RPIZCT4V3T2.

Bare wires

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.

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

See another alternative here. Using plink

To record the data in a text file see Recording RPICT Serial stream on local file

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.

Forward to Influxdb from RPICT

See also
Install an InfluxDB Grafana stack on a Raspberrypi

Using Home Assistant - home-assistant.io

Follow this guide below for Homeassistant.

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.

Using Node-Red

See the link below for an example using Node-Red.

RPICT_and_Node-Red_hosted_on_Raspberrypi

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.

http://raspberrypi/cgi-bin/emonwrt3-json?last=1

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.

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.

Emoncms and RPICT on the same Raspberry

Emoncms and RPICT on the same Raspberry

Forward to a remote Emoncms server

There are 2 ways to do this. The first one is using our gateway tool called lcl-gateway. The second one involves installing Emonhub alone.

lcl-gateway

Get the lcl-gateway tool and install it this way.

wget https://github.com/lechacal/lcl-gateway.py/releases/download/v2.1.0/lcl-gateway_2.1.0_armhf.deb
sudo dpkg -i lcl-gateway_2.1.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

/usr/local/bin/lcl-gateway.py -d

Emonhub

An alternative way is to install Emonhub on the raspberry. See this guide. Use Emonhub with RPICT

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 python3-serial package installed

$ sudo apt-get install python3-serial

Then copy the following into an executable file and run it.

 #!/usr/bin/python3
 import serial
 ser = serial.Serial('/dev/ttyAMA0', 38400)
 
 try:
        while 1:
                # Read one line from the serial buffer
                line = ser.readline().decode().strip()
                # Create an array of the data
                z = line.split(" ")
 
                # Print it nicely
                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])
 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.

Full Output Firmware

For the most advanced user who code things themselves and do not use any readily made platforms like emoncms or influxdb we have a special firmware that produces an output with the most complete information.

RPICT Full Output Firmware

This firmware brings in the additional features

  • Relative timestamping to MCU boot time.
  • One line per computation result. This means that data computed together are packed together and not mixed with other computation results.
  • Data are sent along with the ports and level information that was used to compute them. This alleviate the need to know a user defined data field format.

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.

Upload Arduino sketch to Atmega328.

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.

RPICTlib

Enclosures

Some RPICT have enclosures available as 3D printed product.

See the shop item for
RPICT3T1 Enclosure
RPICT3V1 Enclosure (uses the same as RPICT7V1)
RPICT8 Enclosure
RPICT7V1 Enclosure
RPICT4V3 Enclosure

Related Articles and Howto

Frequently Asked

Howto setup Raspbian for serial read

First time troubleshoot for RPICT

Upload Arduino sketch from Raspberrypi to RPICT

Example Using InfluxDB

Calibration VCAL ICAL PHASECAL

Use Emonhub with RPICT

Burden Resistor calculation

How to program an Attiny85 or Attiny84

RPICT Online Config Generator (old)

RPICT Configuration Web Tool (new)

RPICT Fundamentals

Remote terminal access with tmate

Upgrading to sketch version 4

Burn bootloader on RPICT Atmega with Arduino UNO

Playground

Transform a RPICT into a web scope

RPICT and Node-Red hosted on Raspberrypi

RPICT and MQTT

Compute Energy used using a RPICT

Timestamping with RPICT

Third Party Developments

All of the links below are not managed by LeChacal. We think they might be of interest if you need inspiration.
Contact us if you want your project to be added to the list below.

An enclosure alternative for RPICT7V1

'myPower' Power monitoring and logging developed by KM6WYE

Homeassistant module

An exporter for Prometheus on Github

for RPICT3T1 to MQTT

rpict-mqtt / A package delivering MQTT support for RPICT

A Low-Cost and Do-It-Yourself Device for Pumping Monitoring in Deep Aquifers