Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Diverter firmware for emonTx3 using ESP8266 wifi module

Hello,

Is anyone aware of firmware that would add solar diversion functionality to an emonTx3 that is also using the ESP8266 wifi module? I’m guessing the diverter firmware available for the emonTx3 will not be compatible with the wifi module.

Which diverter firmware do you have in mind - there is a whole section in ‘Learn’ with two proven designs. I take it you’ve not looked?

There’s essentially no difference between the ESP8266-equipped emonTx and any other way of getting serial data out (i.e. a programmer), so the main worry will be an adequate power supply, which the ESP8266 needs anyway, and the availability of a digital output to drive the opto-isolator trigger i.c.

Hi Robert, I have looked and it would be Robin’s firmware for emonTx v3.4. I found a link to that firmware half way down this thread - perhaps there is a more ‘official’ location it can be downloaded from?

Anyway, my assumption was that because there used to be separate firmware version for an emonTx using Wifi, that Robin’s design wouldn’t work with such a setup. It sounds like my assumption was wrong and the version from the link will work (assuming no power issues), which is excellent.

By the way, I got that from this form thread

The firmware running on the ESP8266 module expects data to be sent via serial in a specific format, a json like key:value string of the form: P1:100,P2:250,P3:150

The first step is to upload new firmware to support this format which can be found here:"

As Robin uses the same processor as all versions so far of the emonTx, any sketch of his, including those from his website for use on his own hardware kits, will work on an emonTx with the necessary modifications. Those would include removing code which will drive a display, or the radio module, or indicator lamps, inputs from switches etc, and then changing the I/O pins for the c.t. and trigger i.c. to suit the emonTx pcb. You’d then need to add code to send any information you require to the ESP8266 for onward transmission.

As far as I’m aware, Robin has not published any versions here since he last updated his post linked from the last page of the ‘Learn’ article: Learn→PV Diversion→MK2 PV Diverter→Contents→Diverting surplus PV Power, by Robin Emley

Ok, thanks for the additional info. So there isn’t existing firmware that will work with an EmonTx v3.4 using the wifi module.

Based on using the firmware I mentioned (direct link here) do you have any pointers on how to add the code required for the onward transmission to the wifi module?

Look at the code for the emonTx V3.4; in loop( ), this has print statements in the required “key:value” format, which you need to adopt. In fact, the print statements you have in loop( ) are almost correct as they stand - you must remove the spaces and then, it looks OK.

You might well have a problem with the informational print in setup( ), which the ESP will try to send. I suggest making it conditional - include it while testing and setting up (when you’re likely to have a programmer connected rather than the ESP8266), then exclude it once you have everything working any you’re logging data. You could use one of the DIP switches for this, if you want to avoid recompiling and reloading the sketch.

Thanks Robert, that did the trick. I did have to change the baud rate in the sketch to 115200 to make it work.

I have another issue now, this may be a question for Robin but I will post it here anyway. When I connect up the diverter communication - element 4 of the emonTx terminal strip for digital 3 and element 1 for 5v (running in 5v mode) - to the output board, it immediately turns on the immersion at full power. This is with nothing on any of the CT inputs. I’ve tried this with two different emonTxV3.4 and two different output boards, so clearly I’m doing something fundamentally wrong. When the communication lines are disconnected or both at 0v, the immersion turns off as expected.

You’re confusing me with your “novel” names :exploding_head: We call those “terminal 4” etc. The connections are not “communication lines” - the one from terminal 3 is the digital output, and the one from terminal 2 (when you’ve moved it) is normally called “3.3 V” (being specific, as there are two power supply voltages present). When you wrote “communication lines”, I started thinking of the connections to the programmer, those are serial communication lines between the emonTx and your computer.

You should not be connecting the opto-trigger between DIO3 and 5 V - the emonTx processor runs at 3.3 V (on terminal 2). You may well have damaged your processor, which if you have means you must replace the emonTx (it’s not practical to remove and replace the processor).
You should be using the diagram for the emonTx V3 on this page Learn | OpenEnergyMonitor, but using DIO3 (terminal 4). If you’re using an external 5 V USB adapter, you can use the 75 Ω resistor and MOC3041M as used for the emonTx V2. If you’re only using the a.c. adapter to also power the emonTx V3, you must change the value for the current-limiting resistor (to 180 Ω) and use the more sensitive version of the opto-trigger i.c - a MOC3043M. Either way, you must check that D3/pin 3 is the one used in the sketch.

What’s actually happened is the output of the processor can’t go to a high enough voltage to turn the opto-trigger off (it’s OFF when the output is HIGH at just below 3.3 V, and ON when the output is LOW at just above 0 V), but by connecting to 5 V, you still have 1.7 V feeding it even when it should be off, which is enough to turn it on, hence turn the triac permanently on.

I can’t take any credit for the novel names, they came from Robin in the old forum thread :smiley:

Thanks for the further explanation, things are starting to make much more sense now. I was previously using an emonTx shield which - I believe - does operate at 5V hence some of my confusion.

Of the two emonTx v3 I have been testing with, the first still operates fine and the second does now have an issue - it will not communicate via the RFM69 anymore, but does work with a wifi module.

I haven’t managed to try and connect it up again yet, but hopefully this time it will be more successful…

If you connected the 3.3 V rail or the processor output pin to the 5 V, via the photo-diode that’s in the opto-trigger, this does not sound good for the RFM69CW radio. That has an absolute maximum supply voltage of 3.9 V, so if you haven’t turned the radio off in the sketch, it’s possible that it has been damaged.

The emonTx Shield operates at two voltages - the analogue inputs are 5 V, the radio is 3.3 V. The 5 V data from the processor to the radio is divided down to prevent damage.