Hi there, I need some help.
I'm trying to get the readings of the BME280 to show on the Waveshare 1.54inch v2 b/w display.
So far I was able to connect both display and BME280 sensor to my Arduino nano 33 iot with ISP communication and I'm getting text on the display and the sensor readings in my serial monitor, but I'm not able to get the code for floating numbers running.
attached is the code so far...
#include <SPI.h>
#include "epd1in54_V2.h"
#include "imagedata.h"
#include "epdpaint.h"
#include <stdio.h>
#include <Wire.h> //BME280
#include <Adafruit_Sensor.h> //BME280
#include <Adafruit_BME280.h> //BME280
#define BME_SCK 13 //BME280
#define BME_MISO 12 //BME280
#define BME_MOSI 11 //BME280
#define BME_CS 6 //BME280
#define SEALEVELPRESSURE_HPA (1013.25) //BME280
Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
Epd epd;
unsigned char image[1024];
Paint paint(image, 0, 0);
unsigned long time_start_ms;
unsigned long time_now_s;
#define COLORED 0
#define UNCOLORED 1
unsigned long delayTime;
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("e-Paper init and clear");
epd.LDirInit();
epd.Clear();
paint.SetWidth(200);
paint.SetHeight(24);
Serial.println("e-Paper paint");
paint.Clear(UNCOLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 40, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(8, 4, "TEMPERATURE", &Font16, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 60, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(8, 4, "HUMIDITY", &Font16, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 80, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(8, 4, "PRESSURE", &Font16, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 100, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(8, 4, "HEIGHT", &Font16, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 120, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
epd.DisplayFrame();
delay(2000);
//Serial.println("e-Paper clear and goto sleep");
//epd.HDirInit();
//epd.Clear();
//epd.Sleep();
while(!Serial); // time to get serial running
Serial.println(F("BME280 test")); //BME280
unsigned status; //BME280
status = bme.begin();
Serial.println("-- Default Test --");
delayTime = 1000;
Serial.println();
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" °C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
}
void loop(){
}
void printValues(){
}
It would be nice if someone knows the correct lines to add to the code so i can display the temperature, humidity, pressure and approximate height.
I also tried to use the Adafruit_GFX.h and Adafruit_SSD1306.h library, but without succes.