YANP (Yet Another Noob Post) DS18B20 1Wire Probe

Hi everyone, post #1 here (obviously).

I am seeking help for a problem which is likely very simple but I keep missing it for some reason.

I have spent most of my career in IT on the network and infrastructure side of things, and just recently got into Home Automation, IoT, SBCs, etc. which takes me here on my journey.

I have an ambitious (for me) project of automating Aquarium maintenance based on the output of several sensors (pH, temperature, TDS, water level, etc.)

I have to start somewhere so trying to set up the Water temperature sensor.

My HW:

  • Arduino MKR WiFi 1010 Board
  • DS18B20 Waterproof 1wire temperature probe
  • 4.7kOhm resistor
  • Breadboard and jumper wires

SW enviroment

  • Arduino IDE 2.3.4 on Win11
  • Latest Onewire library
  • Latest DallasTemperature library
  • Board firmware upgraded to 2.0

I have everything wired up as per examples and recommendations, yet, no dice­.

I am powering up the probe with 3.3V from the board, GND is connected, DataPin also connected to the board, 4.7kOhm pull-up resistor between 3.3V and Data (DQ) pin.

Using a multimeter, I can measure up 3.3V between power and GND pins on the probe, and between DQ and GND. I can measure the 4.7kOhm resistance between DQ and PWR pins as well.

The board does not seem to detect the probe and the reading is a consistent -127C. Also querying the wire for the number of connected probes returns 0.

I have tried switching wires for Data pin (and update the code appropriately), changing physical probes, solidifying connections and contacts, yet it just won't work.

I've been at it to make it work for some time now and thought I`d seek help before giving up and just crawling into a hole.

Here is the code I am using. (DQ connected to pin 5 and VCC on pin 8)

#include <OneWire.h>
#include <DallasTemperature.h>
int numberOfDevices = 1;
// Broche DQ du capteur = 5, DC 3V3 = 8
#define ONE_WIRE_BUS 5
const int BrocheVCC = 8;

// Créer un objet OneWire
OneWire oneWire(ONE_WIRE_BUS);

// Passer l'objet OneWire à Dallas Temperature. 
DallasTemperature sonde(&oneWire);

void setup() {
  // Initialiser la communication série
  Serial.begin(9600);

  // Démarrer la librairie de température
  sonde.begin();

  // Alimenter la sonde
  pinMode(BrocheVCC, OUTPUT);
  digitalWrite(BrocheVCC, HIGH);

  
}

void loop() {
  // Demander aux capteurs de mesurer la température
  sonde.requestTemperatures(); 

  // Afficher la température en degrés Celsius
  Serial.print("Temperature : ");
  Serial.print(sonde.getTempCByIndex(0)); 
  Serial.println(" °C");
// Grab a count of devices on the wire
  numberOfDevices = sonde.getDeviceCount();
  Serial.print(numberOfDevices);
  Serial.println("  devices found"); 
  
  delay(1000); 
}

I appreciate any help anyone can provide.

Thanks,

Hugo

Hi Hugo,

Did you try an example sketch from the Dallas Temperature library?

That is an error code

#define DEVICE_DISCONNECTED_C -127
  1. recheck your wires
  2. connect the DS18B20 to a real 3.3V pin as the IO pin might not be able to provide enough current?

I will try that. Though I am getting 3.3V reading on the multimeter.

Téléchargez Outlook pour iOS

Be aware the current may peak when conversion starts.

Hi Paul, yes I did, same results. Leaning towards unstable wiring, especially around the threaded probe wires and the resistance/breadboard.

What is generally recommended for parts like these? Alligator clips?

You can also get male crimp pins which are ideal for breadboard use.

Awesome tip!!! Thanks Paul!

Well thanks for giving me the confidence to push forward. I redid all of the connections, secured the resistor, was still getting the same results.

I moved the power to the 5V pin and instantly started getting temperature readings.

I’ll have to dig deeper into why that isn’t working but for now, at least I can push forward on my project.

Thanks guys.

Hugo

have a look at DS18B20 Temperature Sensor Module Kit which include an adapter with onboard pullup resistor
works OK with ESP32 microcontrollers and the DallasTemperature library
EDIT: powered from 3.3V

DS18B20 should work fine at 3.3V:

I suspect you have a clone/fake sensor which doesn't meet the official specs.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.