AVR-DB: emonTx V4, new hardware in progress

Hello all

It’s been some time since we gave an update on what we are doing and what is coming next. There’s a lot happening behind the scenes. This post will be mostly about hardware but we’ve also moved office amongst other things.

Chip shortage

Some of you may have noticed that we are out of stock on quite a few key items in the shop at the moment. We have unfortunately been hit by the ongoing chip shortage, affecting the whole of the electronics industry.

The chip shortage seriously affects several key components that we use including the ATmega328 microcontroller, RaspberryPi’s and the chip that we were planning on using for new hardware, the STM32F303. There’s no general availability of these through standard distributors and the lead times from the manufacturers themselves are around a year. The pricing for these components through more speculative distributors are also eye wateringly high, which we don’t think would represent good value if we added this additional cost to our units.

Introducing the AVR-DB microcontroller range

The good news however is that after searching around for alternative options we found a new range of microcontrollers in the same AVR family as the ATmega328 that look very promising, both from a feature set perspective providing a welcome upgrade to the capability of our energy monitoring hardware but also on price and availability.

The AVR-DB range is the latest and highest spec 8-bit AVR microcontrollers from Microchip, launched relatively recently in mid-2020.

The AVR128DB48 is of particular interest to us are (with comparison to the current ATmega328 in brackets):

  • 12-bit ADC (4x improvement)
  • 18 channels on the 48 pin version (up from 8)
  • Higher sampling rate potential (~3x)
  • Flash memory up to 128k (4x)
  • All the usual peripheral requirements (SPI, UART, I2C etc)
  • Potentially useful PGA Op amps built in
  • Relatively low cost
  • Availability is relatively good, and we have secured the stock that we need!
  • Wide range of package types & pin counts.
  • Arduino compatible core called DxCore

These features provide many of the key benefits that we were hoping to get from using the STM32 range, in particular the 12-bit ADC, larger number of analog channels and a higher sample rate. That said the AVR-DB has still only a single ADC multiplexed to a large number of input pins and so does not allow for simultaneous sampling across voltage and current channels which was a nice feature of the STM32, but it’s also hard to say how much difference that would make in practice and is it worth the higher price of the STM32 chips?

The lack of availability of the STM32 chips mean we don’t have much choice in the short term, but it’s certainly something to consider in the longer term.

A large plus for the AVR-DB range over the STM32 range is compatibility with our existing firmware developed for the ATmega328, In particular Robert Wall’s latest CM (Continuous Sampling) firmware using the native RFM69cw driver code. The modifications to make this firmware work on the AVR-DB is small. The familiarity provided by the hard work of Spece Konde on the DxCore for the Arduino IDE is also a huge plus for us and other open-source contributors. Combining the use of the DxCore with the modified low level commands for continuous sampling in the EmonLibCM library provides the best of both.

We’ve actually gone ahead and ordered, and received enough stock of a combination of AVR128DB48 and AVR128DB32 chips to see us through the next 18-months or so.

We are also well on our way on the design process for using these chips, with successful testing of these chips and new emonTx, emonPi and emonTH board designs in progress.

Ultimately, if all goes well we expect to have the new units in stock in ~3-4 months time, mid to late July 2022. In the meantime, we have more stock of our current emonPi units on the way in a few weeks.

Voltage output CT sensors

The new versions of the emonTx and emonPi will feature many of the same improvements that we were intending to implement with the STM32 development, which are in many ways more important than the microcontroller itself for the overall accuracy and general functionality of the system.

The first change is to support 333mV voltage output CT sensors. This is probably the most widely used type of CT sensor. There are many manufacturers, current ranges and accuracy ratings. By switching to this voltage output standard it’s much easier to select the right CT for the application and there’s no need to change the burden resistor on the circuit board to use different CTs.

Precision voltage sensing

The second key change will be to upgrade to using a ZMPT101 precision voltage transformer for higher accuracy AC voltage sensing. The current use of a standard AC output power adapter is the largest source of error in our system, so upgrading this part will provide the greatest gain in measurement accuracy.

The precision voltage sensing unit will be an external unit that plugs into the upgraded emonTx/emonPi and will also include an integrated power supply module so that only a single socket is required. This unit will also have the option of being hard-wired for a fixed installation and full three-phase monitoring.

Precision reference

The third key change is to use a precision voltage reference chip to increase the accuracy of the ADC conversion.


Overall with the above combination and careful selection of other components in the system it should be possible to get to a maximum error for an uncalibrated system in the 1-2% range, the realistic error is better still if you applied a monte-carlo analysis of likely component tolerances. This will provide a significant upgrade to the out-of-the-box accuracy of our units.

Over the next set of posts I will outline what’s new on the new hardware designs and then continue to give updates on progress as they are tested, and we get them ready for production.

Here are a couple of pictures of our new office in the meantime. We have a unit in a really nice community building near Llanberis in North Wales, there’s an onsite cafe that does really good food, cakes and coffee, we are nearer the mountains and walking distance from where we live which makes it all a lot more convenient. If you are in the area and would like to drop in to say hi, please get in touch!


emonTx v4

