EmonTx4 firmware release 1.5.7 is now available. Providing improved temperature sensing support, mitigating most of the observed interference with electricity monitoring. The following posts discuss:

- The observed effect, comparing firmware versions up to 1.5.4 with 1.5.7.
- The mechanism behind the error.
- The improved implementation in firmware version 1.5.7, which based on modelling of the code, reduces the introduced error to ~0.04% with 3 temperature sensors or 0.07% with 6 temperature sensors.
- Plans to improve the implementation further with future hardware.

Version 1.5.7 of the EmonTx4 firmware is now available via the emonPi/base firmware updater tool or if you prefer to compile and upload yourself the firmware can be downloaded here: emontx4/firmware at main Ā· openenergymonitor/emontx4 Ā· GitHub

**Make sure to either run a full emonPi / emonBase update before uploading the firmware, or using the emoncms > admin > components update tool, update EmonScripts.**

**Part 1: The observed effect**

When I first ported the emonTx3 continuous sampling firmware using @Robert.Wallās emonLibCM library to the emonTx4, I was unaware that temperature sensing with DS18B20 temperature sensors would interfere with the continuous sampling electricity monitoring firmware in a small but noticeable way. I noted the effect in the emonTx4 documentation earlier this year here: https://docs.openenergymonitor.org/emontx4/other_sensors.html.

**Example of impact on measurements with the original implementation (EmonTx4 firmware versions up to and including 1.5.4, with 3x temperature sensors connected)**

In this example I have an emonTx4 with 3x DS18B20 temperature sensors connected and 3 CT sensors, plugged into CH1, CH3 & CH5. The load is a 3kW heater. CH2, CH4 & CH6 do not have CT sensors connected, yet they are registering up to 4W of consumption, a 0.13% error.

```
{"MSG":18,"Vrms":241.22,"P1":3100,"P2":3,"P3":3102,"P4":2,"P5":3103,"P6":3,"E1":23,"E2":0,"E3":23,"E4":0,"E5":23,"E6":0,"T1":20.37,"T2":20.50,"T3":20.87,"pulse":0}
{"MSG":19,"Vrms":241.10,"P1":3096,"P2":3,"P3":3097,"P4":2,"P5":3098,"P6":4,"E1":31,"E2":0,"E3":31,"E4":0,"E5":31,"E6":0,"T1":20.37,"T2":20.50,"T3":20.87,"pulse":0}
{"MSG":20,"Vrms":241.17,"P1":3095,"P2":1,"P3":3096,"P4":2,"P5":3098,"P6":3,"E1":40,"E2":0,"E3":40,"E4":0,"E5":40,"E6":0,"T1":20.37,"T2":20.50,"T3":20.87,"pulse":0}
```

With no load, an error appears only on CT6, we can see here an error again of ~4W:

```
{"MSG":2,"Vrms":244.59,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":2,"E1":0,"E2":0,"E3":0,"E4":0,"E5":0,"E6":0,"T1":20.37,"T2":20.50,"T3":20.87,"pulse":0}
{"MSG":3,"Vrms":244.53,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":4,"E1":0,"E2":0,"E3":0,"E4":0,"E5":0,"E6":0,"T1":20.25,"T2":20.50,"T3":20.87,"pulse":0}
{"MSG":4,"Vrms":244.60,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":3,"E1":0,"E2":0,"E3":0,"E4":0,"E5":0,"E6":0,"T1":20.37,"T2":20.50,"T3":20.87,"pulse":0}
```

**Example of measurements with improved implementation in the 1.5.7 firmware release:**

As above, emonTx4 with 3x DS18B20 temperature sensors connected and 3 CT sensors, plugged into CH1, CH3 & CH5. The load is a 3kW heater. CH2, CH4 & CH6 do not have CT sensors connected. They are now registering 0W correctly.

```
{"MSG":12,"Vrms":241.85,"P1":3107,"P2":0,"P3":3105,"P4":0,"P5":3105,"P6":0,"E1":63,"E2":6,"E3":60,"E4":9,"E5":58,"E6":11,"T1":20.37,"T2":19.87,"T3":20.37,"pulse":0}
{"MSG":13,"Vrms":242.36,"P1":3116,"P2":0,"P3":3114,"P4":0,"P5":3117,"P6":0,"E1":71,"E2":6,"E3":69,"E4":9,"E5":67,"E6":11,"T1":20.37,"T2":20.00,"T3":20.37,"pulse":0}
{"MSG":14,"Vrms":242.87,"P1":3126,"P2":0,"P3":3126,"P4":0,"P5":3128,"P6":0,"E1":80,"E2":6,"E3":77,"E4":9,"E5":75,"E6":11,"T1":20.50,"T2":20.00,"T3":20.37,"pulse":0}
```

With no load, CT6 is also showing 0W correctly:

```
{"MSG":27,"Vrms":242.50,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":101,"E2":6,"E3":99,"E4":9,"E5":97,"E6":11,"T1":20.62,"T2":20.25,"T3":20.50,"pulse":0}
{"MSG":28,"Vrms":244.34,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":101,"E2":6,"E3":99,"E4":9,"E5":97,"E6":11,"T1":20.62,"T2":20.12,"T3":20.50,"pulse":0}
{"MSG":29,"Vrms":244.70,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":101,"E2":6,"E3":99,"E4":9,"E5":97,"E6":11,"T1":20.62,"T2":20.12,"T3":20.50,"pulse":0}
```

I will dive into the mechanism behind the error in the next post.