I have a project which uses a DS18B20 temperature sensor and an LCD with an I2C interface on it. I have connected the sensor to my micro-controller (the DS18B20 has a 12-bit digital output) to the ATmega16 PD17, but as I try to print my values on the terminal the sensor output a really high value in decimal. Here is part of the code (and yes everything is working fine, this is a home-made Arduino):
DDRD &= 0x00;
PORTD |= 0x00;
ds18b20_init(&PORTD, 20, 30, DS18B20_12BIT_RES);
int temperature_sensor_output = (float)ds18b20_temperature(&PORTD);
printf("Temperature: %d ", temperature_sensor_output);
delay_ms(500);
ds18b20_init is the Dallas function for initializing the module. ds18b20_temperature returns a float value of the temperature
From this code it just prints:
Temperature: 51603
If I change %d to %f it prints:
Temperature: without any value
I do not understand where I may have missed some things.