The first set of emonTx v4 prototype PCB’s have arrived. Here’s a picture of the first assembled board, testing in progress!

Key features

  • Micro-controller: AVR128DB48 (VQFN 128 kb flash, 48-pin package)
  • 3 voltage channels (via RJ11 connector top-right, interfaces with separate voltage sensing board)
  • 5 CT current channels on the base board. [Edit: Subsequently extended to 6 in post no.50 (RW)]
  • Option to extend the number of CT channels to 11 12 via an additional extender board.
  • Precision voltage reference for the ADC to improve accuracy.
  • RJ45 socket for pulse counter and DS18B20 temperature sensing.
  • 3x 3-WAY pluggable terminal blocks for selectable temperature sensing, pulse or additional analog input.
  • RFM69CW 433MHz radio transceiver
  • DIP Switch to select node id
  • USB-C power and integrated CP2102 usb to serial chip
  • Serial and SPI pin headers designed for ESP8266+I2C LCD based shield module (more details soon).

The dimensions of this board are slightly smaller than that of the emonTx v3 at 65mm long rather than 80mm this provides a proportional saving on the cost and material requirements for the aluminium enclosure, which goes part of the way to offset the additional cost of some of the additional components on the board.

The board is designed to support both single and full 3-phase electricity monitoring when used in conjunction with the relevant external voltage sensing board. And the CT extender pin headers should provide a cost effective way of gaining additional CT channels.

The on-board USB to serial chip will make it easier and neater to have a hard-wired installation linking the emonTx to a RaspberryPi based base station.

Here’s a picture of the VQFN AVR128DB48 which was fun to solder on our new Andonstar 407 microscope (Review by the Thrifty Tool Shed: https://www.youtube.com/watch?v=_QamUtQci7c) :


Looks GOOD!

thumbsup highfive beer_cheer

1 Like

Thanks @Bill.Thomson much appreciated!

Yeah, yeah, yeah. But how much are they and when can I buy one?? :grinning:


If all goes well, it should be available mid to late July. Target is to bring in at a similar price to the current emonTx. The AVR-DB costs about the same as the Atmega328’s did cost when they were cheap. The board size and enclosure is a little smaller and there are more SMT components and less hard to solder through-hole which should help reduce assembly costs. There are however a few more connectors and the CP2102 and precision reference are additional costs. We haven’t yet submitted the design to our CM for a quote but outline costing from the BOM using octopart is promising…

Will the TX power the Pi as you can do currently with the serial link?

The other thought, is there room for a PiZero inside the case? If so, could holes for a mounting point be squeezed in?

Looks great :grinning:

1 Like


In the present design the external voltage sensing board and power supply is providing 3.3V and currently only enough power for the micro and an ESP8266. The Pi would in that case need to be powered seperatly. We probably need to reconsider that for a future revision and perhaps just have a 5V PSU module in the voltage sensing unit and route 5V all the way through to the USB-C. I will put that higher up the list to consider.

Edit: There may need to be different versions of the external voltage sensing and power supply unit with different power output ratings. As I understand it from advice from the company we do EMC testing with some of these AC-DC power supplies do not always provide a low noise environment when lightly loaded so careful selection in relation to the load is needed. That will mean a PCB that can accommodate different ratings of PSU Modules.

We did discuss but felt we were at risk of over complicating things at this stage. It would also likely be difficult to get the Pi Zero in there as well as the CT channel expander, due to the obstruction provided by the other connectors on the board limiting the location that a Pi Zero could fit. Probably best to focus on getting 5V out on the USB-C and having the Pi Zero mounted externally.

So is the USB-C powering the TX, or just for data out?

As an either/or option? At least having the holes for the PiZero would provide the option. I’m thinking there would be a very small group that might want both :slight_smile:

It’s for data out (though it could power the unit if needed).

Yes that could work and it would be a neat option. It might not be on the first version due to time constraints but certainly would be worth looking at for future versions. It is something Id be interested in too.

1 Like

Yes it would. Personally, I really like the PiZeroW/EmonTX combination. Best of both worlds IMHO.

1 Like

emonTx v4 (left) vs v3 (right) enclosure size, it’s getting smaller! feels nice and compact :slight_smile: thanks to @glyn.hudson for ordering and https://lincolnbinns.com for very fast delivery of the sample:


This issue with the Pi Zero is there is a 1 unit per customer limit which is mandated by the Raspberry Pi Foundation, so it would be impossible for us to sell a unit which contained a Pi Zero.

Presumably, you will be looking for a “universal” voltage input (100 – 255 V), I don’t think any changes will be needed for 110 or 120 V sensing, i.e. the sensing input should be rated and linear up to not less than 255 V, and I’d expect more than adequate performance down to 100 V.

Yes, the AC-DC power supply modules support that and as you say the voltage sensing should work fine across that range.

Yes, agreed and no change to the current situation. But if the mounting was all there it could easily be sourced by the recipient.

I’m not sure what is currently on the enclosure, but can the version be clearly identified from the outside, please? A version label perhaps?

Yes that will certainly be on there


Looking good! Now I need a reason to upgrade from my v3!

The extra CT’s could be useful though!

1 Like