diff --git a/firmware/test1/heizung-test1/platformio.ini b/firmware/test1/heizung-test1/platformio.ini index 02716d6bfecd099a6e53545b53a469a3d71f56da..6c6199b086e1fb6c0551b616eec7053cf572623c 100644 --- a/firmware/test1/heizung-test1/platformio.ini +++ b/firmware/test1/heizung-test1/platformio.ini @@ -13,4 +13,6 @@ platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = pico framework = arduino board_build.core = earlephilhower -lib_deps = adafruit/Adafruit SSD1306@^2.5.7 +lib_deps = + adafruit/Adafruit SSD1306@^2.5.7 + sparkfun/SparkFun TMP102 Breakout@^1.1.2 diff --git a/firmware/test1/heizung-test1/src/main.cpp b/firmware/test1/heizung-test1/src/main.cpp index 4983019998c54edf5354707eea3dfb7dd7731ce3..2147c23361491633e6a83af19d4dff548ff21582 100644 --- a/firmware/test1/heizung-test1/src/main.cpp +++ b/firmware/test1/heizung-test1/src/main.cpp @@ -2,6 +2,7 @@ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> +#include <SparkFunTMP102.h> enum Pinout { DRIVE1 = 0, @@ -42,6 +43,8 @@ bool hasDisplay; #include "logo.h" +TMP102 sensor0, sensor1; + void setup() { rp2040.enableDoubleResetBootloader(); @@ -80,6 +83,19 @@ void setup() { display.drawBitmap(0, 0, logo_data, logo_width, logo_height, SSD1306_WHITE); display.display(); } + + if (sensor0.begin(0x48)) { + //0-3: 0:0.25Hz, 1:1Hz, 2:4Hz, 3:8Hz + sensor0.setConversionRate(2); + sensor0.setExtendedMode(1); + sensor0.wakeup(); + } + if (sensor1.begin(0x49)) { + //0-3: 0:0.25Hz, 1:1Hz, 2:4Hz, 3:8Hz + sensor1.setConversionRate(2); + sensor1.setExtendedMode(1); + sensor1.wakeup(); + } } void i2c_scan() { @@ -204,6 +220,13 @@ void loop() { display.print(digitalRead(REED4) ? '^' : 'v'); display.println(); + auto temp0 = sensor0.readTempC(); + auto temp1 = sensor1.readTempC(); + display.print(F("Temp: ")); + display.println(temp0, 2); + display.print(F(" ")); + display.println(temp1, 2); + display.display(); }