Raspberrypi Current and Temperature Sensor Adaptor: Difference between revisions
Line 37: | Line 37: | ||
For this you should use the Linux distribution recommended by EOM for the Raspberry emonbase. | For this you should use the Linux distribution recommended by EOM for the Raspberry emonbase. | ||
[http://lechacal.com/DIRECT_CT2_TEMP/ | [http://lechacal.com/DIRECT_CT2_TEMP/rpi_CT_temp_v1_2.ino This sketch] will allow you to run the board for the use of Emoncms. | ||
==Record the data from Linux terminal== | ==Record the data from Linux terminal== |
Revision as of 17:51, 6 August 2014
A current sensor and temperature adaptor for your Raspberrypi. It connects to the GPIO connector and provide data via serial interface. An Atiny85 mcu run the board and can be re-programmed easily with your Arduino IDE.
There are several options for logging and viewing the data. Python or Emoncms or anything able to read a serial port.
There are currently three model of the board.
- One single CT
- One CT and one temperature sensor
- Two CT and one temparature sensor.

Technical Specifications
Current Sensor
Recommended sensor: SCT-013-000 50mA/100A
Burden Resistor: 18Ohm
Connector: 3.5mm Jack
Temperature Sensor
Connector: 3.5mm Jack
The intented temperature sensor is the DS18B20 which can be configure in either parasite or normal mode.
The connection to a 3.5mm jack connector is shown below.
Log the data with EMONCMS
To record and view data on Emoncms the Adaptor must emulate a RFM12Bpi unit. i.e. What will be sent to the Raspberrypi serial port will look as if it was sent by the RFM12Bpi.
For this you should use the Linux distribution recommended by EOM for the Raspberry emonbase.
This sketch will allow you to run the board for the use of Emoncms.
Record the data from Linux terminal
First of all a sketch that return the data in csv format can be found here.
The output from the adaptor board will be like
current_power,temperature*1000
Then on the Raspberrypi you can issue the commands
$ stty -F /dev/ttyAMA0 raw speed 9600 $ cat /dev/ttyAMA0
The terminal should then show something like this below
pi@raspberrypi ~ $ cat /dev/ttyAMA0 46,19464 47,19464 45,19464 47,19464
First figure being the power in Watts and second being the temperature*1000.
Log the data with Python
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', 9600, timeout=1) ser.open() try: while 1: response = ser.readline() z = response.split(",") if len(z)>=2: print "Power: %s Watts" % z[0] print "Temperature: %s Degrees" % z[1][:-2] except KeyboardInterrupt: ser.close()
See here for the python example using the board with two CT sensors.
Program the Attiny85
The onboard mcu can be re-programmed to your needs. This link is a good tutorial to load Arduino sketches into the Attiny85.
The board does not have any SPi port. The chip will have to be removed from the board manually.