There seems to be a lot of interest in the ESP8266 and emoncms.
I have started this thread as a resource for any one interested.
Esp8266 forum http://www.esp8266.com/
Very useful blog http://tech.scargill.net/
I have emoncms monitoring my central heating, rain fall and a garden shed mounted DC solar system. (We live in a listed cottage and have a very small roof so grid connected PV is tricky) I use the rain fall to control a solar powered remote irrigation system locally controlled by an Arduino. I use SMS messages to monitor and control the water. The whole system is tied together using mqtt (my own broker - mosquitto) and node red running on a Pi. My emoncms is locally hosted also on a PI. (At the moment 2 Pi are used mainly for historical reasons, now I have everything pretty well debugged I think it could all run happily on a Pi2) I can control most things over the internet using thing studio:- http://www.thingstud.io/
I am working on using an ESP8266 as the local control for the irrigation and controlling via the Internet as there is now a public wifi connection I can pick up.
there seem to be at least four different ways to use the ESP8266:
- use as a slave controller with the AT command set
- use NodeMCU firmware and LUA script programming
- write native code with the ARDUINO IDE and environment
- write native code with the Espressif SDK
Which way will you be going?
I just tested first scenario mentioned by Jorg - ESP8266 as a AT command slave for Arduino Due and it is really impressive powerfull and flexible set.
I ended up using this :- http://www.esp8266.com/viewtopic.php?f=9&t=820
It meant learning how to use basic eclipse functions but I did not find it too difficult (after a lot of google searching). The main reason was because it had the best mqtt support I could find when I first started. It uses this library:- http://www.esp8266.com/viewtopic.php?f=6&t=1031&start=40
I must admit it was mainly because that is what Peter Scargill is using and he seems to know what he is doing and he is also using the ESP8266 for a very similar application to mine.
If on your travels you should find any info on how to make a serially connected esp8266 replicate a "normal usb wifi dongle" for normal internet usage, I would be very pleased to hear about it, I did search extensively but the general consensus seems to be "yes it's capable but why bother when a usb dongle costs the same".
What the esp8266 method can do that the standard dongle cannot is power down AND power up the Pi (or reboot) and put itself to sleep, and it has a single adc that could monitor it's own battery voltage and (something you may be interested in Ian) when operating from battery it can shut down the Pi when battery voltage is low and start it again when battery voltage comes back up, whilst providing a manual override and notifications/updates in it;'s "sleep" state (ie Pi off & esp sleep 90% of the time)
Plus the esp8266 is capable of starting in AP mode and switching function, which could make a very easy WiFi configuration method, plug it on => connect to network "esp" using a smartphone => enter ssid and password => exit ap-mode so the pi can connect to your lan, job done.
I have so far done a quick test with a USB adapter and ESP8266 using the AT command set. Very impressive! Two simple commands and I had the chip connected to my WLAN, wow. But in the end I do not want to use a second microcontroller.
I have also set everything up for the Arduino environment. Sample programs compile, so there is a good chance it works if I get my final hardware (today?).
Not so much success with the setup Ian uses (http://www.esp8266.com/viewtopic.php?f=9&t=820). Everything is set up successfully, but I am not able to compile sample projects from others. Not sure about the reason, but has something to do with the makefile and location of files.
I am looking at using the ESP8266 to operate as temperature and humidity sensor plus IR remote control for an air conditioner. However it is looking more complicated than I thought it would be, mainly because of the way in which the IR commands work for the air conditioner. I really wish I had bought an air conditioner with wifi remote control. That however wouldn't have solved the problem with the older air conditioner unit.
For anyone interested in using Arduino environment for programming of ESP8266:
I tried to program the NodeMCU hardware using the setup described here:
It has cost me some hours now to find out that the 'stable' version to use the boardmanager:
does not work. The NodeMCU hardware uses a different layout/addressing of the flash and some variants of the ESPxx chips might do so too.
So, always use the 'staging' version:
This one works like a charm 'out of the box'.
Just as a matter of interest, has anyone got eMonLib working with an ESP8266?
I know they only have one ADC, so could only be used for monitoring current. However with the addition of an external analog mux it may be possible to read both voltage and current. I don't know how fast the ADC is on the ESP8266 (I can't seem to find a very good datasheet for this device), but if it was fast enough and the mux was fast enough, it may be possible to switch the mux and sample both voltage and current on the same ADC input.
Just for info:
I am now using the NodeMCU hardware (very convenient to use) in combination with the Arduino IDE. First project was to measure voltage and current of my PV storage battery and send this data via Wifi to EmonCMS running on a Raspberry Pi. I am using an external Microchip 18 bit I²C ADC (MCP3424 on Jeelabs Analog plug).
This is so simple, it is really amazing ....
I am interested in your NodeMCU implementation, this sounds very interesting! How are you sending the data to EmonCMS?
+1 to that. Which version of emoncms and how have you linked the data into emoncms?
Must admit I've also found it incredibly easy to get things up and running with the arduino ide. I've been using Nathan Chantrell's dev board with the esp03, sending temperatures to an mqtt server.
For anyone wanting to play around you could also look at the simple web server demo that Pete Scargill published in the last couple of days.
I use the NodeMCU hardware with the normal 'Arduino' firmware.
Attched my small sketch. It reads voltage and current from an MCP3424 and sends this data to the EmonCMS running on a Raspberry Pi. (Wifi and EmonCMS keys deleted).
Hope it helps.
I am hoping to use some ESP8266 devices on my home automation. The first project is to use one with a DHT22 to report temperature and humidity back to emoncms.
In fact, where I can I will use an ESP8266 instead of an Arduino. They have limited cpacity but for simple tasks where an Arduino isn't needed they are perfect.
The general principle I am hoping to use on my home network is to expose sensor data from an ESP8266 as json or a simple web page. The ESP8266 acts as a simple web server very easily so creating a kinda API for other nodes on the Wifi network to interrogate should be straightforward.
Thank you Jorge! Your code cleared up some mysteries for me.
Jorge. Much appreciated!!
Just an FYI, you missed blanking one of the api keys. There is one at the end of the code. You might want to blank this and resubmit.
But very many thanks, this has really helped me. Would have taken hours of searching for the info and debugging it until it was running.
oh yes, missed that apikey (I had made a test with variable and 'hard coded' strings). Not a big issue though as the Raspi is on my internal network only. Would have been worse if I had published my WIFI key ;-)))
When I wrote that sketch I had just begun to play around with the Arduino ESP8266. There might be places in the code where things can be done in a better way. But this setup is running since some weeks now without any problems. It is reading the voltage and current of my PV storage battery. Next amendment will be to read the charge and discharge currents separately with two individual shunts (battery is charged via an MPPT charge controller and discharged by a controllable AEconversion grid tie inverter). And then I want to add an RS485 for communication with the inverter. The software changes will be easy, it takes more time to do the hardware part.
I have been using an ESP8266 with an ADS1115 ADC to read data off a current clamp and approximately monitor my power usage. Here is the set-up:
There is a free differential channel for reading the voltage using a transformer as well.
Which ESP8266 board you are using?
Do you have a circuit diagram for this?
What code are you using?
I am using a NodeMCU v1.0 board like this one - https://github.com/nodemcu/nodemcu-devkit-v1.0 . It is slim and fits nicely on the breadboard. The ADS1115 is attached to pins 1,2 of the NodeMCU via the I2C bus. The code I am using is a modified version of the Irms method in emonLib for Arduino. I will upload my sketch to gist tonight and update this.
Here is the gist with the code - https://gist.github.com/whatnick/73c244694466355f6a14
With the ADS1115, would it be able to monitor a total of 4 currents since it is a four channel system?
I am using the ADS1115 in differential mode to avoid having to add the bias voltage resistors and have a voltage reference. So my set-up is limited to 2 channels. You have the choice of setting it up in single ended mode with voltage dividers and using all the 4 channels separately, or you can put 2 ADS1115 sensors on the I2C bus with different addresses as shown here. I am going to get Fritzing and redraw this with Node MCU.
Here is how the ADS1115 is connected to the NodeMCU:
Thanks for all the information.
I have put my project together on a PCB and it is available here - https://www.tindie.com/products/whatnick/nodemcu-energy-monitor-pcbkit/ . Please let me know if you are interested.
The full story of its development is here - http://whatnicklife.blogspot.com.au/2015/09/experimenting-with-energy-mo... .
You are publishing your api key...
correct it if you can
Here's firmware for ESP8266/EmonCMS code I wrote to get data from an Electric Vehicle charging station and send it to the server.
The firmware boots up as an Access Point in configuration mode to enter SSID, Password, EMON Key and Node which is stores in EEPROM.
Then it boots into client mode, connects to your AP and sends data to EmonCMS. The web server is active in client mode to edit configuration.
Open-source tools for energy monitoring and analysis. Forum has moved to: https://community.openenergymonitor.org