// Data wire is plugged into digital pin 2 on the Arduino #define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);
int deviceCount = 0;
float tempC;
void setup(void)
{
sensors.begin(); // Start up the library
Serial.begin(9600);
// locate devices on the bus
Serial.print("Locating devices...");
Serial.print("Found ");
deviceCount = sensors.getDeviceCount();
Serial.print(deviceCount, DEC);
Serial.println(" devices.");
Serial.println("");
}
void loop(void)
{
// Send command to all the sensors for temperature conversion
sensors.requestTemperatures();
// Display temperature from each sensor
for (int i = 0; i < deviceCount; i++)
{
Serial.print("Sensor ");
Serial.print(i+1);
Serial.print(" : ");
tempC = sensors.getTempCByIndex(i);
Serial.print(tempC);
Serial.print((char)176);//shows degrees character
Serial.print("C | ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
Serial.print((char)176);//shows degrees character
Serial.println("F");
}
I don't understand these things very well, but I've had a problem like this before and i wrote something similar and the problem was corrected. " ("\xC2\xB0");" but I can't remember exactly what the line is.
'\xB0' is hexa for 176 resp. octal \260. It depends on terminal type and character set. Normally it is 176.
Try 248 (\370 or \xF8).
If it wont work, print each character. One of them must be correct.
Budvar10:
'\xB0' is hexa for 176 resp. octal \260. It depends on terminal type and character set. Normally it is 176.
Try 248 (\370 or \xF8).
If it wont work, print each character. One of them must be correct.
Erik_Baas:
Serial monitor will only print characters with ASCII values from 32 to 126.
One has to wonder why you really need to do this at all, but I guess the above explains the problem. I only suggested 130 because ALT+0130 delivers a degree symbol in my CAD. Maybe using a proper terminal, like RealTerm, will deliver the goods.