But in the direct power mode I just get a reading of -127 degrees and the sensor actually gets burning hot. And in parisitic mode, I still get the -127 degrees (no burning sensor though), and if I remove the sensor while in the parisitic setup, then the reading stays at -127 degrees also
Code below
Anyone able to help please? I'd really appreciate it
Thanks!
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
Serial.print("Temperature for Device 1 is: ");
Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
}
Just completely tried again from scratch, this time using the 'simple' example sketch from the dallas library and parisitic mode and I get the same... -127 degrees regardless of whether the sensor is plugged in or not
I have also tried a different sensor just in case, but that doesn't seem to be the issue since the sensor isn't having any effect on the reading
127 means a bad connection. I believe it may also signal inadequate power. Your diagrams says "any digital pin" but implies you are using pin 46 while your code specifically states you are using pin 2. The code you post is junk and possibly incomplete. This code might help. Strip out what you don't need
/* Basic 2xDS18B20 code for serial monitor, bluetooth, Excel or w.h.y.
Derived from Hacktronics. USE THEIR ADDRESS SNIFFER and substitute your
numbers. Use Hacktronics connections diagram.
http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
Stay away from using parasite power
-127C means bad connection
85 means you haven't gotten a read yet, probably just the
wrong order of commands
*/
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
byte Thermo1[8] = {0x28, 0x39, 0xFD, 0x50, 0x04, 0x00, 0x00, 0X69};
byte Thermo2[8] = {0x28, 0x09, 0xA9, 0xC0, 0x03, 0x00, 0x00, 0x95};
float tempC,Temp1,Temp2;
void setup(){
Serial.begin(9600);
sensors.begin();
delay(500);//Wait for newly restarted system to stabilize
sensors.setResolution(Thermo1, 12);
sensors.setResolution(Thermo2, 12);
}
void loop() {
sensors.requestTemperatures(); // call readings from the addresses
Temp1 = sensorValue(Thermo1);
Temp2 = sensorValue(Thermo2);
Serial.print(" Temp1 = ");
Serial.print(Temp1);
Serial.print(" Temp2 = ");
Serial.println(Temp2);
delay(1000);
}
//sensorValue function
float sensorValue (byte deviceAddress[])
{
tempC = sensors.getTempC (deviceAddress);
return tempC;
}
Nick_Pyner:
127 means a bad connection. I believe it may also signal inadequate power. Your diagrams says "any digital pin" but implies you are using pin 46 while your code specifically states you are using pin 2. The code you post is junk and possibly incomplete. This code might help. Strip out what you don't need
Sorry for the rushed initial post Nick, I was in a hurry and copied that image from a video I was following, I was however using pin 2 on my Arduino Yun despite the image saying 46
Thanks for the info and code, I'll try that this evening
Out of interest, with regards to inadequate power, if that is the issue, what can be done about this?
Out of interest, with regards to inadequate power, if that is the issue, what can be done about this?
I'm not familiar with the Yun and I'm only speculating about inadequate power, but generally, a 9v wall wart fixes all and you will be amazed how many people try to use 9v batteries or questionable USB sources. Having said that, a Yun with a DS18B20 outputting to serial monitor is unlikely to be demanding.
Note that the code I posted is not exactly the same as in the Hacktronics tutorial I recommend, but modified to be more easily expanded upon.
Scanner didn't seem to pick up the sensor... BUT, I still don't think that is the issue, I think it is more my wiring or something else (since the sensors are brand new and they don't seem to have an affect on the figure)
Pic below of my breadboard.
So the cable in 20 is going to ground. 18 is going to 15. 15 has the resistor in and goes to 19, which goes off to pin 3 on my arduino. And then the red cable is bringing in 5v to the + rail on the breadboard, connecting a wire from this into row 15 causes the sensor to smell and begin to get VERY hot, so it is not plugged in. But that is following this image from the hacktronics site:
Despite how it looks in the pic, the resistor in 19 is not actually touching the wire in 18
The code being used is from various places, I've tried that one you supplied and also this from a youtube video
Looks to me like you've wired the DS18B20 backwards. Unless there's some trickery/rerouting of signals on the breakout board, 18 is power, 19 is signal and 20 is ground. You've got power and ground reversed which will tend to annoy the DS18B20
Where did you get that breakout board from and did you solder the DS18B20 on it yourself?
The diagram in your original post suggested that you had just the DS18B20 device without a breakout board.
Are you sure it it at DS18B20 sensor on that module ?
It looks like there is at 4K7 resistor already mounted on the senser board ? And it's hard too see how the connection pin on the module are connected too the Dallas sensor.
Have you tried bying at "naked" DS18B20, it's pretty easy too Work with.
Sorry, I must have had my brain in backwards this afternoon.
Have you got a multimeter? If so, take the breakout board out of the breadboard and just test connectivity between the pins on the breakout board and the leads on the DS18B20 just to make sure there's no trickery on the board - i.e. the left pin does connect to the left lead (as viewed in the photo).
Thanks el_supremo!! I think you've helped me work it out! There IS some trickery on the board and the pins do not match up left to right, I'll re-wire it (probably tomorrow) now I know which pin is which and hopefully it will work
Elac I've got some proper breadboard jumper wires now so that red one can go in the bin
The same board is obviously used for different devices such as this one which uses the middle row of connections. That board also has the 4k7 resistor and what I presume is a Led. This made me wonder if the outputs at the header pins might not be in the same order as the ds18b20 pins.
Let us know which way round the pins are connected if you get it working.
The resistor is on the board already, as well as what seems to be a status LED. If connected incorrectly it either flashes slowly or doesn't flash at all. If connected correctly it flashes quickly
So pins are all shifted to the right one (and far right one is the far left pin)... Looking at the board from the front:
Left hand pin at the top (positive) is middle pin at the bottom
Middle pin at the top (signal) is right hand pin at the bottom
Right hand pin at the top (ground) is left hand pin on the bottom
Thank you so much for all the help in trying to diagnose this, feels so good to finally have it working... Was nearly giving up haha
Thanks all
Note: I couldn't get parasite power working, but I was warned about that by another member here before I began the project