Example Code - sending data to emoncms using only ESP8266

I have spent countless hours searching and am feeling really dumb right now.

So I have an account for emoncms where being new I have no inputs created. I expect I need to create a source of data input but I have two questions:

  1. Can I use just a ESP8266 all by itself to get the data and send it to emoncms? For example, let’s say I create random numbers and send to the emoncms so that I can create an input and see the data coming in just so I can start to understand how it works.

  2. Assuming 1 is correct, where can I find example code for an ESP8266 or ESP32? Because I cannot find this I think I am totally confused about how this works?

Am I getting confused because I have been using Blynk for a number of years now?

Thank you for any help.

Welcome, Steve, to the OEM forum.

I can well understand that you are confused. Don’t worry, it isn’t you - we know how you feel, we were all in the same place once.

In case you were wondering, you don’t create inputs in emonCMS - they will appear when data arrives. If you want, you can see on the Inputs Help page the format of the data that emonCMS expects, you can send this manually, using the address bar in your browser.

Now, Question 1:
I presume you could, but we don’t use it that way, hence there’s no software (that we use) that will do that. We use it purely as a one-way serial data (out of an emonTx, in a specific format and baud rate) to WiFi “converter”. Not that I’ve ever done it, if you can use a laptop and a short script/application to send the correct serial data - which you can crib out of an emonTx script - then our software for the ESP8266 should take that and the data should appear in emoncms.org

Which brings us to Question 2. If you got your ESP8266 from the OEM shop, it’s already programmed. If you didn’t, you’ll need to get the application to flash it and the code to flash.
My colleague Brian, who knows more about this than I do, recommends Release 1.4.0 · esphome/esphome-flasher · GitHub to flash ESP8266 devices.

The code for the ESP8266 (emonESP is an emonTx with an ESP8266 attached originally, now inside the case) is in Github (and best of luck with that - I can’t understand it) here:

What worries me is

What data do you have in mind?

Thank you Robert for your response. You have cleared much of it.

Now regarding “What data do you have in mind?” I presently have an ESP8266 which reads the blinks on my hydro meter and I send it up to the Blynk website.

I send real time house power consumption by calculating kWhr using the time between blinks (no pun intended) then at midnight I send the total number of blinks, min/max power for the day to the Blynk website.

But, I don’t like how limited and clumsy the graphing tool is for Blynk so I am thinking I can just redirect this data to emoncms instead of Blynk.

Am I able to do this or am I still missing something?

Thank you.

Sorry, I realize that I have another question.

I think I know this but confirmation will really help with my confidence.

So the GitHub link above, does that basically convert serial to WiFi for sending data to https://emoncms.org?
So that is where I have say an UNO doing the ADC stuff and sending it to emoncms through this ESP8266?

I need an ADC and have learned the hard way that the ADC in the ESP parts do not work. The WiFi interferes with readings.

Also, what is confusing is when you say “out of an emonTx”. Is this the product I have seen which I can buy? Or are you referring to Arduino code which sends out “emonTx”?

So answering those two together:

I don’t see a major problem doing the kWh pulses and accumulated values to emonCMS, but because I’ve never written software for the ESP8266, and knowing intimately what the emonTx does, I would keep the ESP8266 purely as a serial data to Wi-Fi interface. so specifically answering

this is all that software does (apart from appearing as an AP for initial configuration).

The emonTx uses the same processor as the Arduino Uno, so the software is more or less interchangeable. The emonTx is the complete device you can buy in The Shop. Its software in Arduino-speak is a “sketch”. The advantage of an emonTx for you is you have the analogue inputs for voltage and current, so if you want to measure those and hence power/energy of (say) only part of you house, you’ve got the hardware to do it. The emonTx also has a pulse input (on a RJ45 connector) so you can use that for your meter interface. You might need to add some code to do the daily reset, because the emonTx doesn’t have a real-time clock nor access to Internet time. If you need that and emonCMS won’t do it (I don’t know emonCMS well enough to say), then it might be easier to add that to the ESP8266, and send it (as a separate Sensor Node) to emonCMS.

The “original designed” way we use the emonTx is to send the data by ISM band radio (hence “Tx” in the name). Serial data via the FTDI programmer port was always an option, and it’s that which the ESP8266 connects to, for the data to go out via Wi-Fi.

I’m using “out of an emonTx” in both senses there, first “the data coming out of the emonTx serial port…”, the second as “lift the code that generates the serial data or the format of the serial data out of the code (sketch) that the emonTx executes”.

There are very critical comments about the analogue side of the ESP32 elsewhere on the WWW, and as the ESP8266 is the same manufacturer, I’m not surprised by what you write.