Hello
I'm having issues with a setup where I'm trying to read 5x DS18B20 temperature sensors. I'm pretty sure this isn't a code issue, but here's the basics.
// sensor addresses
DeviceAddress sensorAddr[5] = {
{0x28, 0x2D, 0x56, 0x46, 0x92, 0x02, 0x02, 0x48},
{0x28, 0x40, 0x5B, 0x79, 0x97, 0x08, 0x03, 0x73},
{0x28, 0xA6, 0x94, 0x79, 0x97, 0x07, 0x03, 0xBD},
{0x28, 0xD6, 0x69, 0x79, 0x97, 0x05, 0x03, 0xFE},
{0x28, 0x24, 0x08, 0x77, 0x91, 0x01, 0x02, 0x9F}
};
// Data wire for temperature sensors
#define ONE_WIRE_BUS 13
// 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);
// get temps
sensorActualCount = 0;
sensors.requestTemperatures();
for (int i = 0; i < sensorCount; i++) {
temps[i] = sensors.getTempC(sensorAddr[i]);
if (temps[i] > -127) {sensorActualCount++;}
}
All of the sensors are connected in a star topology to anArduino Uno Wifi Rev 2 with a 4.7k pullup resistor. The reason I've added the sensor addresses is because it's important to know which sensor is which if one of them cannot be read for some reason.
I have used high quality cat5e cable as follows :-
- Brown - W/Brown - GND
- Orange - W/Orange - +5V
- Blue - Data
Approximate lengths of cable are as follows :-
- Sensor 1 - 3m
- Sensor 2 - 2m
- Sensor 3 - 7m
- Sensor 4 - 11m
- Sensor 5 - 15m
The issue I have is that when a 5th sensor is connected, I lose the data for all of the sensors. Usually, the readings are all 0. I've tried various combinations, sometimes adding the 4th sensor in to mix kills the sensor readings. I thought it was the longest cable causing the issues but it's not. e.g. if I start at sensors 5 and work backwards, sensor 1 ends up killing the readings.
I have checked this link regarding long cable lengths and I understand that it doesn't recommend a star topology but I have no choice in this setup. I simply want to understand the electronics side of things and try and resolve the issue on the setup I already have.
Am I using the incorrect resistor value for this type of setup? Do I need to add other resistors to the endpoints near the sensors?
Appreciate any help and if I've missed anything out that anyone feels is relevant please let me know and I'll supply the information.
Thanks,
Matt