Help with my project <> Smart Thermostat
First, i'm good at googling, copy/paste etc. I'm not a coder in the way i can make it up myself.
I'm working on a project to implement a smart thermostat in my house at low cost.
I found this project wich works, no problem. But i want to add a display which will display the current temperature. I found this piece of code:
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_BMP280 BMP;
void setup() {
Serial.begin(115200);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
bool status = BMP.begin(0x76);
if (!status) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
delay(2000);
display.clearDisplay();
display.setTextColor(WHITE);
}
void loop() {
display.clearDisplay();
// display temperature
display.setTextSize(1);
display.setCursor(0,0);
display.print("Temperature: ");
display.setTextSize(2);
display.setCursor(0,10);
display.print(String(BMP.readTemperature()));
display.print(" ");
display.setTextSize(1);
display.cp437(true);
display.write(167);
display.setTextSize(2);
display.print("C");
display.display();
delay(1000);
}
This works, but now, how to merge the two.?
The sensor works, the libraries are added. But where to add the display code, i tried to add it on a lot of different places en tried to change things but no luck. I changed the "display.print(String(BMP.readTemperature()));"
to
"display.print(Temperature);"
And now i'm falling short on knowledge
Thanks in advance