Im using loads of strings and getting away with it.
My project doesnt stall and has been running on and off for weeks at a time between me fiddling with it.
Im thinkinmg of doing the same as you regarding storing the tempo values. Just havnt got round to it.
The only difference I can think is that I dont use a library for the DS18B20.
But some code I found and used.
float getTemp(byte addr[8]){
int HighByte, LowByte, TReading, SignBit, Whole, Fract,i;
float temp;
OneWireReset(TEMP_PIN);
OneWireOutByte(TEMP_PIN, 0x55);
for( i = 0; i < 8; i++) OneWireOutByte(TEMP_PIN,addr[i]);
OneWireOutByte(TEMP_PIN, 0x44); // perform temperature conversion, strong pullup for one sec
OneWireReset(TEMP_PIN);
OneWireOutByte(TEMP_PIN, 0x55);
for( i = 0; i < 8; i++) OneWireOutByte(TEMP_PIN,addr[i]);
OneWireOutByte(TEMP_PIN, 0xbe);
LowByte = OneWireInByte(TEMP_PIN);
HighByte = OneWireInByte(TEMP_PIN);
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2's comp
}
temp = (6 * TReading) + TReading / 4; // multiply by (100 * 0.0625) or 6.25
temp /= 100;
if (SignBit){ // negative
temp *= -1;
}
// one wire functions
void OneWireReset(int Pin) // reset. Should improve to act as a presence pulse
{
digitalWrite(Pin, LOW);
pinMode(Pin, OUTPUT); // bring low for 500 us
delayMicroseconds(500);
pinMode(Pin, INPUT);
delayMicroseconds(500);
}
void OneWireOutByte(int Pin, byte d) // output byte d (least sig bit first).
{
byte n;
for(n=8; n!=0; n--)
{
if ((d & 0x01) == 1) // test least sig bit
{
digitalWrite(Pin, LOW);
pinMode(Pin, OUTPUT);
delayMicroseconds(5);
pinMode(Pin, INPUT);
delayMicroseconds(60);
}
else
{
digitalWrite(Pin, LOW);
pinMode(Pin, OUTPUT);
delayMicroseconds(60);
pinMode(Pin, INPUT);
}
d=d>>1; // now the next bit is in the least sig bit position.
}
}
byte OneWireInByte(int Pin) // read byte, least sig byte first
{
byte d, n, b;
for (n=0; n<8; n++)
{
digitalWrite(Pin, LOW);
pinMode(Pin, OUTPUT);
delayMicroseconds(5);
pinMode(Pin, INPUT);
delayMicroseconds(5);
b = digitalRead(Pin);
delayMicroseconds(50);
d = (d >> 1) | (b<<7); // shift d to right and insert b in most sig bit position
}
return(d);
}
You could try slotting that in and removing the library and see if it makes any difference.
Might help tracking down the problem.
At some point I need to put in some error checking with the CRC as sometimes when I first turn it on I get some strange values. But a reset with the power connected sorts that out. Suggesting to me the sensors arnt quite ready.
Gordon