Voltage readings are clipping

I’m using the emonTx Arduino shield and have modified the code to sample and record at high rates (around 1kHz, or 20 samples per waveform for both voltage and current). I’ve noticed that I’m regularly getting 5 or 6 voltage samples at the maximum 1023 value, so around 4ms of clipped data.

This can’t be doing the power calculations any good. I’m using the recommended AC to AC wall plug and unmodified EmonTx Arduino shield, so this is a bit of a surprise. My typical house voltage seems to be around 235v, although occasionally it tips over 240v. Any ideas why this is happening and what I can do to fix it?



What is the “recommended AC to AC wall plug”? You don’t say your country, as you mention 240 V, would it be the UK?

The a.c. voltage out of the adapter should be around 11.6 V (at 240 V in), the divider resistors are 120 kΩ and 10 kΩ, so giving you about 0.9 V rms (approx 2.54 V peak-peak) so it should be well inside the range for both 3.3 V supply and 5 V, even at maximum supply voltage (254 V).

Check the d.c. voltage on the adapter input socket - it should be sitting at half the supply voltage (i.e. around 512 counts with no input). If it is not, that will limit the input range.

I don’t understand this - the default sketch should be managing around 50 sample pairs per cycle anyway.

Sorry, yes, I’m in the UK, so I meant the voltage adapter available via the online shop. I’ll do some voltage readings tomorrow but I think it may be that I have a DC offset, as I think I remember seeing numbers in the 600’s with nothing connected. I’ll investigate.

The software change I’ve made is that I’m recording data at that 1kHz rate to SD Card, not just calculating and storing a single value for the previous second.

Thanks for your help,


My sums say that to just clip on the nominal mains voltage, your quiescent count would be around 760 (3.7 V), not the 512 (2.5 V) that it should be.
If you measure significantly different to 2.5 V (i.e. more than a few of percent, bearing in mind it’s a high impedance 235 kΩ source) on the a.c. adapter input with no adapter connected and with a 5 V supply, then email support at the shop and quote this thread.
If you’re not sure how your meter is affecting the voltage, measure from the input to the 5 V rail and to GND - the voltages should be sensibly the same.

OK, I’ve just found the time to do some investigation, and I think the culprit is the fact that I’m using an Ethernet Shield (for SD Card storage). With a simple read of analog pin 0, I get:

Plain board: ~246
Board + Ethernet shield: ~222
Board + EmonTx: ~510
Board + Ethernet shield + EmonTx: ~725

The 725 number is a high DC offset. Is there something I need to do to make an Arduino Uno work with EmonTx and the Ethernet Shield?

Possibly don’t use the Ethernet Shield - or at least that make of Ethernet Shield!

Without knowing exactly what the Ethernet shield is doing with the analogue inputs, it’s impossible to say. I do know that at least one make of clone uses an analogue input as a digital input from the shield, so it’s possible that’s what is happening to you. If you can find detailed information (circuit diagram with component values) of your Ethernet shield, you’d be able to confirm that. If it is the case, there are three possible solutions: Change the Ethernet shield for one that doesn’t steal an analogue input (nor anything else that the emonTx shield uses), or find out if your Ethernet shield needs that input for what you’re using it for, and if it doesn’t, cut the connection to that pin on the Ethernet shield, or cut the pin on the emonTx shield and take the voltage instead to a genuinely otherwise unused analogue input (AI 5?), and change your sketch accordingly.