Skip to content
Snippets Groups Projects
Commit 173da652 authored by Benjamin Koch's avatar Benjamin Koch
Browse files

add temperature sensors

The one on the display PCB isn't working, right now.
parent 738f69e1
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment