Hello all, I’m betting this is an easy one but there’s something I’m not grasping. 1st off, I’m sending data over XBee in the form of a variable. Data is coming from a DS18B20 Temperature sensor to an Arduino. I’m using the Dallas Temperature sensor library. I named the device grabbing temperature in direct sunlight ‘suntemp’, I will later incorporate another temp sensor in the shade to grab ‘shade temp’…first things first though. Here’s the code grabbing the variable ‘suntemp’:
#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);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress shadeTemp = { 0x28, 0x94, 0xE2, 0xDF, 0x02, 0x00, 0x00, 0xFE };
DeviceAddress sunTemp = { 0x28, 0x9D, 0x56, 0xEB, 0x03, 0x00, 0x00, 0xD5 };
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(sunTemp, 10);
sensors.setResolution(shadeTemp, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.println(DallasTemperature::toFahrenheit(tempC));
}
}
void loop(void)
{
delay(1000);
sensors.requestTemperatures();
//Serial.println("SunTemp: ");
printTemperature(sunTemp);
//Serial.print("\n\r\n\r");
}
So far on the send side in the serial monitor, the temp is reading and printing correctly and it’s 75.20
Here’s the code on the receiver side:
void setup() {
Serial.begin(9600);
Serial.print("testing Xbees");
// opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0)
{
//val = Serial.read();
Serial.println("is this correct? ");
Serial.println(Serial.read());
}
}
Serial gives me 55,53,46,50,48,13,10
which is 75.20 in ASCII, but I want to display this to an LCD as Characters. I’m not sure of how to alter the code so it prints the data in Character form.
Can someone help. Thanks much.