emonTX + DS18B20: invalid temperature read?

Hi,

just got around to building my emonTx and connecting to it the weatherproof temp sensor bought from the online store here.

emonTX seems fine, I am talking to it over USB for the moment.

However I cannot read a valid temperature from the DS18B20.

It is correctly detected by the DallasTemperature library, and has a plausible looking address of 28:B8:0D:A2:04:00:00:64
The Dallas code decides this is a valid device address.

however the temperature read back from the device is a contant and strange 85C.
Dumping out the scratchpad using the Dallas API just gives a constand set of bytes

Any clue about what might be wrong?

Is is plausible that the device is just bad?
I don't have another one to try ...

Thanks
Liam

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

Hmm

OK I see from the DS18B20 datasheet that 0x50 0x05 in the first two bytes of the device scratchpad (a.k.a the temperature reading of 85C) is the scratchpad power up state.

Curious.

But it would suggest that I am at least talking to the device.

The code just looks like this:

sensors.setWaitForConversion(true);
sensors.setCheckForConversion(true);
sensors.requestTemperaturesByAddress(tempSensorAddr);  
if( sensors.isConversionAvailable(tempSensorAddr))
{
      Serial.println("Temperature conversion is available");
} else {
      Serial.println("No temp conversionavailabe");
}

/* Dump out the scratchpad : debug */   
sensors.readScratchPad(tempSensorAddr, scpad);
Serial.println("Scratchpad...");
for(i=0; i<9; i++)
{
      Serial.print(scpad[i], HEX);
      Serial.print(" ");
}
Serial.println("");
   
temp=sensors.getTempC(tempSensorAddr);
Serial.print(temp, DEC);

 

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

And one followup question if I could

The store-provided outdoor-ready temp sensor kit has 3 wires + a braid.
Should the braid connected be connected to ground too?

Robert Wall's picture

Re: emonTX + DS18B20: invalid temperature read?

What does the example sketch EmonTx_temperature_power give you? - after plugging in the address of your sensor, of course.

Check whether the screen braid is connected anywhere else! If not, then earthing it is probably a good idea.

[Edit]

After adding some declarations and minor details like setup( ) and loop( ) to your "sketch" to allow it to compile, it does seem to be giving me the correct temperature readings.

Temperature conversion is available
Scratchpad...
73 1 4B 46 7F FF D 10 41
23.1875000000

So I suggest you check your definitions for the variables and your connections to the sensor. http://openenergymonitor.org/emon/buildingblocks/DS18B20-temperature-sen...

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

Thanks

A colleague also suggests that he has seen exactly the same behaviour, caused by incorrect wiring on his part.

So I need to check that i have soldered the board together properly. The temp sensor is definitely connected properly to the 3.5mm jack, at least it is according to the picture on this page:

http://openenergymonitor.org/emon/buildingblocks/DS18B20-temperature-sen...

And I also have other generic Arduino boards, I might be able to connect the temp probe to one of them as a second check.

 

 

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

Experiments with another arduino board showed that the temperature sensor works fine.

I spent a *long* time trying to figure out what I did wrong with the emonTx, but to no avail. I can't find anything wrong with the connections, but it just does not want to play ball with the temperature sensor.

I don't really have any debugging kit here either, beyond a simple multimeter.

Oh well, I guess I broke it :-)

I will build another one. Carefully.

Bramco's picture

Re: emonTX + DS18B20: invalid temperature read?

Liam,

I'm about to start on the same journey, so if you do ever do find out what went wrong it would be good to hear about it.

Simon

Robert Wall's picture

Re: emonTX + DS18B20: invalid temperature read?

liam,

Before you do that:

There are only 3 connections to the jack socket - 5 V, GND and the Input to Pin 6 on the processor (DIO 4). Can you check continuity with your meter on those - a faulty socket is not unheard of. I presume you have R9 (4k7) fitted and you get 5 V on the ring, 0 V on the sleeve and something in between on the tip with the sensor connected or 5 V without.

You can prove the digital input by writing a "one-liner" sketch to read DIO4, it should read HIGH with nothing connected and LOW if you short tip to sleeve.

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

Hi

apologies for not monitoring the forum. Some vacation time intervened.

I built another emonTx there this evening (very, very carefully) and connected to it one of the weather proof temp sensors from this site. In various experiments I <ahem> sort of broke the first one ;-)

Somewhat to my annoyance, this didn't work properly either: a sketch would find the Dallas chip, no problem. But the temperature read from sensor was always incorrect (+127C)

After a spot of googling and some experiments, though, I discovered how to fix it.

Instead of the 4.7K pullup resistor which is part of the standard kit, I used a 2.2K pullup.
well, OK, not exactly 2.2K, but I had another 4.7K on the bench so I wired that in parallel. So 2.35K to you.

Now it works just fine. This at the moment is running from USB power, but ultimately will be outside running off battery+solar power.

So why, we wonder, does it not work with the standard 4.7K value, which is even recommended by the DS1820 datasheet.

Any idea? Should I be concerned about it?

Next I will have to see if the RF module works and try running it from battery power

Liam

Robert Wall's picture

Re: emonTX + DS18B20: invalid temperature read?

So why, we wonder, does it not work with the standard 4.7K value, which is even recommended by the DS1820 datasheet. Any idea? Should I be concerned about it?

Indeed we do wonder. I assume the supply is correct at 5 V and relatively clean?  I'll flag it to Glyn & Trystan.

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

