hello, I'm having a hard time with the Dallas ds18b20, I tried your code on my arduino mega and my display is showin bogus stuff wrong caracters, reseting etc.
this appends on any code that contains Dallas related queries, when it does this "sensors.begin();" al lines on my display lights up... and when it reads sensor data my display shows wierd caracters...
with other sensors works ok(DHT11, LM35, etc.)
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 22
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
//Setup lcd
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress Probe012 = { 0x28, 0xCE, 0xE4, 0xA7, 0x03, 0x00, 0x00, 0x9C };
//DeviceAddress Probe013 = { 0×28, 0×43, 0×77, 0×22, 0×03, 0×00, 0×00, 0x9D };
//DeviceAddress Probe014 = { 0×28, 0×30, 0×65, 0×31, 0×03, 0×00, 0×00, 0×13 };
//DeviceAddress Probe015 = { 0×28, 0xDE, 0x9D, 0×31, 0×03, 0×00, 0×00, 0xB1 };
//DeviceAddress Probe016 = { 0×28, 0x7E, 0x8A, 0×31, 0×03, 0×00, 0×00, 0xC0 };
void setup(void)
{
// start lcd
lcd.begin(20, 4);
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(Probe012, 10);
//sensors.setResolution(Probe013, 10);
//sensors.setResolution(Probe014, 10);
//sensors.setResolution(Probe015, 10);
//sensors.setResolution(Probe016, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
}
else
{
lcd.print("C: ");
lcd.print(tempC);
//Serial.print(” F: “);
//Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}
void loop(void)
{
delay(2000);
Serial.println();
Serial.println();
Serial.print("Getting temperatures\n\r");
sensors.requestTemperatures();
Serial.print("Probe 012 temperature is: ");
printTemperature(Probe012);
Serial.print("\n\r");
//Serial.print(“Probe 013 temperature is: “);
//printTemperature(Probe013);
//Serial.print(“\n\r”);
//Serial.print(“Probe 014 temperature is: “);
//printTemperature(Probe014);
//Serial.print(“\n\r”);
//Serial.print(“Probe 015 temperature is: “);
//printTemperature(Probe015);
//Serial.print(“\n\r”);
//Serial.print(“Probe 016 temperature is: “);
//printTemperature(Probe016);
//Serial.print(“\n\r”);
}