Open Energy Monitor

What are you developing?
User avatar
mrburnette
Posts: 1788
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Open Energy Monitor

Post by mrburnette » Sat Jun 25, 2016 5:59 pm

ityogi wrote:I plugged in my OpenEnergyMonitor setup into the BPB STM32 today and it worked without any modifications. Great work, and thanks, @rogerclark!

Now the next challenge is to make it talk to EmonESP for WiFi data upload, and incorporate MQTT in the STM32 itself.
TristantLea wrote:
The next step is to test and establish the reliability of this, I've had mixed results so far with some of the prototype heatpump monitors loosing wifi connection and requiring a reset.
Yea! Relying on TCP connection is always going to be problematic. Websockets work better, but can still get lost forcing a reload. In my experience (9 months) UDP is reliable and self-healing. Example Send a serial string and parse what you need... extendable too; just add new data to the end of the string. I have 3 receiver units working simultaneously w/ no issues.

Ray

User avatar
RogerClark
Posts: 6130
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Sun Jun 26, 2016 10:54 pm

BTW.

I had also considered just using an ESP8266 for this, and an analog mux , or an external DAC e.g. AD7705

I did some research but I can't find anyone who has done this, which is a bit surprising.

I know that the main issue is that the ESP8266 only had one ADC and its reads the 0 to 1V range.
People have speculated that you could not get good results reading both voltage and current using the same ADC using an external MUX, but as the ESP8266 is significantly faster than the AVR Arduino (on which the original EMonTX is roughly based), I think this is just speculation and no one has done any serious comparisons between AVR and ESP8266

The STM32 however is bound to give better results as the sampling rate and resolution is better than the ESP's internal ADC.

External ADC on the ESP8266 however may be an interesting option depending on the functionality of the external ADC.
i.e if the external DAC can be triggered to read the voltage and current inputs simultaneously, or to possibly for the ADC to be doing conversion on one channel while the data is read out from the other channel etc
This may put an ESP8266 solution on par with an STM32 solution.

However it would take a lot of research.

User avatar
mrburnette
Posts: 1788
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Open Energy Monitor

Post by mrburnette » Sun Jun 26, 2016 11:19 pm

RogerClark wrote: <...>External ADC on the ESP8266 however may be an interesting option depending on the functionality of the external ADC.
i.e if the external DAC can be triggered to read the voltage and current inputs simultaneously, or to possibly for the ADC to be doing conversion on one channel while the data is read out from the other channel etc
This may put an ESP8266 solution on par with an STM32 solution.

However it would take a lot of research.
Another possible solution, just brainstorming:
Use an Atmega328P-PU running @12MHz and 3.3V for the ADC's. Use SPI to SPI to pass a struct (binary) between the 328 and the ESP8266. This is a very cheap solutuon and you can likely run the 328 out-of-spec @16MHz and 3.3V on an Arduino Mini breakout. Even @12MHz the solution is incredibly simple - simple is good.

Ray

User avatar
RogerClark
Posts: 6130
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Sun Jun 26, 2016 11:34 pm

Ray

My existing solution is already to do something similar as I use a Maple Mini, to do the data capture and analysis and just send data via Serial to the ESP8266.

The Maple mini could be replaced by Blue Pill if people were price sensitive.

User avatar
mrburnette
Posts: 1788
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Open Energy Monitor

Post by mrburnette » Sun Jun 26, 2016 11:41 pm

RogerClark wrote:<...>and just send data via Serial to the ESP8266. <...>

"serial" is simple :D

User avatar
RogerClark
Posts: 6130
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Sun Jun 26, 2016 11:48 pm

Ray

I guess I was being lazy by using Serial, but as the ESP8266 was not a core part of the project (the display and data transmission on 433Mhz as essential)
I thought connecting via Serial would be fine.

I run the eMon lib so that it samples over 1 second and takes an average. So I only need to send 1 packet of data to the ESP8266 every second, and that packet is quite small, something like 32 bytes, so transferring via Serial isn't much of a bottleneck


