I'm in the middle of building an automated hydroponic setup , which is going pretty much to plan apart from one small problem.
I have a small sensor board I have built that contains a Dallas 18B20 for sensing water temp , an LDR for measuring light levels , and a DHT 11 for air temp and humidity. This is all uploaded to a cosm stream, and works well for the most part. After fighting to compile the sketch to include the Dallas sensor, things seemed to be working as they should , no erroneous or wild readings - apart from when the grow lights switch off in the evening ( and consequently the LDR resistance drops ) the dallas starts reporting 85 degrees ( which I believe is an error code ).
My question is this : Would the sudden drop in resistance of the LDR be causing some issue with the DS18B20 ? Once it starts reporting "85" that is all you will get out of it. Would a small cap help? ( The Dallas is running off the 5v , not parasite power )
As as newB I'd appreciate some help or explanation of why turning off lights causes the temp sensor to go mental.
EDIT : There is no improvement in the Dallas ( ie still reporting 85 deg ) even after rebooting the Arduino....
Cigarette packet - style circuit drawing:
You are using a waterproof DS18B20 like this one, do you?
I had trouble with a DS18B20 on my own and it reported 85, too.
The problem was a bad solder joint.
How did you connect/solder the sensor to your arduino?
Do you have a 4.7k pullup connected between Vcc and the output? I have used the TO 92 package DS18B20 and the SOIC DS18B20 on my arduino with a 4.7k tied between Vcc and the output and they have all worked flawlessly. In my opinion they are some of the best temp sensors on the market.
Nevermind, I just looked at your schematic and it appears that you are using a 5.7k resistor, try knocking it down to a 4.7k resistor and see if you are still having problems.
Hi, thanks for the replies !
I think I have narrowed the problem down to the sketch - my both-feet-first troubleshooting has got me into trouble yet again ! My initial problem occurred ( I thought ) when the lighting switched off, and the resistance of the LDR dropped. What I didn't take into account is that the sensors only read and upload every 15 seconds - and during that 15 seconds I had unplugged the 'duino from my laptop and into a wall - wart for the night. It seems that whenever the 'duino loses power , the sketch goes pear shaped. I had stripped a good bit of code out to squeeze everything in , I think I have possibly taken too much out...
In order to resurrect the sensor, I need to upload the example sketch ( tester, I think ) and then re-upload my sketch. It will all work happily again until power off. I'm thinking along the lines that some of the code that was stripped out was for finding the sensors address ( duh! ) and by uploading the test sketch ( with address - finding ) it stores the address in memory , even after uploading my own code - and works until power off. Does this sound feasible ?
In response to Kduin, the sensor module ( containing the DHT-11 , LDR and Dallas are all soldered onto a tiny 1" protoboard ) - the Dallas is an ebay waterproof S/S unit and this is then connected thru an IDC box header and ribbon cable to a corresponding connector on a shield on the 'duino.
I'll try modify the code today and see how I get on this evening.
If the sensors are any distance for the Arduino add a 0.1uF decoupling capacitor from 5V ro GND at the sensor board...
Thanks to you all for valuable input. The problem was caused by my shitty code. I'd managed to strip out the line that gets the sensor readings. Up and running :