Getting C from 18B20 Digital Temp Sensor - 2 Meter

Does any one have any suggestions please.

I have 4 18B20 reading temperature. 3 working 100% the 4 one returns 85. Following is a print
44.9,48.4,47.6,85.0

My ,h files

#include <OneWire.h>
#include <DallasTemperature.h>
#include <avr/wdt.h>
#include "RTClib.h"

uint8_t sensor1[8] = { 0x28, 0xA9, 0x1B, 0x85, 0x11, 0x20, 0x06, 0x7D }; //
uint8_t sensor2[8] = { 0x28, 0x7D, 0x3D, 0x52, 0x11, 0x20, 0x06, 0x86 }; //
uint8_t sensor3[8] = { 0x28, 0xA9, 0x1B, 0x85, 0x11, 0x20, 0x06, 0x7D };
uint8_t sensor4[8] = { 0x28, 0xE7, 0x9C, 0x75, 0xD0, 0x01, 0x3C, 0xCD }; // Manifold

code in setup:

sensors.begin();
delay(300);

My code in loop()

TempGD = sensors.getTempCByIndex(0);
PrevGTempD1 = TempGD;
delay(990);
HoldingTTempGD = sensors.getTempCByIndex(1);
PrevGTempD2 = HoldingTTempGD;
delay(990);
ManifoldTempGD = sensors.getTempCByIndex(3);   //  was 2
PrevGTempD3 = ManifoldTempGD;
delay(990);
AmbiantTepGD = sensors.getTempCByIndex(2);     // was 3
PrevGTempD4 = AmbiantTepGD;
delay(990);

The first three works 100% The 4 returns 85. I tried 4 new/different ones and they all do the same return 85.

I can read it first second third or 4th I only get 85.

I can increase the delay shorten it. I only get 85.

I replaced the resitor (4k7) re wired the 4 stereo jacks that I use to connect the devices.

Checked the PS . Only thing I did not do is to jump. But I did drive to the clif

Many thanks

Can some one please help me out of my "misery" .

Show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

Wait... You're not using the addresses? Nevermind.

Maybe you need:
sensors.requestTemperatures();

Maybe you shouldn't use the same address twice.

1 Like

Hi!
Your code should look like this:

void loop()
{
  sensors.requestTemperatures();
  TempGD = sensors.getTempC(sensor1);
  HoldingTTempGD = sensors.getTempC(sensor2);
  AmbiantTepGD = sensors.getTempC(sensor3);
  ManifoldTempGD = ssensors.getTempC(sensor4);
}

Best regards.

Sorry,

This was a typo it is:

uint8_t sensor1[8] = { 0x28, 0xA9, 0x1B, 0x85, 0x11, 0x20, 0x06, 0x7D }; //
uint8_t sensor2[8] = { 0x28, 0x7D, 0x3D, 0x52, 0x11, 0x20, 0x06, 0x86 }; //
uint8_t sensor3[8] = { 0x28, 0x87, 0xFE, 0x90, 0x11, 0x20, 0x06, 0x69 };
uint8_t sensor4[8] = { 0x28, 0xE7, 0x9C, 0x75, 0xD0, 0x01, 0x3C, 0xCD }; //

It doesn't matter since you aren't using the addresses for anything. You're scanning the bus every time you read a temperature so if one of your sensors fails, the others will just change numbers.

Changed to this:
sensors.requestTemperatures();
GeaserTempGD = sensors.getTempCByIndex(0);
HoldingTTempGD = sensors.getTempCByIndex(1);
ManifoldTempGD = sensors.getTempCByIndex(3); // was 2
AmbiantTepGD = sensors.getTempCByIndex(2); // was 3
PrevGTempD1 = GeaserTempGD;
PrevGTempD2 = HoldingTTempGD;
PrevGTempD3 = ManifoldTempGD;
PrevGTempD4 = AmbiantTepGD;

This is the result of this change:
127.0,-127.0,-127.0,-127.0,09,-127,06,1,0,0.050,0,19,2,19,1,17,5bbc
49.4,53.1,52.4,85.0,09,49,53,1,1,0.050,0,19,2,19,1,18,41fb

I then changed the code to:
LoopTimerCGL = 0;
sensors.requestTemperatures();
delay(2000);
GeaserTempGD = sensors.getTempCByIndex(0);
HoldingTTempGD = sensors.getTempCByIndex(1);
ManifoldTempGD = sensors.getTempCByIndex(3); // was 2
AmbiantTepGD = sensors.getTempCByIndex(2); // was 3
PrevGTempD1 = GeaserTempGD;
PrevGTempD2 = HoldingTTempGD;
PrevGTempD3 = ManifoldTempGD;
PrevGTempD4 = AmbiantTepGD;

The result:

First line was correct then line 2 on the dreaded 85
49.7,53.4,52.8,34.6,
,49.8,53.5,52.8,85.0,

Will do a little later it is now 1/2 2 and will make some noise upsetting those thats a sleep.

Sorry for this

The idea was to implement this code.

But because the error I used a simple loop to get help.

double ReadTempSensor(int sensor) {
int ErrorI = 0;
double TempD;

// Serial.println(sensor);
do {
sensors.requestTemperatures();
delay(2000);
if ( sensor == 1)
TempD = sensors.getTempC(sensor1);
else if ( sensor == 2)
TempD = sensors.getTempC(sensor2);
else if ( sensor == 3)
TempD = sensors.getTempC(sensor1);
else
TempD = sensors.getTempC(sensor4);
// Serial.println(TempD);
if ( TempD <= -126 ) {
if ( ErrorI++ > 5) {
sensors.begin();
delay(2000);
ErrorI = 0;
}
}
#ifdef Debug
Serial.println(TempD);
Serial.println(LoopTimerCGL);
#endif
} while (TempD < -126);
return ( TempD);
}

The full data set that get send via rf is: 12f0 is crc
,81,005,001,001,V3,V4,V5,V6,1,50.3,54.2,53.5,34.7,54,50,54,1,0,0.050,0,19,2,19,1,38,12f0

Clock time:
2,19,1,38,12f0
Feb,19,1H,38Sec

Temp data is
,50.3,54.2,53.5,34.7,

Sorry tried to upload scheme but message says new users not aload to upload.

This is a screen shot

Hi, @erastusc
You should be able to EXPORT a jpg file from your CAD, then copy and paste it into your post.

Please include pin names and component names in your schematic.
What is you switching regulator?

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

Onewire does not like a star-topology the signals on the wire get bended more if you use a star-topology

use a line-topology even if the wires get 10 m long when using a line-topology

Another try is to reduce the pull-up-resistor between Data and +Vcc from 4k7 to 2k.
I have a 21 m long onewire-bus running with 25 sensors and it works (almost) perfect.
maybe one wrong value every two days at a measuring-interval of 20 seconds

best regards Stefan

Will update and upload again

Thanks for the response

I am quite sure my wiring is like below. Which is a split or star. Will fix it and let you know also replace the resistor.

Many thanks I did not expect that.

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