Simple energy meter counting pulses, environment sensor, xbee gateway and web dashboard to show data
PHP Arduino
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
EthernetXbeeGW
SensEthernetSD
envsensor
int3drevettsl257medSD
web
PowerMeter TSL257 and SD.fz
README

README

ArduinoEnergyMeter
==================
https://github.com/aardalo/ArduinoEnergyMeter

Author
------
Øyvind Aardal

License
-------
http://creativecommons.org/licenses/by-nc-sa/3.0/


Hardware [SENS]
---------------
Sensor-device with "light-to-voltage" converter used to count pulses on a
energy meter similar to this:
http://bilde.digi.no/overv%E5k+str%F8mforbruket+i+huset+fra+pc-en.jpg?o=2720923&w=698&h=0&ee=1220967635
The TSL257 is fastened over the impulse diode with "McGyver tape" to avoid
stray light and to ensure secure fastening. The Arduino and Xbee is located
outside the "fusebox" and a regular 4-wire telephone cable is used to connect
the TSL257 to the Arduino (3 wires).

	Arduino Uno R3		
	http://arduino.cc/en/Main/ArduinoBoardUno
	
	Wireless Proto Shield
	http://arduino.cc/en/Main/ArduinoWirelessProtoShield

	DFrobots SD module
	http://www.dfrobot.com/index.php?route=product/product&filter_name=sd%20breakout&product_id=163
	
	TSL257-LF
	http://www.taosinc.com/ProductDetails.aspx?id=73
	
	Xbee 1mw 802.15.4
	http://www.sparkfun.com/products/8665

	
### Wiring of sensor module [SENS]
	TSL257 OUT to Arduino pin 3
	SD module as described in DFR0071_Wiring.JPG
	Xbee mounted on Wireless Proto Shield
	
Hardware [ENGW]
---------------
	Arduino Uno R3		
	http://arduino.cc/en/Main/ArduinoBoardUno
	
	Wireless Proto Shield
	http://arduino.cc/en/Main/ArduinoWirelessProtoShield

	Xbee 1mw 802.15.4
	http://www.sparkfun.com/products/8665

	Arduino Ethernet Shield
	http://arduino.cc/en/Main/ArduinoEthernetShield
	
### Wiring of xbee to ethernet gw [ENGW]
	Ethernet Shield and Xbee Shield stacked

Hardware [ENVM]
	Arduino Uno R3
	http://arduino.cc/en/Main/ArduinoBoardUno

	Arduino Wireless Proto Shield
	http://arduino.cc/en/Main/ArduinoWirelessProtoShield

	Xbee 1mw 802.15.4
	http://www.sparkfun.com/products/8665

	Sparkfun TMP102 breakout
	http://www.sparkfun.com/products/9418

	Any old LDR (approx 30k) and a 1k resistor

### Wiring of Environmental Monitor
	(Based on http://bildr.org/2011/01/tmp102-arduino/)
	TMP102
		Connected with CAT5 cable as follows:
 		A5->Brown->SCL, GND->Brown/White->GND
 		A4->Blue->SDA, 5V->Blue/White->V+
 		GND->Orange->ADD0, (not connected)->Orange/White->ALT
	LDR (not polarized)
		GND->Green->LDR
		5V->Resistor->Green/White
		Between Resistor and Green/White->A3

Hardware [LAMP]
---------------
Any LAMP server - could be a Synology NAS (my setup) or e.g. a Amazon EC2
server (small ... free for a year). 

Database
========
Data Dictionary for MySQL database "power" on localhost
You must have db config file "dbconfig.php" in same dir as sql*.php:

	<?php
	$user="insert database username";
	$password="insert password for user";
	$database="database name";
	$table="meter table name";
	?>

meter
-----
Table comments: power meter loggdata

Column 		Type 		Null 	Default
-----------	-----------	-------	-----------------
timestamp 	timestamp 	No 		CURRENT_TIMESTAMP 	
count 		int(11) 	No 		
kwhh 		float 		No 		
	
utelys
------
Table comments: lysmåling ute

Column 		Type 		Null 	Default 	
-----------	-----------	-------	-----------------
timestamp 	timestamp 	No 		CURRENT_TIMESTAMP 	
value 		float 		No 		

utetemp
-------
Table comments: utetemperatur

Column 		Type 		Null 	Default 	
-----------	-----------	-------	-----------------
timestamp 	timestamp 	No 		CURRENT_TIMESTAMP 	
value 		float 		No 		

Revision History
================
20.03.2012  Added database description
	Modified environmental sensor to save data to separate tables to make life
	easyer for my Synology 410 - it was peaking CPU due to inefficient queries
07.03.2012	Fixed minor bugs and added support for "temp" table on MySQL server
	Also modified the gw to support "wellformed" GETs that will be
	sent directly to the LAMP server.
	Fixed graphs so that they grow correctly if missing datapoints.
	Added environmental monitor that logs light and temperature
29.02.2012	Added MySQL support. web/sql*.php is called from index.php
	Added Xbee to Ethernet GW
05.02.2012	Revised web pages to dynamically update without reload - still rough 
    but closer...
01.02.2012	Added web pages in php using Google Chart. Inspired by code created 
    by https://github.com/HNygard
01.02.2012	Initial version - experimental level - all input highly appreciated

To-do
=====
*	Revise SENS to send "correct" syntax to the GW. Now the transform to save
	data to the MySQL db is done in the GW and it should be transparent.
*	Revise SENS to employ /utc/ time broadcast by ENGW and timestamp reports
*	Really need to add DHCP and DNS support for the GW to avoid hardcoded IPs
*	lots more...

Known issues
============
*	When computer sleeps and resumes, page should reload to catch up the line-
	graph - now it just continues multiple reads is hogging memory and cpu on 
	my LAMP server (Synology 411j) - should only parse new stuff since last
	load and update graphs
*	If there's not enough data last 24 hours, the graph doesn't grow. The same
	number of data points is kept, should grow until 24 hours total is reached.
	(Resolved 07.03.2012)