Trying to read ds18b20 on A5

I’m trying to make a shield that can read a ds18b20 using a Spark Core (using a shield shield) OR a Mega as the microcontroller. On the shield we are using the ds18b20 is routed to pin 11 on the arduino, which is then translated into pin A5 on the spark core using a shield shield.

Q1 - I understand that the analogue pins can still read as a digital pins? - does this mean we can read the ds18b20 on A5?
Q2 - A5 should only receive 3.3V? (looking athttps://community.spark.io/t/one-awsome-pinout-diagram-for-spark-core-located/3361) Does this mean that the pwr line should be limited to 3.3v or can the A pins also take 5V (and if they do get 5V and they can’t read it - will it fry them?)

Why don’t you connect the ds18b20 directly to the spark core instead?

There’s not much reason to pass it through the logic level converter i think…

but you will need a digital pin that is 5v tolerant in order to do so: http://docs.spark.io/hardware/#spark-core-datasheet-pins-and-i-o


Qn1 - yes you can use it like a normal digital output using pinMode() but i’m not sure whether both output/input is required.

The level converter might interfere with the 1-wire communication so you would have to test out.

Qn2 - seems like 3.3V is the minimum required Vdd voltage to power the ds18b20 but i’m not sure if the performance is the same.

A5 is not a 5v-tolerant pin so it should not exceed that voltage. (see above)

It’s got to do with the pinout that the Arduino boards are using. Essentially the shield allows people to plug in an Arduino or the spark core.

I’m breadboarding to get it working, as all I’m reading atm is -127…

is the code I’m using if you have any idea?

thanks for your help!

As I read your sketch you are using the A5 pin for the LCD and D2 for the OneWire anyhow.
If you go for D0,D1,D3…D6 instead you’ll be good with 5V, too. But 3.3V should just be fine, as the datasheet I’ve looked at suggest Vdd min as 3.0V.

And as for plugging in an Arduino, you’d just need to have that Arduino programmed accordingly, then you’re good again.

Or what shield are you using, have you got some details?

1 Like

Yeah, it just has a relay for a pump, some button inputs and LCD pinout. It’s a custom one. Just working out where to pin out the ds18b20 to.

Ok, so in the code posted I’m just breadboarding trying to figure out why I was getting a -127 reading. So i’ve swapped the A5 and D2 pins. But I’m getting -127 on both pins. I was wondering if it was using the A5 pin that was the problem or the shield shield or something else. But it looks like there is an issue reading the probe. Any idea why?

Have you got any possibility to test the sensor without the Shield shield - possibly on a 5V tolerant pin with 5V supply first, then stepping down to 3.3V supply and communication?

When you hit a wall of possible problems, try to eliminate as many bricks as possible and the add one after the other till you find the culprit :wink:

1 Like

Yeah, the sketch above is aiming to do that. That’s why I moved the pin to D2 as it is 5V tolerant. I started with the shield and have moved backwards trying to eliminate complexity - the above sketch is for a breadboard with a power supply that allows each rail to be switched between 3.3v and 5v. That said, I think I’ve only tried it with 3.3V so far. I’ll try with 5V.

The temp probes read properly with an arduino sketch, so I know they work fine.

Does the code look like it should read the temp?

I think the shield-shield has problems with open-collector/open-drain signaling like the DS18B20 uses.

Can you try with the 3.3V supply and no shield-shield on any pin?

I have a couple DS18B20’s that work fine with the Core.

Hi bko,

That is interesting. So maybe it won’t be possible to do it using the shield-shield? That would be frustrating.

Even so, I have tried with everything breadboarded and no shield-shield - just pins using 3.3V. I keep getting -127.00, hence my question if the code ‘should’ work. I’m assuming that all ds18b20s are the same and there isn’t some ‘gotcha’ that I need to be aware of?

I need a new battery for my multimeter, but will try it again tonight

So I haven’t used the Spark-dallas-temperature library, I just rolled my own from the one wire library. Feel free to steal code from my time and temperature tutorial code here:

Just to save you some grief - don't us D2 since it's NOT 5V tolerant, as I've suggested above already.
See http://docs.spark.io/hardware/#spark-core-datasheet-pins-and-i-o

The Spark Core offers a total 18 I/O pins to the user: 
D0 to D7, A0 to A7 and two pins that are preset to serial - TX and RX. 
All of these I/O pins run at 3.3V and the user should keep this in mind before attaching any external peripherals to them. 
The only exception to this are the following pins that are tolerant to 5V inputs:
D0, D1, D3, D4, D5, D6 and D7

I've avoided to suggest D7 since the attached LED might interfere with OneWire.


As for the possible problems with the Spar Core Shield shield, you might like to hear that this issue seems to be addressed with the Spark Photon Shield shield, which should be compatible with the older Core one, but without (or with less :wink: ) gotchas.

Thank you! I’m glad I didn’t run 5V through it. Funny, I did NOT read that carefully enough, read it as D0-D7. Thank you again!

You know what… http://www.reuk.co.uk/wordpress/ds18b20-temperature-measurement-with-spark-core/ says 4K7 across power and gnd… facepalm. Should be 4K7 across Vdd and Dq.

My thanks for all your help, and apologies. It works just fine now on both D6 and A5 @ 3.3V.

2 Likes

ok - can confirm that I can read temp fine with breadboard, but the spark core shield shield will not let me read and I get a -127 value.

ScruffR - do you know what the issues are that have been fixed and when the new shields are available? I’ve pre-ordered a couple of photons with new shields…

edit - oh, and I tried 5v volts on A5 and it read fine(using the breadboard)… I tried as I knew I had run 5V through it before at some point when didn’t know I wasn’t supposed to and it still seemed to be working reading on 3.3V. Could it actually be 5V tolerant, or would it burn out in time?

@lael, as for the new Shield shiled there is a thread here

and I guess @mohit would be the person to ask about your particular issue, if this will be fixed on the new one.

As for the A5 5V-tolerance, I’m pretty sure it’s not, but you could have been lucky or you only frazzled the ADC part of it :worried:, which would not show on a digitalRead() test.
But if it is in perfect condition now, you should not need to worry about after effects of this - just don’t do it again :wink:

@ScruffR - Thanks!

Is there a simple test to check ADC on pin A5?
and… I won’t do it again :slight_smile:

A simple voltage divider and analogRead(A5) should give you a clue.

e.g. 2k2 and 4k7 across two other pins which you set via digitalWrite() HIGH and LOW in all four possible combinations should give you four readings, where the two “middle” ones are the most interesting ones.