Hi there,
What are we doing here
After the generic RF protocol, let me introduce my generic Wifi sensor module.
With this project you will be able to monitor your electricity and gas consumption.
My gas meter is similar to this one (there is a magnet inside that allow me to count “ticks”, 1 imp = 0,01m³)
Electric meter is similar to this one (there is a led that we will use, 1imp = 1 Wh)
Hardware side
- 1 ESP8266: http://www.banggood.com/ESP8266-ESP-201-Remote-Serial-Port-WIFI-Transceiver-Wireless-Module-p-964288.html
- 1 FTDI module: http://www.banggood.com/FT232RL-FTDI-USB-To-TTL-Serial-Converter-Adapter-Module-For-Arduino-p-917226.html
- 1 Breadboard Module Adapter : http://www.banggood.com/Wholesale-MB102-Breadboard-Power-Supply-Module-Adapter-Shield-3_3V-or-5V-For-Arduino-Board-p-47473.html
- 1 hall sensor : http://www.alldatasheet.fr/datasheet-pdf/pdf/547695/OHHALLSENSOR/OH44E.html
- 1 Light-Sensor : http://ams.com/eng/Products/Light-Sensors/Light-to-Voltage-Sensors/TSL257
- 1 power supply that connect to the round connector of the Breadboard Module Adapter
You don’t need any arduino or ATmega! We will use the chip of the ESP8266.
Connect things together
Some notes : when you want to load the sketch connect all green wires (RX/TX/GND AND IO0 to GND), when sketch is loaded connect IO0 to VCC.
Software (ESP8266 side)
- Install this Arduino IDE for ESP8266 : https://github.com/esp8266/Arduino
- go here https://github.com/Yves911/PimaticClient and download : PimaticClient.ino or PimaticClient2.ino
- open PimaticClient.ino into the Arduino IDE for ESP8266 and adjust
- ssid and password (ie your wifi details)
- Pimatic_host (the server that is currently running pimatic)
- httpPort (WARNING : here enter a port that is not used by any service on your pimatic server : ie a FREE port, for our example it will be 8888)
- load the sketch on your ESP8266 (remember connect all green wires)
On pimatic side
- run a netcat server on the pimatic server (remember 8888 was a free port)
nc -d -l 8888 > /dd_extern/tmp/conso.log &
- check that you see some info coming from the ESP8266 module, you should see something like
E,622,488,7366
- add those devices (and adjust depending on your specific needs)
{
"id": "consoelec",
"name": "elec data",
"class": "LogWatcher",
"file": "/dd_extern/tmp/conso.log",
"attributes": [
{
"name": "tick_elec",
"type": "number"
},
{
"name": "cons_elec_inst",
"type": "number",
"unit": "Wh",
"discrete": true,
"acronym": "inst."
},
{
"name": "tick_e_time",
"type": "number",
"unit": "ms"
}
],
"lines": [
{
"match": "^E,(.*),(.*),(.*)",
"tick_elec": "$1"
},
{
"match": "^E,(.*),(.*),(.*)",
"cons_elec_inst": "$2"
},
{
"match": "^E,(.*),(.*),(.*)",
"tick_e_time": "$3"
}
]
},
{
"variables": [
{
"name": "Compteur",
"expression": "61400 * 1000 + $consoelec.tick_elec",
"unit": "Wh",
"type": "number",
"label": "Compteur"
},
{
"name": "Conso_inst",
"expression": "$consoelec.cons_elec_inst",
"unit": "Wh",
"type": "number",
"label": "inst.",
"discrete": true,
"acronym": "inst."
},
{
"name": "Conso_jour",
"expression": "$elec_display.Compteur - $elec_morning",
"unit": "Wh",
"type": "number",
"label": "Journée",
"acronym": "j."
}
],
"id": "elec_display",
"name": "Électricité",
"class": "VariablesDevice"
},
{
"id": "consogaz",
"name": "gaz data",
"class": "LogWatcher",
"file": "/dd_extern/tmp/conso.log",
"attributes": [
{
"name": "tick_gaz",
"type": "number"
},
{
"name": "cons_gaz_inst",
"type": "number",
"unit": "m³",
"discrete": true,
"acronym": "inst."
},
{
"name": "tick_g_time",
"type": "number",
"unit": "ms"
}
],
"lines": [
{
"match": "G,(.*),(.*),(.*)",
"tick_gaz": "$1"
},
{
"match": "G,(.*),(.*),(.*)",
"cons_gaz_inst": "$2"
},
{
"match": "G,(.*),(.*),(.*)",
"tick_g_time": "$3"
}
]
},
{
"variables": [
{
"name": "Compteur",
"expression": "17852.000 + $consogaz.tick_gaz/100",
"unit": "m³",
"type": "number",
"label": "Compteur"
},
{
"name": "Conso_inst",
"expression": "$consogaz.cons_gaz_inst/100",
"unit": "m³",
"type": "number",
"label": "inst.",
"discrete": true,
"acronym": "inst."
},
{
"name": "Conso_jour",
"expression": "$gaz_display.Compteur - $gas_morning",
"unit": "m³",
"type": "number",
"label": "Journée",
"acronym": "j."
}
],
"id": "gaz_display",
"name": "Gaz",
"class": "VariablesDevice"
},
Results
You can now start pimatic and enjoy live data coming from your electric and gas meters…
Few remarks
You can adapt this example to your need (for example my electric has a led that flash every watt maybe not yours).
Also i think i will change the way to transmit data to pimatic (but waiting the MQQT plugin first: http://forum.pimatic.org/topic/344/pimatic-mqtt-would-be-nice/2)