Sunday, September 27, 2015

Energy Monitor based on OpenEnergyMonitor

As every one hooking up energy monitor for their , I also in the urge to setup a energy monitor.
Yesterday I done a trial run with following components.

1. Current sensor (30A) available for ebay

2. Stalker V3 - from seeedstudio ( got it down for 10USD in the promotion period)




3. in programming , I used emon library http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor  to calculate Irms. Then use SD card to log the Wattage around every 300mS



Following is the data obtained through SD card log.

8:27:57 - 27-9-2015 0.61A 142.54W 3.89V- Bat 
18:27:57 - 27-9-2015 0.60A 141.45W 3.93V- Bat 
18:27:57 - 27-9-2015 0.61A 142.17W 3.93V- Bat 
18:27:58 - 27-9-2015 0.61A 141.63W 3.89V- Bat 
18:27:58 - 27-9-2015 0.61A 142.75W 3.93V- Bat 
18:27:59 - 27-9-2015 0.61A 143.34W 3.91V- Bat 
18:27:59 - 27-9-2015 0.61A 141.86W 3.89V- Bat 
18:27:59 - 27-9-2015 0.61A 143.68W 3.94V- Bat 
18:28:00 - 27-9-2015 0.60A 141.33W 3.91V- Bat 
18:28:00 - 27-9-2015 0.61A 143.64W 3.93V- Bat 
18:28:00 - 27-9-2015 0.61A 143.57W 3.94V- Bat 
18:28:01 - 27-9-2015 0.62A 144.14W 3.89V- Bat 
18:28:01 - 27-9-2015 0.61A 141.90W 3.91V- Bat 
18:28:02 - 27-9-2015 0.60A 141.48W 3.89V- Bat 
18:28:02 - 27-9-2015 0.62A 144.13W 3.93V- Bat 
18:28:02 - 27-9-2015 0.60A 141.46W 3.89V- Bat 
18:28:03 - 27-9-2015 0.61A 143.72W 3.93V- Bat 
18:28:03 - 27-9-2015 0.61A 143.91W 3.93V- Bat 
18:28:04 - 27-9-2015 0.60A 141.31W 3.93V- Bat 


Following is the screen shot of usage (Wattage) vs Time. As per this graph,it clearly shows the   around that there is a peak power consumption around 6pm and around 8.30pm releavant to water heater (shower). And later part of the night it shows how the invert-er refrigerator on / off cycle.

As my proof of concept design worked in required accuracy, now it is the time to permanently fix a Energy Monitor connected to internet, So I can monitor the usage, calculate Electric bill, predict behaviors, identify abnormal conditions using these day.
I  came across on of  my multi purpose arduino like board , which have charging Li-ion battery using solar cell and able to interface to nrf24L01 chip directly.Although original purpose of this of board is a birthday card using 9x9 LED matrix, it have the capability to act as a solar powered device.

Yes. I am planning to run this energy monitor using small solar panel :).




 Main features of the board are,

1. Monitoring Solar charge current
2. Monitoring Solar voltage
3. Monitoring Battery Voltage
4. General purpose buttons
5. NRF24L01 Header ( to connect module available on ebay)

Following is the PCB. The plan is to use this board , for self powered energy monitoring device. which would update it's data to web using either wifi module or to a Raspberri pi via ISM band RF communication.


Update - 10/8/2015
Within in this week I was able to soldered the most of the components of the board. Mainly the Atmega328 chip , solar charger chip , 3.3 regulator and the 8Mhz crystal. Following is a photo of the board.


This board is in Ardino term is a "Arduino Mini Pro Atmega328p 3.3V 8 Mhz" board. So once the chip is soldered i tried to program the bootloader using another Arduino board as the ISP. while programming i came up with an issue saying the Chip signature mismatch. 

The error is that the expected signature is 0x1e 0x95 0x0F  and the read signature is  0x1e 0x94 0x06; So first I thought this is a general error and just edit the avrdude.conf and change following segment.

part parent "m328"
    id = "m328p";
    desc = "ATmega328P";
    signature = 0x1e 0x94 0x06;
    ocdrev              = 1;


But later ,I figured out that I forget to solder pull-up for reset pin. Then I soldered it the board (see the big old fashion 1k resistor in the photo). Then when i try it again it successfully download the boot loader.

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM28 -b19200 -Uflash:w:C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:i -Ulock:w:0x0F:m 

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM28
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex"
avrdude: writing flash (32652 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 32652 bytes of flash written
avrdude: verifying flash memory against C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:
avrdude: load data flash data from input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:
avrdude: input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex contains 32652 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 32652 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.07s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done.  Thank you.

The circuit is populated and now it have Li-ION battery and RN42 Bluetooth is connected to it.
Following it the image of the setup. I have use a container to protect the device from rain.

As visible on the photo, the current Sensor attached to the one of the wires which feed the Main board in the house. Following is a reading from the Bluetooth.

Data sent over serial as comma separated values first column is a count  then wattage , then current after that Li-ion battery voltage.




No comments: