Difference between revisions of "EmonPi"

From OpenEnergyMonitor Wiki
Jump to: navigation, search
(Setting Up Wifi)
(Sketch / Firmware Upload from Raspberry Pi)
Line 116: Line 116:
$ sudo apt-get install arduino
$ sudo apt-get install avrdude
$ git clone https://github.com/openenergymonitor/avrdude-rpi
$ git clone https://github.com/openenergymonitor/avrdude-rpi
$ cd avrdude-rpi
$ git clone https://github.com/openenergymonitor/avrdude-rpi.git ~/avrdude-rpi && ~/avrdude-rpi/install
$ sudo cp autoreset /usr/bin
$ sudo cp avrdude-autoreset /usr/bin
$ sudo mv /usr/bin/avrdude /usr/bin/avrdude-original
$ sudo ln -s /usr/bin/avrdude-autoreset /usr/bin/avrdude
$ avrdude -v  -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:sketch_name.hex
$ avrdude -v  -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:sketch_name.hex

Revision as of 12:58, 2 February 2015

Raspberry Pi Energy Monitoring Shield - Dev Notes

Open Development

OpenEnergyMonitor.org forum thread

[G+ Development Photos Album

Build Notes

Change Host Name

$ sudo nano /etc/hosts

$ sudo nano /etc/hostname

Disable Pi Serial Console

Simple script to easily enable & disable the Raspberry Pi's serial 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).


$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

$ sudo reboot

$ rpi-serial-console status

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:

$ sudo nano /etc/network/interfaces

Change interfaces file to the following entering your SSID and password.

auto lo

iface lo inet loopback

iface eth0 inet dhcp

auto wlan0

allow-hotplug wlan0

iface wlan0 inet dhcp

wpa-ssid "YOUR_SSID"


[CTRL] + [X] to save and exit nano

either reboot the Pi or just reboot the adapter

$ sudo ifdown wlan0; sudo ifup wlan0

Script to check for working wifi connection and restart wifi if needed https://github.com/dweeber/WiFi_Check

Some users have reported the disabling power saving on the Edimax module improves reliability:


$ sudo nano /etc/modprobe.d/8192cu.conf

and add this line:

options 8192cu rtw_power_mgnt=0 <code>

save and reboot.

For terminal GUI and auto scanning of available Wifi networks wicd can be used:

sudo apt-get install wicd-curses sudo wicd-curses

</code> http://www.raspyfi.com/wi-fi-on-raspberry-pi-a-simple-guide/

Sketch / Firmware Upload from Raspberry Pi

To Upload pre-compiled .hex file using AVRdude

Assuming starting with latest version of Raspien Wheezy (tested with 2014-01-07)

$ sudo apt-get install avrdude

$ git clone https://github.com/openenergymonitor/avrdude-rpi

$ git clone https://github.com/openenergymonitor/avrdude-rpi.git ~/avrdude-rpi && ~/avrdude-rpi/install

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

Compile Arduino sketches on the Raspberry Pi





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:

Edit the modules file

$ sudo nano /etc/modules

Add these lines:



Edit the modules blacklist file:

$ sudo nano /etc/modprobe.d/raspi-blacklist.conf

Add a '#' character to this line so it commented out:

#blacklist i2c-bcm2708

Finally install the I2C utilities:

$ sudo apt-get install python-smbus i2c-tools

reboot pi

Detect LCD on I2C bus

Returns I2C address of LCD

$ sudo i2cdetect -y 1

Use port 1 for 512Mb RAM pi (rev2) or port 0 for older 256Mb RAM pi (rev1)

LCD Python Examples


Built upon: https://github.com/mmmarq/raspberry_lcd

Run emonPi Python as startup


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