Can only find DS18B20 on OneWire bus when on breadboard

I am trying to use the Spark Core to read from a bunch of sensors and send the data up to a webserver.

When I hook up the DS18B20 to the Spark Core on a breadboard, it works every time. However when I solder it into my circuit with a bunch of other sensors on it, I fail to find any devices on the OneWire bus. This makes me think it’s a problem with my circuit. I would love for someone to check out my schematic and look for potential problems.

Thanks!!

Edit: Corrected schematic to fix switched pH and ORP probes and to put CHG_N on D1.

Maybe your breadboard gave you some bypass capacitance that you are now missing on your PCB.
Just try some smallish caps here and there :wink:

BTW: Bottom left - have you swapped the ORP and pH probes in respect to their adapters on purpose?

Maybe your breadboard gave you some bypass capacitance that you are now missing on your PCB.
Just try some smallish caps here and there wink

Ahhh I was really hoping it wasn't something like this. Any suggestions on where I should add caps? I put caps on all the analog inputs after reading this thread. Should I add a cap to the the OneWire bus (D0)? I would like to learn a little more about hardware, but I've always hated bypass caps. They make schematics look so much more complicated than they should be!

BTW: Bottom left - have you swapped the ORP and pH probes in respect to their adapters on purpose?

Haha no I made a mistake when making the schematic, but thanks for pointing that out. Fortunately those sensors are working as expected.

@bvosk

  1. How long is your wire for the DS18B20 sensor?
  2. Where have you placed the pullup resistor on the data line? It’s always best to put the pullup as close to the DS18B20 as possible.
1 Like

@mtnscott

I’m glad you asked. It’s long! I am using this waterproof DS18B20. The pullup resistor is at the end of that long temperature sensor cable. Could that be an issue?

Did you have the same long cable attached when you had the breadboard setup?

Have you got it solved already?

I have a similar setup with the same sensor, so it’s probably not the pullup. I just noticed that on your schematic you are using D0 for the data line on the DS18B20 as well as CHG_N from your Sunny Buddy. I hope this is a typo.

1 Like

@ScruffR Yes I used the same long cable on the breadboard and it worked. I don’t have the problem solved yet. I just tried adding a .1uF bypass capacitor from D0 to GND, but that didn’t fix it.

@mtnscott That is also a schematic mistake. The CHG_N signal is on D1. I will edit the schematic and update it in the original post.

Thanks for the help guys. Anything else I could try?

Just tried connecting the pullup resistor to 3.3V* instead of 3.3V with no luck.

I also tried using a 3.3k resistor instead of the 4.7k since I am pulling up to 3.3V not 5V. This did not work either.

@bvosk, a bypass capacitor on D0 will screw up the data signal (rise/fall time) so it is not recommended. Is it fair to assume you don’t have data/GND reversed? Have you tried temporarily using another data line like D1 to test? :smile:

2 Likes

For good measure I am adding my DS18B20 code here too.

static OneWire oneWire(TEMP_SENSOR_PIN);          // Instance of OneWire class
static DallasTemperature dallasTemp(&oneWire);     // Instance of DallasTemperature class
static DeviceAddress tempSensor;
void TEMP_Init(void)
{
    dallasTemp.begin();                     // Initialize the Dallas Temperature library
    dallasTemp.getAddress(tempSensor, 0);   // Get sensor address
}
float TEMP_GetTempC(void)
{
    dallasTemp.requestTemperatures();       // Initiate conversion, wait for it to complete
    return dallasTemp.getTempC(tempSensor);
}

@peekay123 Sorry didn’t see your post as I was writing mine haha.

So I left the capacitor on D0 until I saw your post. As soon as I took it off it started working!!! So it must have been either using the 3.3V* pin instead of the 3.3V line or switching the resistor value that did it. I’m really curious which one it was, but I’m kind of terrified to move anything around now.

Thank you so much! This was my first project using a Spark Core, and I’ll definitely be sticking around. As soon as I get around to it I’m grabbing a Photon.

1 Like

For science I connected the pullup resistor back to 3.3V instead of 3.3V* and it still works. So it appears that the 4.7k pullup resistor was too large. Substituting a 3.3k worked.

@bvosk
I am using 4.7K pullup resistors. I did not see your post about putting a bypass cap on D0, that would cause problems as that cap with the pullup resistor will change the rise / fall times on the data line as @peekay123 mentions causing you not to see the D18B20.

Glad you got it working. You don’t really need to use the filtered 3.3V* line. I would save that for something that needs a solid clean voltage. Just keep it connected to the 3.3V and you should be good to go.

@mtnscott
Hmmm maybe there was just something wrong with the 4.7k I had in there. In any case thanks again!

2 Likes