Difference between revisions of "EmonPi"

From OpenEnergyMonitor Wiki
Jump to: navigation, search
Line 1: Line 1:
 
Raspberry Pi Energy Monitoring Shield  
 
Raspberry Pi Energy Monitoring Shield  
  
''Technical Wiki Documentation - IN DEVELOPMENT!''
+
''Hardware Technical Wiki Documentation - IN DEVELOPMENT!''
  
==Features==
+
==Technical Features==
==Port Map==
+
==Power Supply==
+
==SD Card Image==
+
===Download===
+
===Build===
+
==Uploading Arduino Firmware==
+
==Connectivity==
+
===RFM69CW===
+
===OOK===
+
===RJ45 Socket===
+
====DS18B20 Temperature====
+
====Pulse Counting====
+
====Aux I/O====
+
==Electrical Characteristics==
+
==Open-Hardware Design Files==
+
==Open Development==
+
  
The emonPi has been developed with input from the OpenEnergyMonitor community. See origional development [http://openenergymonitor.org/emon/node/3937 OpenEnergyMonitor.org forum thread].
+
* 2 x CT Current Sensor Inputs - designed for 100A max YHDC clip-on SCT-013-000
  
[https://plus.google.com/b/114424977493521882459/photos/+OpenenergymonitorOrgpage/albums/5999656723837107313 [emonPi Development Photos Album]
+
* 1 x AC Voltage Input - designed for 9V AC power adapter
  
==Physical Dimensions==
+
* Arduino compatible ATmega328P - setup for sketch upload direct from the Pi via GPIO serial
==License==
+
  
The emonPi is part of the OpenEnergyMonitor.org project
+
* RJ45 connector for connecting DS18B20 temperature sensors, IRQ pulse counting sensor, and access to power and spare I/O including analog and PWM
  
The hardware designs (schematics and CAD files) are licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
+
* RFM12B 433Mhz RF Radio
  
The firmware is released under the GNU GPL V3 license
+
* I2C LCD (16 x 2) with control push button
  
The documentation is subject to GNU Free Documentation License
+
* Raspberry Pi Shutdown Button
  
The hardware designs follow the terms of the OSHW (Open-source hardware) Statement of Principles 1.0
 
  
==Media==
+
==Overview Diagram==
==Environmental & Life Cycle==
+
==Disclaimer==
+
  
OUR PRODUCTS AND ASSEMBLY KITS MAY BE USED BY EXPERIENCED, SKILLED USERS, AT THEIR OWN RISK. TO THE FULLEST EXTENT PERMISSIBLE BY THE APPLICABLE LAW, WE HEREBY DISCLAIM ANY AND ALL RESPONSIBILITY, RISK, LIABILITY AND DAMAGES ARISING OUT OF DEATH OR PERSONAL INJURY RESULTING FROM ASSEMBLY OR OPERATION OF OUR PRODUCTS.
+
[[File:emonPi_V1.4_Diagram.jpg|650 px]]
  
The OpenEnergyMonitor system is sold as a development kit to empower members of the openenergymonitor community to to get involved with the OpenEnergyMonitor open-source energy monitoring development project.
+
==Port Map==
  
Your safety is your own responsibility, including proper use of equipment and safety gear, and determining whether you have adequate skill and experience. OpenEnergyMonitor and Megni registered partnership disclaims all responsibility for any resulting damage, injury, or expense. It is your responsibility to make sure that your activities comply with applicable laws, including copyright. Always check the webpage associated with each unit before you get started. There may be important updates or corrections. All use of the instructions, kits, projects and suggestions given both by megni.co.uk, openenergymonitor.org, shop.openenergymonitor.org and wiki.openenergymonitor.org are to be used at your own risk. The technology (hardware , firmware and software) are constantly changing, documentation (including build guide and instructions) may not be complete or correct.
 
  
If you feel uncomfortable with assembling or using any part of the kit / unit, please return it to us, we will happy to give a full refund.
 
  
 +
==Raspberry Pi Compatibility==
  
 +
The emonPi has been designed to with the Raspberry Pi Model B+ and Pi2.
  
=Build Notes=
+
The emonPi will also work on the Model-B, although due to physical differences it won't fit inside the emonPi aluminium case. The use the emonPi on the Model B a 13-pin GPIO extender is needed instead of the 20-pin extender included; please leave a note at checkout when ordering.
  
==Change Host Name==
 
<code>
 
  
$ sudo nano /etc/hosts
+
==Power Supply==
  
$ sudo nano /etc/hostname
+
The emonPi is powered by 5V DC via a mini-B-USB socket. The Raspberry Pi is powered by the emonPi via the GPIO pins. The emonPi board itself runs at 3.3V provided by on on-board voltage regulator. The Raspberry Pi's 3.3V rail is left un-touched by the emonPi.
  
</code>
+
''We recommend at least a 1.2A 5V USB power supply''
  
==Disable Pi Serial Console==
+
==SD Card Image==
  
Simple script to easily enable &amp; disable the Raspberry Pi's serial
+
Based on Raspbien
console. Disabling the serial console is required if you want to use
+
the Raspberry Pi's serial port (UART) to talk to other devices e.g.
+
ATmega328 microcontroller on emonPi (see <http://elinux.org/RPi_Serial_Connection> for more
+
information).
+
  
[https://github.com/lurch/rpi-serial-console https://github.com/lurch/rpi-serial-console]
+
===Download===
  
<code>
+
===Build===
$sudo wget https://raw.github.com/lurch/rpi-serial-console/master/rpi-serial-console -O /usr/bin/rpi-serial-console && sudo chmod +x /usr/bin/rpi-serial-console
+
  
$ sudo rpi-serial-console disable
+
Run emonPi install script. See script for details
 
+
$ sudo reboot
+
 
+
$ rpi-serial-console status
+
 
+
</code>
+
You should see the message ''Serial console on /dev/ttyAMA0 is disabled'', the serial port is now free for communication with the ATMega328 on the emonPi
+
 
+
 
+
==Setting Up Wifi==
+
Using Edimax EW-7811
+
 
+
We need to edit the file /etc/network/interfaces on the root file system partition of the Pi's SD card.
+
 
+
Either connect Pi via Ethernet and access via SSH or connect a keyboard mouse and screen to the Pi or edit the file on your computer. Assuming your connect to the Pi via SSH:
+
 
+
<code>$ sudo nano /etc/network/interfaces</code>
+
 
+
Change interfaces file to the following entering your SSID and password.  
+
  
 
<code>
 
<code>
auto lo
+
$ git clone https://github.com/openenergymonitor/emonpi.git
 
+
$ cd emonpi
iface lo inet loopback
+
$ sudo ./install
 
+
iface eth0 inet dhcp
+
 
+
 
+
auto wlan0
+
 
+
allow-hotplug wlan0
+
 
+
iface wlan0 inet dhcp
+
 
+
wpa-ssid "YOUR_SSID"
+
 
+
wpa-psk "WIFI_PASSWORD"
+
 
</code>
 
</code>
  
 +
==Uploading Arduino Firmware==
  
[CTRL] + [X] to save and exit nano
+
.hex file can be uploaded:
 
+
either reboot the Pi or just reboot the adapter
+
  
 
<code>
 
<code>
$ sudo ifdown wlan0; sudo ifup wlan0
+
$ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:sketch_name.hex
</code>
+
 
+
Script to check for working wifi connection and restart wifi if needed [https://github.com/dweeber/WiFi_Check https://github.com/dweeber/WiFi_Check]
+
 
+
 
+
Some users have reported the disabling power saving on the Edimax module improves reliability:
+
 
+
http://openenergymonitor.org/emon/node/2941
+
 
+
 
<code>
 
<code>
$ sudo nano /etc/modprobe.d/8192cu.conf
 
</code>
 
  
and add this line:
+
For further info see [https://github.com/openenergymonitor/avrdude-rpi avrdude-rpi readme]
  
<code>
+
==Connectivity==
options 8192cu rtw_power_mgnt=0
+
===RFM69CW===
<code>
+
===OOK===
 +
===RJ45 Socket===
 +
====DS18B20 Temperature====
 +
====Pulse Counting====
 +
====Aux I/O====
 +
==Electrical Characteristics==
 +
==Open-Hardware Design Files==
  
save and reboot.
+
See [https://github.com/openenergymonitor/Hardware/tree/master/emonpi emonPi hardware GitHub repo]
  
 +
==Open Development==
  
For terminal GUI and auto scanning of available Wifi networks wicd can be used:
+
The emonPi has been developed with input from the OpenEnergyMonitor community. See origional development [http://openenergymonitor.org/emon/node/3937 OpenEnergyMonitor.org forum thread].
  
sudo apt-get install wicd-curses
+
[https://plus.google.com/b/114424977493521882459/photos/+OpenenergymonitorOrgpage/albums/5999656723837107313 [emonPi Development Photos Album]
sudo wicd-curses
+
</code>
+
  
</code>
+
==Physical Dimensions==
[http://www.raspyfi.com/wi-fi-on-raspberry-pi-a-simple-guide/ http://www.raspyfi.com/wi-fi-on-raspberry-pi-a-simple-guide/]
+
  
==Loading Bootloader==
+
PCB: 99.2mm  x 76.1mm
 +
Enclosure: 99mm x 85mm x 50mm
  
ATmega328 on the emonPi uses standard Arduino uno Optiboot bootloader:
+
==License==
  
 +
The emonPi is part of the OpenEnergyMonitor.org project
  
</code>sudo avrdude -v -p atmega328p -c avrispmkII -P usb  -U efuse:w:0x05:m -U hfuse:w:0xDE:m - Ulfuse:w:0xFF:m -U flash:w:optiboot_atmega328.hex </code>
+
The hardware designs (schematics and CAD files) are licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
  
==Sketch / Firmware Upload from Raspberry Pi==
+
The firmware is released under the GNU GPL V3 license
'''To Upload pre-compiled .hex file using AVRdude'''
+
  
 +
The documentation is subject to GNU Free Documentation License
  
<code>
+
The hardware designs follow the terms of the OSHW (Open-source hardware) Statement of Principles 1.0
  
$ sudo apt-get update
+
==Media==
  
$ git clone https://github.com/openenergymonitor/avrdude-rpi.git ~/avrdude-rpi && ~/avrdude-rpi/install
+
[https://plus.google.com/b/114424977493521882459/photos/114424977493521882459/albums/6118683943716950081 emonPi Stock Photos]
 +
[ https://plus.google.com/b/114424977493521882459/photos/114424977493521882459/albums/5999656723837107313 Development Photos]
  
$ avrdude -v  -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:sketch_name.hex
+
==Environmental & Life Cycle==
</code>
+
==Disclaimer==
  
 +
OUR PRODUCTS AND ASSEMBLY KITS MAY BE USED BY EXPERIENCED, SKILLED USERS, AT THEIR OWN RISK. TO THE FULLEST EXTENT PERMISSIBLE BY THE APPLICABLE LAW, WE HEREBY DISCLAIM ANY AND ALL RESPONSIBILITY, RISK, LIABILITY AND DAMAGES ARISING OUT OF DEATH OR PERSONAL INJURY RESULTING FROM ASSEMBLY OR OPERATION OF OUR PRODUCTS.
  
===Compile Arduino sketches on the Raspberry Pi===
+
The OpenEnergyMonitor system is sold as a development kit to empower members of the openenergymonitor community to to get involved with the OpenEnergyMonitor open-source energy monitoring development project.
  
http://www.deanmao.com/2012/08/06/arduino-and-the-raspberry-pi/
+
Your safety is your own responsibility, including proper use of equipment and safety gear, and determining whether you have adequate skill and experience. OpenEnergyMonitor and Megni registered partnership disclaims all responsibility for any resulting damage, injury, or expense. It is your responsibility to make sure that your activities comply with applicable laws, including copyright. Always check the webpage associated with each unit before you get started. There may be important updates or corrections. All use of the instructions, kits, projects and suggestions given both by megni.co.uk, openenergymonitor.org, shop.openenergymonitor.org and wiki.openenergymonitor.org are to be used at your own risk. The technology (hardware , firmware and software) are constantly changing, documentation (including build guide and instructions) may not be complete or correct.
  
or
+
If you feel uncomfortable with assembling or using any part of the kit / unit, please return it to us, we will happy to give a full refund.
 
+
http://openenergymonitor.blogspot.co.uk/2013/12/developing-for-arduino-remotely-on.html
+
 
+
==LCD==
+
 
+
HD44780 LCD with PCF8574 I2c
+
I2C Address: 0x27
+
 
+
===Enabling The I2C Port===
+
The I2C ports need to be enabled in Raspbian before they can be used:
+
 
+
====On Raspberry Pi 2====
+
 
+
Uses Device Tree: http://www.raspberrypi.org/forums/viewtopic.php?p=675658#p675658
+
 
+
http://www.raspberrypi.org/documentation/configuration/device-tree.md
+
 
+
Add to /boot/config.txt
+
 
+
dtparam=i2c_arm=on
+
 
+
===On Raspberry Pi Model B and B+====
+
 
+
'''Edit the modules file'''
+
 
+
<code> $ sudo nano /etc/modules</code>
+
 
+
Add these lines:
+
 
+
<code>
+
i2c-bcm2708
+
 
+
i2c-dev
+
</code>
+
 
+
 
+
'''Edit the modules blacklist file:'''
+
 
+
<code> $ sudo nano /etc/modprobe.d/raspi-blacklist.conf </code>
+
 
+
Add a '#' character to this line so it commented out:
+
 
+
<code> #blacklist i2c-bcm2708 </code>
+
 
+
 
+
+
'''Finally install the I2C utilities:'''
+
 
+
<code> $ sudo apt-get install python-smbus i2c-tools </code>
+
 
+
reboot pi
+
 
+
===Detect LCD on I2C bus===
+
 
+
Returns I2C address of LCD
+
 
+
<code> $ sudo i2cdetect -y 1 </code>
+
 
+
Use port 1 for 512Mb RAM pi (rev2) or port 0 for older 256Mb RAM pi (rev1)
+
 
+
===LCD Python Examples===
+
[https://github.com/openenergymonitor/emonpi/tree/master/LCD https://github.com/openenergymonitor/emonpi/tree/master/LCD]
+
 
+
Built upon: [https://github.com/mmmarq/raspberry_lcd https://github.com/mmmarq/raspberry_lcd]
+
 
+
==Run emonPi Python as startup==
+
 
+
[http://blog.scphillips.com/2013/07/getting-a-python-script-to-run-in-the-background-as-a-service-on-boot/ http://blog.scphillips.com/2013/07/getting-a-python-script-to-run-in-the-background-as-a-service-on-boot/]
+
 
+
<code>
+
sudo cp shutdownpi.sh /etc/init.d
+
 
+
sudo cp emonpiLCD /etc/init.d
+
 
+
sudo update-rc.d emonpiLCD defaults
+
 
+
sudo update-rc.d shutdownpi.sh defaults
+
 
+
sudo service shutdownpi.sh start / stop / status
+
 
+
sudo service emonpiLCD start / stop / status
+
</code>
+

Revision as of 13:54, 4 March 2015

Raspberry Pi Energy Monitoring Shield

Hardware Technical Wiki Documentation - IN DEVELOPMENT!

Technical Features

  • 2 x CT Current Sensor Inputs - designed for 100A max YHDC clip-on SCT-013-000
  • 1 x AC Voltage Input - designed for 9V AC power adapter
  • Arduino compatible ATmega328P - setup for sketch upload direct from the Pi via GPIO serial
  • RJ45 connector for connecting DS18B20 temperature sensors, IRQ pulse counting sensor, and access to power and spare I/O including analog and PWM
  • RFM12B 433Mhz RF Radio
  • I2C LCD (16 x 2) with control push button
  • Raspberry Pi Shutdown Button


Overview Diagram

EmonPi V1.4 Diagram.jpg

Port Map

Raspberry Pi Compatibility

The emonPi has been designed to with the Raspberry Pi Model B+ and Pi2.

The emonPi will also work on the Model-B, although due to physical differences it won't fit inside the emonPi aluminium case. The use the emonPi on the Model B a 13-pin GPIO extender is needed instead of the 20-pin extender included; please leave a note at checkout when ordering.


Power Supply

The emonPi is powered by 5V DC via a mini-B-USB socket. The Raspberry Pi is powered by the emonPi via the GPIO pins. The emonPi board itself runs at 3.3V provided by on on-board voltage regulator. The Raspberry Pi's 3.3V rail is left un-touched by the emonPi.

We recommend at least a 1.2A 5V USB power supply

SD Card Image

Based on Raspbien

Download

Build

Run emonPi install script. See script for details

$ git clone https://github.com/openenergymonitor/emonpi.git $ cd emonpi $ sudo ./install

Uploading Arduino Firmware

.hex file can be uploaded:

$ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:sketch_name.hex <code>

For further info see avrdude-rpi readme

Connectivity

RFM69CW

OOK

RJ45 Socket

DS18B20 Temperature

Pulse Counting

Aux I/O

Electrical Characteristics

Open-Hardware Design Files

See emonPi hardware GitHub repo

Open Development

The emonPi has been developed with input from the OpenEnergyMonitor community. See origional development OpenEnergyMonitor.org forum thread.

[emonPi Development Photos Album

Physical Dimensions

PCB: 99.2mm x 76.1mm Enclosure: 99mm x 85mm x 50mm

License

The emonPi is part of the OpenEnergyMonitor.org project

The hardware designs (schematics and CAD files) are licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

The firmware is released under the GNU GPL V3 license

The documentation is subject to GNU Free Documentation License

The hardware designs follow the terms of the OSHW (Open-source hardware) Statement of Principles 1.0

Media

emonPi Stock Photos [ https://plus.google.com/b/114424977493521882459/photos/114424977493521882459/albums/5999656723837107313 Development Photos]

Environmental & Life Cycle

Disclaimer

OUR PRODUCTS AND ASSEMBLY KITS MAY BE USED BY EXPERIENCED, SKILLED USERS, AT THEIR OWN RISK. TO THE FULLEST EXTENT PERMISSIBLE BY THE APPLICABLE LAW, WE HEREBY DISCLAIM ANY AND ALL RESPONSIBILITY, RISK, LIABILITY AND DAMAGES ARISING OUT OF DEATH OR PERSONAL INJURY RESULTING FROM ASSEMBLY OR OPERATION OF OUR PRODUCTS.

The OpenEnergyMonitor system is sold as a development kit to empower members of the openenergymonitor community to to get involved with the OpenEnergyMonitor open-source energy monitoring development project.

Your safety is your own responsibility, including proper use of equipment and safety gear, and determining whether you have adequate skill and experience. OpenEnergyMonitor and Megni registered partnership disclaims all responsibility for any resulting damage, injury, or expense. It is your responsibility to make sure that your activities comply with applicable laws, including copyright. Always check the webpage associated with each unit before you get started. There may be important updates or corrections. All use of the instructions, kits, projects and suggestions given both by megni.co.uk, openenergymonitor.org, shop.openenergymonitor.org and wiki.openenergymonitor.org are to be used at your own risk. The technology (hardware , firmware and software) are constantly changing, documentation (including build guide and instructions) may not be complete or correct.

If you feel uncomfortable with assembling or using any part of the kit / unit, please return it to us, we will happy to give a full refund.