Hi Robert

seems fine, all measured voltages on the board seems correct (but I can't do a very fine measurement at home, just a multimeter)

I am only powering it over USB/FTDI interface from a laptop, but it's only running the arduino + a single temperature probe, nothing else, and I have never noticed problems before powering arduino toys over USB from that laptop ...

 

 

TrystanLea's picture

Re: emonTX + DS18B20: invalid temperature read?

It usually works fine with a 4.7k resistor, so that sounds strange, did you say that you had two sensors and both dont work?

jpbrigg's picture

Re: emonTX + DS18B20: invalid temperature read?

Hi, First post but may have something to add  regarding 85C reading.

Having only recently changed from a Combi boiler to a regular boiler and Hot Water tank plus Robin's excellent circuit, I was interested in knowing how much hot water was available. I do fully appreciate there are issues with measuring the temperature of the  external pipework.  I chose 4  approx equally spaced levels. With pointers from this site I was able to concoct a sketch that read 4    DS18B20 sensors and display the results on a 20x4 LCD HD44780 display.

All was working well until I moved the 1 sensor from one place to another, from then on, when first powered up, it sometimes reads as 127C and sometimes 85C.  Two or three resets of the Arduino usually cure it. The other  three sensors, on the same circuit, continue to work correctly. My circuit uses a 4.7K pullup resistor. I have so far put this false reading down to my poor soldering onto the first sensor, that showed up once I moved it.

John

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

Hi

so far I've only tried one sensor: a weatherproof assembly one which I built from this site.

I have a couple more though on hand (just bare DS1820s, not the weatherproof assemblies), and I am going to build some temperature-only nodes with bare Arduinos, so I can also test the weatherproof sensor I have on one of those Arduino boards, when I get them built, using 4.7K pullups on those Arduino boards.

I will also double check the soldering on the one I assembled, but I doubt that's the problem.

Robert Wall's picture

Re: emonTX + DS18B20: invalid temperature read?

You are using an emonTx, aren't you? Do you have an "iffy" socket or plug? Problem sockets are not unknown, it's also not unknown to have a bad contact between the tag for the tip connection and the rivet in the plug. It would pay to check those carefully before you look for anything more complicated.

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

Yes, emonTx for the moment.

I'll try your suggestions ... 

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

I have been experimenting some more with this (this == an emonTx board with a DS1820 weatherproof sensor, kits all purchased in the store here)

For the moment I am concentrating on temperature reading only, current sensing will come later.

My results are a bit surprising (at least to me)

* temperature reading only works if the pullup resistor is 2.2K and not 4.7K. 4.7K just doesn't work ever (invalid value of +127C read)

* it works correctly (RF12B transmission to base station, + correct temp read) if powered by USB/FTDI, or it will work if powered with a battery pack of 4 AA rechargeables (yes, 4) connected as recommended on the site between PWR and GND.

* it will not work with 3 x rechargeable AAs, even freshly charged and delivering about 4.2V.

With 3 x AAs, the RF12B works fine, and the board runs fine, but the temperature reading is invalid (+127C, always).
I have played around with the dallas library, tried very conservative temp conversion timings, etc. No avail. <4 AA cells, no workee at all. 4 AA cells (or USB power) works fine.

I only have one of those weatherproof sensors, which is a pity, because I wonder if it's a bit of a dud. Why else would it not work properly with 4.2V supply?

I will persevere with my 4xAA solution. On the plus side, this should run for ages.
On the minus side, I am going to have to adjust my solar charger circuit a bit.

Robert Wall's picture

Re: emonTX + DS18B20: invalid temperature read?

I haven't forgotten you. I'll try to check one on reduced voltage tomorrow.

Robert Wall's picture

Re: emonTX + DS18B20: invalid temperature read?

I'm not sure that you'll like this.

I fed my emonTx from my lab power supply. It stopped transmitting below 4.8 V, so inconclusive.

So instead I lifted the red wire (power to the DS18B20) off the plug and fed that alone from my variable supply. It was accurate down to 2.4 V (at room temp) and "worked" but gave wrong readings some way below that.

I wonder whether the impedance of your battery is to blame, and you need a fatter capacitor across the supply to hold it up whilst the DS18B20 is drawing current? From the data sheet: "when the DS18B20 is performing temperature conversions or copying data from the scratchpad memory to EEPROM, the operating current can be as high as 1.5mA."  It seems unlikely that 1.5 mA would cause trouble but in the absence of anything else to blame it's worth checking.

And all this with the standard 4k7 on-board pull-up.

liamf's picture

Re: emonTX + DS18B20: invalid temperature read?

Hmm interesting

Thanks for experimenting and following up.

I had gone ahead and built my 4x rechargeable AA powered external temp + current emonTx board.

This is running away there now, happily outputting a valid temperature + power reading. I need to make one firmware update to it to fix a stupid bug I have in my power reading code, but apart from that it's working OK. Of course I don't know yet if my rather amateur-hour solar powered trickle charger will keep the rechargeables topped up, especially in winter. In Ireland. But hey, that's what experiments are for.

The next phase of my project is to build some more temperature only nodes and although those won't be using the weatherproof DS18B20s (just plain vanilla DS18B20s) I can try to reproduce the issue and then experiment with the larger capacitor as you suggest.

Highly entertaining though, the whole thing.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.