#include <OneWire.h>
#include <DallasTemperature.h>
#include <TinyWireM.h>
#include <Tiny4kOLED.h>
#include <TinyDebug.h>
#define ONE_WIRE_BUS 3 // PB3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
void setup() {
Debug.begin();
sensors.begin();
oled.begin(128, 64, sizeof(tiny4koled_init_128x64br), tiny4koled_init_128x64br);
oled.enableChargePump(); // Most display require to display properly
oled.clear(); // Clear the memory before turning on the display
oled.on(); // Turn on the display
oled.setFont(FONT6X8P); // Two fonts are supplied with this library, FONT8X16 and FONT6X8
oled.setCursor(0, 0);
oled.print("Celsius temperature: ");
}
unsigned long t0 = 0;
unsigned long t1 = 0;
void loop() {
t1 = millis();
if (t1 - t0 > 1000) {
t0 = t1;
sensors.requestTemperatures(); // request temperature from all sensors on the bus
// Debug.print("Celsius temperature: ");
// Debug.println(sensors.getTempCByIndex(0)); // temp from sensor idx=0
oled.setFont(FONT8X16P); // Two fonts are supplied with this library, FONT8X16 and FONT6X8
oled.setCursor(0, 3);
oled.print(sensors.getTempCByIndex(0)); // temp from sensor idx=0
}
}