Hi All,
Could I please have some assistance on why this will not display the temp output of my DS18B on the SH1106 I have used it with?
Sorry but I am very new to this…
// Include the Dallas Temperature library
#include <DallasTemperature.h>
// Setup the OneWire bus on Pin 2
OneWire bus(2);
// Setup DallasTemperature to work on the OneWire bus
DallasTemperature sensors(&bus);
// Include the U8glib Library
#include <U8glib.h>
// Configure the OLED Screen (I2C)
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NO_ACK); // Display which does not send ACK
int frame = 0;
float temperature;
char temperatureString[6] = "-";
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g.setFont(u8g_font_fur11);
u8g.drawStr( 0, 22, "Temp:");
u8g.setFont(u8g_font_fub25);
u8g.drawStr( 0, 54, temperatureString);
}
void setup() {
// Start the sensors
sensors.begin();
}
void loop() {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
// Update the sensor readings
sensors.requestTemperatures();
// Read Temperature
temperature = sensors.getTempCByIndex(0);
dtostrf(temperature, 2, 2, temperatureString);
// Delay for 2 seconds between readings
delay(2000);
}