EmonTx + ESP + LCD new install

I just came in from finishing the final installation of my EmonTx v3 system and wanted to come give my thanks to the hardware and software developers who have made this project so great. I have been using EmonCMS since it was first released, trying to achieve the dream of power monitoring at my home. I have reverse engineered the protocol for the Black and Decker EM100 pulse counter, and built hardware to decode it using an atmega and RF69 in OOK mode (or a superheterodyne receiver module). I have reverse engineered the protocol for the Lowes Iris smart plugs and integrated their measurements into the system. Now I have an official EmonTx from the Open Energy Monitor store and I am wondering why I waited so long to get the real McCoy!

I recently had solar panels installed and the new meter from the electric company meant that the EM100 wasn’t going to work any more so I set to work installing the EmonTx. The Tx itself also has a DS18B20 jammed into the phoenix screw terminals. The case had to undergo a 1 minute modification with a circular file to get it to fit in the slot sideways (sorry no photo of that).

For those that aren’t as into being an electrician as electricians are, to run the CT wiring out of the panel I used one of the 1/2" knockouts, with a schedule 40 PVC male adapter, a 1/2" conduit locknut, and a 1/2" rigid conduit insulating bushing (although I don’t believe you need this last piece). It took a few trips to the hardware store to get the right combination.

One of the things that was holding me back in getting an EmonTx originally was that it transmitted RF so you needed a receiver that was just tasked with uploading the data to EmonCMS. A Raspberry Pi, wifi adapter, 5V supply, SD card, and yet another little machine sitting somewhere in my house. When I saw the EmonESP blog post I knew it was exactly what I was looking for and it worked immediately with no fuss no muss.

Wait second, the EmonESP doesn’t have an LCD on it! Well I felt bad about having the ESP with all them there GPIOs just not doing anything, and I needed to make a little case to put over the Adafruit Huzzah breakout module anyway so I just wired it up to an LCD I had here and 3D printed a mount and case.

My solar panels ended up putting out too much power though for CT4 on the EmonTx so I replaced all the burden resistors with different values while I was at it. 27 ohm 1% for CT1 and CT2 (house import power), and 47 ohm 1% for CT3 and CT4 (solar generation) which gave me roughly 81A and 47A current limit respectively.

I would be happy to share the source code to the LCD display, it adds a file of about 180 lines to the EmonESP scetch, with the majority of that being the custom character definitions for the wifi / house / sun icons which I designed!

LCD / ESP board mount is on Thingiverse
Full sized images Imgur Gallery

Again, thanks for everyone who answered my questions and made this project a 100% success! It might be cool down the road for there to be an EmonTx v4 with no RF69 module and an ESP8266 instead but this is ridiculously easy and cheap to do. I can really only complain about one thing, which is a minor gripe that the FTDI header could be moved 0.1" toward the edge of the board which would allow for a more secure connection to a standard right angle dupont header. I may add a piece of double sided tape to the LCD to help hold it on.

EDIT: I wasn’t sure what category to post this in, so if a moderator wants to move it to where it might do the most good I say go for it.


Very nice!
Id be interested to see if I could add this onto my shed emontx that’s using serial to gather the output from the emontx to a pi.


True. Although not needed, it keeps the inspectors happy. :wink:

I’ve now had this up and running for 4 full days and the daily accumulated values reported by EmonCMS are within +/-0.3% of those reported by my inverter’s monitoring interface. Pretty awesome! It is nice being able to see live data with decent resolution as opposed to the monitoring website’s 10 minute update period.

It might also be helpful to others to know how I calibrated my system, especially considering I replaced the burden resistors in the EmonTx.

  • Step 1: Stick a multimeter on the AC outlet and measure the AC voltage. Adjust the Vcal_USA constant so that the Vrms reported by the emonTxV3_4_DiscreteSampling sketch matches the multimeter. Adjusting the value up makes the reported voltage go up. I ended up with 138.96 which is pretty high, but the voltage matches what my inverter says it is putting out so /shrug?
  • Step 2: Wait until the solar panels are at peak output so the power readings are at their max values. Compare the power readings from EmonTx to the real-time display on the inverter. Adjust Ical3 and Ical4 (my solar CTs) in the sketch to make the power readings match. Adjusting the values up makes the reported power usage go up. My 47 ohm 1% resistors ended up at 42.2 which works out to be about 47.4 ohm.
  • Step 3: Flip off all the breakers in the house (leaving the mains breaker on) so all solar generation is being exported. The ct3+ct4 values should now match ct1+ct2 (import/export). Adjust Ical1 and Ical2 constants so the power numbers reported by EmonTx matches. Again, adjusting the values up makes the reported power usage go up.

As well as the one the inverter is backfeeding…

haha yes of course, also the outlet you have the EmonTx plugged into (making sure there’s nothing else plugged into that circuit)!