I think the main reason I thought about using an ESP-12 and external MUX was that it was smaller than the Maple Mini, but a bare metal STM32 just needs an external xtal, so would really not be very big if I wanted to just reduce the size, and would not be substantially bigger than either a analog MUX or external ADC

ityogi
Posts: 4
Joined: Thu Jun 16, 2016 6:36 am
Location: India
Contact:

Re: Open Energy Monitor

Post by ityogi » Thu Aug 04, 2016 6:09 pm

You've echoed my line of thoughts and experimentation on this topic, Roger and Ray.

Using only ESP8266 (with sensors) would've been an ideal solution. Apart from single ADC input and 1V range, the problem lies in the sampling rate of ESP8266 ADC. The stated official sample rate is 200sps. Some have reported achieving 2.5k sps but there are risks of WDT resets at such high sample rates. To accurately measure power, it's recommended to measure 20th harmonic which corresponds to 2000sps. A minimum of measuring up to 6th harmonic, i.e., 1200sps is needed.

Realising this, I ordered an external ADC for use with ESP8266, but a common ADC such as ADS1115 has 860sps, way inadequate for this application. Using a more expensive ADC doesn't make sense because ATMEGA328 or STM32 work out as a cheaper ADC!

Currently, my setup is similar to what your described: a BPB connected to ESP8266 over Serial, sending MQTT data.

My next attempt is towards using a dedicated energy measurement chip (I got an ancient CS5460A for cheap on Ali), interfaced to ESP8266.
RogerClark wrote:BTW.
I know that the main issue is that the ESP8266 only had one ADC and its reads the 0 to 1V range.
People have speculated that you could not get good results reading both voltage and current using the same ADC using an external MUX, but as the ESP8266 is significantly faster than the AVR Arduino (on which the original EMonTX is roughly based), I think this is just speculation and no one has done any serious comparisons between AVR and ESP8266

External ADC on the ESP8266 however may be an interesting option depending on the functionality of the external ADC.
i.e if the external DAC can be triggered to read the voltage and current inputs simultaneously, or to possibly for the ADC to be doing conversion on one channel while the data is read out from the other channel etc
This may put an ESP8266 solution on par with an STM32 solution.

However it would take a lot of research.

User avatar
RogerClark
Posts: 6130
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Thu Aug 04, 2016 9:22 pm

As I wanted to measure voltage as well as current in order to get the power factor, I would have needed 2 external ADCs attached to the EPS8266, so using a STM32 was still the cheaper option, as it also offloads the computation to the STM32

The BluePill board costs less than $2 including carriage, using external ADCs would cost many times more than this.

The only drawback is the physical size of the overall system.

You could try that ESP14 as it has an STM8 in the same housing as the ESP8266, but you have to program it using a completely different compiler ( not GCC and not use the Arduino IDE and API as no one has written and STM8 arduino core)

ityogi
Posts: 4
Joined: Thu Jun 16, 2016 6:36 am
Location: India
Contact:

Re: Open Energy Monitor

Post by ityogi » Fri Aug 05, 2016 5:09 am

Hopefully the ESP32 will address the sample rate problem, and become reasonably priced before the end of 2016. It has 16 channels of 12-bit ADC.

To me, the bulkiest component in an Energy meter is the Voltage sensor, i.e., a transformer/AC-AC adapter. Any dedicated chip that measures voltage (through resistor divider)/current samples and provides isolated I2C/SPI is the holy grail!

User avatar
RogerClark
Posts: 6130
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Fri Aug 05, 2016 7:37 am

ityogi wrote: To me, the bulkiest component in an Energy meter is the Voltage sensor, i.e., a transformer/AC-AC adapter. Any dedicated chip that measures voltage (through resistor divider)/current samples and provides isolated I2C/SPI is the holy grail!
I bought some of these a while ago

Image

http://www.ebay.com/itm/NEW-ZMP107-2mA- ... 1438897688

http://www.zeming-e.com/file/0_2013_10_18_093344.pdf

Which should miniaturize the voltage detection a bit

But I've not had time to test them :-(

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest