Help trying to read voltage using analogRead

I am trying to read the temperature signal off a “smart” electric kettle that conveniently uses a 5V-powered microcontroller. I found the wire that goes from the kettle’s temperature sensor to the input pin on the kettle’s microcontroller. I soldered an extra wire to the temp sensor input wire and ran that to A0 on an Arduino.

I verified with a voltmeter that my new wire’s temperature signal starts at about 0.3V with room temperature water and increases to a maximum of about 3.1V when the water’s at 212 degrees F. Awesome.

At this point I just needed to read that voltage with an Arduino. This is where I ran into something I still don’t understand, and why I need some help here.

I set up the following sketch in Arduino to just take an analog reading, without converting it to voltage or anything yet:

const int tempSensorPin = A1;
int temp = 0;

void setup() {
pinMode(tempSensorPin, INPUT);
Serial.begin(9600);
}

void loop() {

long tempSensorReading = 0;
int i=0;
for(i=0; i<10; i++){
tempSensorReading = tempSensorReading + analogRead(tempSensorPin);
}
tempSensorReading = tempSensorReading / 10;

Serial.print(“Unfiltered Temperature Signal:”);
Serial.println(tempSensorReading);
delay(10);
}

And this gave me the following:

Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:83
Unfiltered Temperature Signal:295
Unfiltered Temperature Signal:1023
Unfiltered Temperature Signal:989
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:65
Unfiltered Temperature Signal:223
Unfiltered Temperature Signal:1023
Unfiltered Temperature Signal:966
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:32
Unfiltered Temperature Signal:155
Unfiltered Temperature Signal:1023
Unfiltered Temperature Signal:959
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:13
Unfiltered Temperature Signal:78
Unfiltered Temperature Signal:632
Unfiltered Temperature Signal:1023
Unfiltered Temperature Signal:904
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:0
Unfiltered Temperature Signal:8
Unfiltered Temperature Signal:2
Unfiltered Temperature Signal:90
Unfiltered Temperature Signal:505
Unfiltered Temperature Signal:1023

This looks nothing like the constant DC signal I was expecting, and what I thought I was reading with the voltmeter. At first I thought it might be a PWM-type or frequency-modulated signal, but I checked that by letting the kettle boil water again, and the signal doesn’t change at all as the water goes from room temperature to boiling.

Can anyone tell me why I might be reading a normal DC voltage that responds to the temperature with the voltmeter, and this fluctuating signal that does not respond to the temperature when I connect it to an Arduino and run this sketch? I am at a loss, would appreciate any help or suggestions. Thanks, all.

-Jimmy

Hmmm...

it's probable that you kettle's electronics -ve isn't at ground potential - and so the arduino is seeing the sensor's out plus a lot of 50/60Hz noise.

If you're powering the arduino via a USB this will give you the effects you see - the host PC will make the arduino's -ve == safety ground.

not that easy to fix...

regards

Allan

Small appliances like that are most likely using a capacitive supply.

That means that all the electronics are directly connected to mains voltage.

Leo..

Thanks for the quick replies... it's working now, kind of. Looks like the USB was the culprit, although I could use some help understanding why, exactly.

So I can't read the signal while connected via USB and have it work, but I just tried powering the Arduino via adapter, and added a line to my sketch to output what I read on the input line to A0, to which I connected a LED and my voltmeter, and bam, the light gets brighter as the water boils, and the voltage increases smoothly from about 1.0 to about 2.4V as the water boils, which makes it usable enough for my purposes.

Now my question has become why are the values different after going in the A1 pin and out the A0 pin?

For example, with room temperature water, the input to A1 reads 0.3V, and the output to my LED reads 1.0V.

Did you understand the dangers of a capacitive supply?

You might kill someone else.

Post a picture of the kettle board, so we can see if it's a capacitive supply or not.
Leo..

You are correct, it is a capacitive supply. I read this about them, and I understand that it does not provide isolation from the mains - what is the best means of isolating my Arduino from this supply? Schottky diode for the temperature signal?

I am also controlling the on/off signal for the kettle’s heating element relay via arduino + mechanical relay (simulating a switch). I plan to add an optocoupler to isolate this part.

The power supply itself is enclosed in its original housing. I was considering adding a fail-safe relay to cut power to the whole shebang given specific triggers, but that may be a little extreme. Also, as you suggested in response to my previous posting, enclosed circuitry/plastic covered switches will be used as another safety measure. I am open to any and all suggestions, especially regarding safety. Link to my previous posting is here. Is this is just a bad idea because there’s no way to safely isolate my low-power circuit from this capacitive supply in case of its failure? I don’t believe that’s the case given correct selection of diodes/optocouplers, but that’s of course assuming I do that right, and I would appreciate any help there as well. Absolutely let me know if I’m missing something here, please.

Also, any thoughts on the 0.3V vs 0.8V difference? Thanks yet again.

James