Not shure if connected dallas sensor correctly

Hello. I'm new here so I'm sorry if this is not the right spot to post this.
I'm now to arduino, but I have some knowledge in other programming languages.
My question is, I am creating a system to manage my aquariums, I'm working with a wemos d1 mini, 2 waterproof dallas sensors with a 66" oled screen to show temperature.
When I try to get data from sensors they give me - 127 value which I know that is an error from the probe not connected correctly.

Main problem. When working with nodemcu I can connect 2 dallas sensors with just one pull up and I need to identify the ID of each one.
But in the wemos via arduino ide I don't know what to do. Any help?

Bryan

Please share your < code/ >, schematics, and pictures of your setup.

How to get the best out of this forum - Using Arduino / IDE 1.x - Arduino Forum

#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is conntec to the Arduino digital pin 5
#define ONE_WIRE_BUS 5
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);
void setup(void)
{
// Start serial communication for debugging purposes
Serial.begin(9600);     // initialize the Serial Monitor at a baud rate of 9600
// Start up the library
sensors.begin();        // initialize the DS18B20 temperature sensor:
}
void loop(void){ 
// Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
sensors.requestTemperatures(); 
Serial.print("Celsius temperature: ");  
// Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
Serial.println(sensors.getTempCByIndex(0));     // get and print the temperature in degree Celsius
delay(1000);
}



I think I have a mistake here..

/ Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
sensors.requestTemperatures(); 
Serial.print("Celsius temperature: ");  
// Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
Serial.println(sensors.getTempCByIndex(0));     // get and print the temperature in degree Celsius
delay(1000);
}

You imply that you were obliged to change code for the Wiemos. Not true. The same code should work for both. That said, a - 127 means dodgy wiring. If the wiring and power were kosher on the Node MCU, it should also be on Wiemos.

Hi,
Try powering the Dallas with 5V rather than 3V3.

What value is the pullup resistor, 4K7?

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

Now, that's a point. There must be some notes out there that specifically deal with DS18B20 on 3.3v boards but, more to the point, OP has had things working with NodeMCU - no comment on the pullup.


4k7

I’ve used 4k7 on ESP32s successfully in 3 projects, works perfectly.

1 Like

Hi,
You have two sensors, you have to address each sensor separately.

Have you just tried with just ONE sensor connected?

Google;

arduino and two dallas temperature sensor

There are quite a few tutorials on how to accomplish this.

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

1 Like

Hi,
I think you are, for a start missing;

 // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  deviceCount = sensors.getDeviceCount();
  Serial.print(deviceCount, DEC);
  Serial.println(" devices.");
  Serial.println("");

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

2 Likes

Hello. Thanks to all. I will try some of the suggested things here, later in this day and report back.

Bryan

Hi Nick. I changed the code because the other board is running esphome and yaml.

Hello again.
The problem is solved, thank you guys for the tips, fortunately all my code was working fine, my dumb as* just entered the wrong port. :smiling_face_with_tear:
Everyting is fine now.
Now i just have to figure how can i display the values in the oled and further pass everything to homeassistant. Maybe MQTT. We'll see.

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