Waterproof temperature sensor

Good morning,

I want to measure temperature using the temperature waterproof link below.
Temperature Sensor Waterproof - Zero Ohm Electronics.

I connected the circuit but I did not find the code for the sensor. Can you assist, please?

Regards.

That is a DS18B20 temperature sensor. Just search " Arduino DS18B20 tutorial"

Which Arduino are you using?

I am using Arduino UNO.
I installed oneWire and DallasTemperture libraries.
I get the error: No device found and it does not return the temp value.
I tried most of the files under DallasTemperture for example simple, single, alarm

Hello engasma
Post your sketch, well formated, with comments and in so called code tags "</>" and schematic to see how we can help.
Have a nice day and enjoy coding in C++.

This is the circuit

The code is taken from DallaTemperature library.
The file name is tester

I am following exactly the circuit in this link: https://bildr.org/2011/07/ds18b20-arduino/

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 12 on the Arduino
#define ONE_WIRE_BUS 12
#define TEMPERATURE_PRECISION 9 // Lower resolution

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

int numberOfDevices; // Number of temperature devices found

DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
  
  // Grab a count of devices on the wire
  numberOfDevices = sensors.getDeviceCount();
  
  // locate devices on the bus
  Serial.print("Locating devices...");
  
  Serial.print("Found ");
  Serial.print(numberOfDevices, DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");
  
  // Loop through each device, print out address
  for(int i=0;i<numberOfDevices; i++)
  {
    // Search the wire for address
    if(sensors.getAddress(tempDeviceAddress, i))
	{
		Serial.print("Found device ");
		Serial.print(i, DEC);
		Serial.print(" with address: ");
		printAddress(tempDeviceAddress);
		Serial.println();
		
		Serial.print("Setting resolution to ");
		Serial.println(TEMPERATURE_PRECISION, DEC);
		
		// set the resolution to TEMPERATURE_PRECISION bit (Each Dallas/Maxim device is capable of several different resolutions)
		sensors.setResolution(tempDeviceAddress, TEMPERATURE_PRECISION);
		
		Serial.print("Resolution actually set to: ");
		Serial.print(sensors.getResolution(tempDeviceAddress), DEC); 
		Serial.println();
	}else{
		Serial.print("Found ghost device at ");
		Serial.print(i, DEC);
		Serial.print(" but could not detect address. Check power and cabling");
	}
  }

}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  // method 1 - slower
  //Serial.print("Temp C: ");
  //Serial.print(sensors.getTempC(deviceAddress));
  //Serial.print(" Temp F: ");
  //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit

  // method 2 - faster
  float tempC = sensors.getTempC(deviceAddress);
  if(tempC == DEVICE_DISCONNECTED_C) 
  {
    Serial.println("Error: Could not read temperature data");
    return;
  }
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}

void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  
  
  // Loop through each device, print out temperature data
  for(int i=0;i<numberOfDevices; i++)
  {
    // Search the wire for address
    if(sensors.getAddress(tempDeviceAddress, i))
	{
		// Output the device ID
		Serial.print("Temperature for device: ");
		Serial.println(i,DEC);
		
		// It responds almost immediately. Let's print out the data
		printTemperature(tempDeviceAddress); // Use a simple function to print out the data
	} 
	//else ghost device! Check your power requirements and cabling
	
  }
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

Hello engasma
Check the wiring and the power supply for the sensor by using a DMM.

Have a nice day and enjoy coding in C++.

Not the best ever circuit diagram …

On some prototyping boards the power rails are not continuous across the width of the board - check that

Not relevant to the photo shown (such as it is :worried:), but one must always suspect the wiring. :roll_eyes:

What is that Adafruit board sneaking in to the photo anyway? :thinking:

No, that is a jumble of wires.

1 Like

Good morning....
I am using both Arduino WIFI Sheild and adafruit RFID reader in my circuit. I want to display some sensors values and the users cards on the web.

An example of a reasonable circuit diagram

Edit : *** see my reply later ***
( unable to Quote atm)

So just what are those 4k7 resistors doing? :astonished:

@hammy I agree with @Paul_B , that doesn't look right at all. The pull-ups are in the wrong place on all the ds18b20 and missing on the dht11 (although I suppose internal pull-up could be engaged there). Also, with one 4K7 per sensor, all those resistors in parallel will become a very strong pull-up and might stop the 1-wire bus working.

The Uno is missing! You gotta connect that!

I once used some cheap waterproof ds18b20 from a Chinese eBay seller. Maybe they were faulty, but I had to use much lower resistors to make them work at all, < 1K, which didn't seem right, but they would not work with the usual 4K7. So maybe try 2K2 or 1K or 510R.

Hi,
Have you just got the UNO and sensor connected, forget about connecting any other shields or modules.

Lets get the sensor working first.
Do you have a DMM?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Better example of a DS18B20 wiring diagram, from: https://create.arduino.cc/projecthub/TheGadgetBoy/ds18b20-digital-temperature-sensor-and-arduino-9cc806

The “ waterproof” sensors you have aren’t water proof and quickly fail if submerged in water .
The tip Is water proof but the cable junction to the top is not

My mistake wasn’t clear on my schematic post . I was just showing an example of what a schematic “is “ for the OP.It’s wasnt intended to be a real circuit ( I just grabbed it from the internet ) to show how to draw stuff .
Apologies for misleading people !

BTW - this forum not allowing me to Quote people today !