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?
#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);
}
/ 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.
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.
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.
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.