Excuse me, but are the full calibration instructions not already available to you?

Full calibration instructions that are on the wiki are great but rely on putting the current clamp through a modified extension cord to separate the Live/Neutral legs (I assume) AND inserting the multimeter in series with the load to measure it. I also wanted to measure the largest current I could which should result in the smallest percentage error.

Because the solar inverter has its own once-per-second voltage and current display it is easy to match calibration constants in the sketch for the solar legs and then the export legs rather than relying on additional loads and wires.

Wow, nice work! Very tidy setup. Good to hear that emonesp is working well.

Hi @CapnBry,

Would you mind sharing the code you used for the display/emonesp? Your idea looks great and I’d love to replicate it.


@sismjw Sure! It is fairly simple. All one needs to do is include the standard Arduino LCD library (LiquidCrystal.h) and then write data to the LCD when there’s serial data (src.ino):

   boolean gotInput = input_get(input);
+  if (gotInput)
+    lcd_publish(input);

Here are my two files for writing to the LCD you’ll need to add to EmonESP

1 Like

Hi @CapnBry, I am only just started using an emonTX V3 and i am very pleased with it. Like you i use an emonESP to connect it to emoncms local.
Found your post about the display for the ESP8266. I would like to ask you some details about the display you use and the connection to the ESP8266.
From the pictures i discovered it is a NewHeaven Display with code E 243002 - 1541.
Unfortunately i could not find this particular type of display. Perhaps it is no longer manufactured… Could you please give some details about it; (i assume it is a 3.3V version). Perhaps you still have the specs.
And the way you connected it to the ESP8266.
Thank you in advance,
Kind regards, Bert

Looking at the code it just uses the standard LiquidCrystal library therefore it will work fine with any two line (or more with code modification) LCD display based on Hitachi HD44780 which includes most text based LCD e.g

Hi @glyn.hudson, Thank you for your reaction! In the mean time i found some tutorials for using this display with Arduino/ESP8266.

Actually i was hoping for a small schematic how to connect them both. But looking at the code, @CapnBry is using LCD pins 4,5,12,13,14,and 16. (resp. RS, RW, D5, D6, D7 and K and 1(Gnd) and 2(Vcc)) So i he is not using I2C mode. He is using only 3 data pins and the LCD’s do know two modes, 4 bit data and 8 bit data. So i am a bit confused…

I found at DigiKey that there are 5V and 3.3V versions of these displays … so i think i need a 3.3V version. (in the specs of the controller from Hitachi i see however that the Vcc can be between 2.7 and 5.5V… but of course that applies only to the controller and not the LCD)

I have an other ESP8266 and a nodemcu lying around and would like to experiment with this before i change the code in the original ESP8266 WiFi Adapter for EmonTx.

Hi @deltabert, looks like you’ve figured it all out pretty quickly but I’ll fill in the blanks where I can.

The LCD is any generic HD44780 compatible as Glyn said, working in standard 4-bit parallel mode, and the one that I am using there is a 5V version (model NHD-0216K1Z-FL-YBW). They work fine with 3.3V signals and I am pulling the 5V directly from the emonTx to drive it and the ESP module. As you’ve seen there’s not much to schematic out, since the ESP is just hooked directly to the emon’s header, and only the LCD needs to be connected:
ESP 4 - LCD’s RS
ESP 5 - LCD’s Enable (Not R/W!)
ESP 12, 13, 14, 16 - LCD’s D4-D7
LCD R/W pin - tied to ground
LCD Contrast pin - 10k potentiometer (along with 5V/GND on other pot pins)

There’ve got to be a hundred ESP to LCD tutorials out there and this follows the same standard hookups that might give you a better idea of what to connect if you’re still unclear. I’d be happy to answer any questions I can remember the answer to though, and my emonTx + ESP LCD is still running strong with no crashes or downtime in over 2 years.

Hi @CapnBry, Thank you for filling in the blanks. I think i have enough info (also found some tutorials) so I will order a display and go experimenting with it.
It would be a nice addition to the emonTX though. Thank you for this description.
I hope when i get this working, i would like to try to extend this to a 4 x 16 display, so i can display 3 or 4 CT’s in the future. (i am planning a second solar system…)

Nice! My system is actually 4 CTs already, since I’ve got 2x CT for USE and 2x CT for SOLAR since I need to measure both legs of the 240V lines on both. If you want to modify the display for 4 lines, it is pretty easy. Just change lcd.begin(2, 16) to 4, 20 and then update lcd_updateDisplay() to display the watts data in _ctdata the way you want.

You can see my SOLAR is CT2 + CT3 and my USE is CT0 + CT1 + SOLAR currently.

Hi Bert,

Looks like the reason you couldn’t find the display was you had the manufacturers name
spelled wrong. It should be Newhaven vice Newheaven.

Ref: https://www.newhavendisplay.com/lcd-character-c-2.html

1 Like