Inaccurate Analog readings due to WiFi power

@Peter @Hugo

I am trying to read temperature and light levels using a TMP36 and TDR connected to pins 5 & 7 on an IMP. I have been getting inconsistent results (light and temperature readings significantly too high) under certain conditions and have been unable to resolve the issue.

The device is fairly complex including a (dynamic) high level rules engine interpreting rules stored in a 2 dimensional array, and based on ON/OFF times, ALARM times, Light and Temperature levels controlling 8 Solid State Relay outputs connected to fans, lights, chargers etc.

In the course of my research I came across a similar problem on the Spark Core ( see discussion at ) with the general conclusion pointing towards very short but significant variations (ripples) in the 3.3V supply (as a reference) due to the fluctuating current draw during WiFi transmission.

The voltages are measured using a sampler configured at 3kHz for 2 channels and supplied with 3 x 6kByte buffers. The 1500 samples/channel returned in a buffer is averaged and used to calculate the voltage (using hardware.voltage()) as reference.

On a hunch I added server.disconnect() & imp.sleep(0.020) statement immediately before starting the sampler and a server.connect immediately after stopping the sampler. The results were immediate and consistent.

The temperature reading immediately dropped from 40C to 34C and the light readings from 80% to 72%, and remained there consistently over a 2 hour period. The 34C, although still fairly high for a summers day in sunny South Africa, is a lot closer to the reality which should be about 30C

Any chance that the theory is correct since practically it has been proved?


Apologies, should be LDR not TDR

Is your power supply capable delivering enough current?

Should be fine, rated at 800mA, works well charging an iPhone or iPad…

There are a couple of possible things here: one is RF coupling from the antenna onto your circuits, the other is the current causing the ground reference to rise with relation to the external components.

An SD socket is not ideal, so eg if it had 100mohm resistance in the ground path you could see 25mV swing of “ground” very easily during a wifi transmission. This also affects the top end as there’s only one power pin, so that’ll change the full scale range of the ADC.

Using a solder-down module alleviates these supply issues, as does averaging for a while when there are not transmissions going on (disconnecting is a pretty big hammer, and may well not be required depending on what you’re doing… a few log messages can cause issues though!)


I am already using an average of 1500 readings per pin in the sampler buffer, and the the sampler is scheduled to run for about 2.5sec every 30 seconds, but the results are consistently high…

As I said, are you logging or anything around that time?

Consistently high would make sense generally, see my comments above. When the imp draws current, it will sample high both in absolute terms (ground shift) and relative terms (full scale range compression).

This is why socketed devices are not great in that situation.

I have used a TMP36 with the electric imp too, it was quite close to my multimeter with thermocouple, but it was also unstable, it could jump 1-1.5c up or down, then go back to where it was before. Didn’t find a fix for it, except I just started doing some averaging of the results.