Analog pin outputs 1.7v when set to input?

What does your voltmeter say the voltage is on the Spark input pin/TMP36 output when you are running your program reading it?

I’ll bet it is near to 0.97V.

I know the Q isn’t addressed to me but: I don’t have a voltmeter :smile: Given that I’m using (almost exactly 3,3 vs 3.28) the formulae advised, and (almost exactly - cap placement could be better) the circuitry advised, and I get correct temperature readings, why do I care what the voltage is? :slight_smile: [I’m a programmer playing with electronics, not an engineer playing with programming]

@bko - actually - and this is what bugs me - it’s 0.75.

Below is the picture of the circuit; the code is now very simply this:

int testpin = A1;
int testPin(String args) {
return analogRead(testpin);
}
void setup() {
pinMode(testpin, INPUT);
Spark.function(“test”,testPin);
}
void loop() {
}

This is the output of curl, taken while the multimeter was attached.

{
“id”: “48ff74065067555046481287”,
“name”: “scraper_hamster”,
“last_app”: null,
“connected”: true,
“return_value”: 1181
}

Ok, I flashed your code into one of my cores over-the-air. This core has a fixed resistor divider on A1 to test the ADC. The A1 pin reads 0.961 V and my 3V3* which I used for the other end of the resistor divider reads 3.304V so the perfect answer would be 1191.06 or 1191 on the ADC. When I read this via Spark function, I get 1191, which is correct. So I added a Spark.publish() call just in case and that also reads 1191, which is correct too. Sometimes these are +/- 1 as you try it many times.

I see in your picture you seem to be using the 3v3 pin not the 3v3* pin which has some filtering on it. That is the third pin in on that side (right side in the photo). Maybe you could try that?

Also, do you think your power to the core is a good solid supply? When the core uses the radio for WiFi, it does draw some power.

@bko - powering from 3v3* has the same effect; I am powering it from the USB on my computer while it’s hooked up to the mains - so it should be fairly stable.

If the power was noisy or unstable, shouldn’t that have the exact same effect on the multimeter as it does on the ADC?

Thanks!
Nir.

Replying to myself for a bit - I just tried the 0.2.0 version and it doesn’t help much…

I still am getting readings consistently 0.2v over what the multimeter reads (and I sprinkled caps between pins 1 and 3 of the TMP36, and between my input pin and GND, as well as added a pulldown resistor between my input pin and gnd).

Anyone else still encountering the same?

I think you should try a fixed resistor divider with any values you have in the range of about 1k to 10k and see how that works.

You might also try a different multimeter, just in case, but that is a long shot.

1 Like

@bko - thanks for the tip.

I used 2 10kohm resistors and fed it 3.3v - as expected, the multimeter reads 1.61v (which is roughly what it should be if I understood what I read about voltage dividers :slight_smile: )

Spark core read 2560 which is apparently ( again , maybe I’m wrong) 2.06v

Once again there’s an offset.

I did however test it with another spark core I had on hand - and it would seem that one operates correctly and the other does not. I am curious what’s the right way to debug the component on the board. Maybe one of them has a faulty component.

Nir.

Hi @TheNirEast

The analog inputs go directly into the STM32 ARM, so there is a not lot to debug.

Did you measure your 3v3* pin? That is the analog reference and if that is wrong then things could be off.

1 Like

I did; it was OK - but I’ll check again when I get a chance. It was always perfectly 3.3 when I checked, but given that I’ve probed the damned thing so many times it might get mixed up in the fog of war :smile:

Thanks!

@bko you were right, it outputs 3.0v, the 3.3v pin outputs 3.3v but it still doesn’t work that way.

It did get me thinking though - if the filtered/regulated 3.3v pin is outputting 3.0v, does that mean that somewhere on the core a reference voltage is out of whack?

any probes I can stick anywhere to test? It must mean I have a damaged board somehow, just curious where.

Hi @TheNirEast

Yes, something is wrong if your 3v3* pin reads 3.0V. Mine reads just under 3.3V like 3.287V typically. It could be the voltage regulator or the 3v3* filter parts (see below) or it could be the USB or other supply you are using for the core not supplying enough current. You might want to try another USB supply that you know is good, just to be sure.

The schematic for the core is here.

There are three small components between the 3.3V supply (which measured OK for you) and the 3v3* pin:

  • C13 a 100nF cap to ground
  • C15 a 10uF electrolytic to ground
  • L2 a ferrite bead in series

If it is not your USB supply, then I am thinking it almost has to be the ferrite bead but you never know. I think if you are sure the core hardware is messed up, the Spark team will exchange it for you!

it’s probably not the USB supply, since the same set up with the same power supply and the same circuit yielded completely two different results with two spark cores.

Readings are off even if I feed the sensor from 3.3v (and there’s a cap to filter out noise on the way out) - so I’m curious to know if 3.3v* feed is somehow fed back into the core as a reference voltage.

Hi @TheNirEast

The primary purpose of 3v3* is to provide the ADC reference level to the STM32. The secondary purpose is to provide a clean output for users. The filtering is required to get good ADC readings and it is convenient for user purposes too.

Thanks @bko!

ah, so definitely if the 3.3v* output is jacked, then the ADC will be off - even if I feed my sensors from a completely different power source. That’s very good to know. would explain all the issues I had with analog readings. I just seem to have a bum core somehow.

I’ll test what I can on the core and report back - I hope that mine is a one off and there wasn’t a bad batch - otherwise that would explain the offset analog readings many other people on the forum had.

Hi @TheNirEast

Regarding the past problems: There were firmware problems with analogRead(), but those were fixed a few weeks ago and I think things are fine now. Further back in time, the ADC was set to sample as fast as possible and that made it’s input impedance low, especially compared to Arduino. This is really a limitation of the STM32 and has improved dramatically since the firmware was updated to not sample at the maximum rate.

If you are using the ADC with sensors that have 10Kohm impedance or less, you should be fine. Above that, things start to degrade and more external components are needed.

I think that @Dave or @Steph could help you return the defective core, if you feel it is just plain broken.

2 Likes

Yup! Please feel free to email us at hello@spark.io if you think your core is defective, we’ll be happy to help!

Thanks,
David

@Dave , it seems to be foobared a little bit. 3.3v* is outputting 3.14v - before shipping it back though I want to figure out where I should be putting probes in - but the schematics sadly don’t detail WHERE the components are. Any thoughts?

Nir.

Just 3.3v* to ground will do.

If you want, you can locate the circuit for 3.3v* and measure the output. But I don’t think it’s going to affect much.

Im just curious what you get on the 3.3v pin to ground? Haven’t checked the schematics but the 3.3v* should just be from 3.3V but extra filter.

Let me get home and see the schematics :slight_smile:

@zachary i can’t find the 3.3V* in the schematics. am i missing something?

1 Like

Good questions @TheNirEast and @kennethlimcp. If you select the 3V3* pin in the board layout, you’ll see the signal is named VDDA. You can find VDDA in the schematic near the top right, in both the “STM32 Power” section and the “STM32 Decoupling…” section. It’s pin 9 of the STM32.