Skip to content

Use of Adafruit ESP32 Huzzah V2, BME280 and Eink screen to record weather data.

Notifications You must be signed in to change notification settings

flamerten/EinkWeatherMonitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Esp32 EinkWeatherMonitor

This E-Ink Weather Monitor uses a BME280 sensor to read and display temperature and humidity data every 15 minutes on an Eink Screen. A PCB for the components was designed, and was enclosed in a 3D printed case.

Contents

Firmware

Explanation and code for the ESP32, connected to the Eink screen and BME280

Hardware

Software

Instructions to set up bluehost to recieve weather data from the ESP32 and publish to an online graph. These were mainly adapted from this source. This was depreceated because paying for Bluehost was expensive and after a while I didn't see value in storingw weather data over the long term. The PHP documentation can be found here, Link. The Firmware section also goes over how to post data. The implementation can be found in this previous commit

Firmware

ESP32

An Adafruit ESP32 Huzzah v2 was used because it could fit in the breadboard better and had Lipo charging capabilities. Hence, this could be used a more portable project.

The ESP32 code is simple. The BME280 sensor is wired to the ESP32 and the sensor data is posted in the format. Note that serverName is the post data website, for instance: https://example/post-data.php.

WiFiClient client;
HTTPClient http;
http.begin(client, serverName);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
String httpRequestData = "api_key=" + apiKeyValue + "&value1=" + String(bme.readTemperature())
                       + "&value2=" + String(bme.readHumidity()) + "&value3=" + String(bme.readPressure()/100.0F) + "";
Serial.print("httpRequestData: ");
Serial.println(httpRequestData);

int httpResponseCode = http.POST(httpRequestData);

I added the deep sleep functionality for it to get data every 10mins. Hence the trend of data is better seen. With a maximum of 40 data points, we can see how the data changes over around 6 hours.

For the time function, I used the internal RTC memory and the NTP Client server to get the time which is printed on the Eink screen. There will be times that the post function does not work, or WiFi is not connected, and I still want to see the last reading. The NTP Client Server is initially used to get the time and is saved to RTC memory. If wifi is not connected, then the RTC memory is incremented by 10mins and that is displayed.

Note that the RTC memory will be initialised on boot up to the assigned value. After that it uses past stored RTC values.

The Secrets.h file was used to protect personal data. To use my code, create a header file called Secrets.h and fill in the following detais.

//Private info, in Gitignore

const char* WIFI_SSID = "WIFI";
const char* WIFI_PASSWORD = "WIFI_PASS";

const char* OTA_SSID = "OTA_WIFI";
const char* OTA_PASSWORD = "OTA_PASS";

const char* BLUEHOST_POST = "BLUEHOST_POST";

String ESP32_API_KEY = "PERSONAL_ESP32_API";

The USB port is only for charging the Huzzah. There is no data cable due to mistakes in the PCB. Hence, the push button is designed to push the ESP32 into OTA mode.

  1. Push button will wake the ESP32 and connect to the OTA WiFI
  2. From there, the IP address is printed on the Eink screen. Connect to IP_address/update over the OTA wifi to upload code over OTA.

Eink Screen

I added an Eink screen to display the latest data. The GxEPD2 Library was used with the MH-ET 2.9" Live Epaper Display (AliExpressLink).

I used this source to set up the Epaper display. Its alot simpler than the example given in the GxEPD2 Library. The SPI wiring is also different from standard ESP32s and I thus had to remap the values and initialise it differently. However, this method is probably the neatest, even for future applications rather than the example given.

#include <SPI.h>
#include <GxEPD2_BW.h>

#define EPD_BUSY  32  // to EPD BUSY
#define EPD_CS    15  // to EPD CS
#define EPD_RST   27 // to EPD RST
#define EPD_DC    33 // to EPD DC
#define EPD_SCK   5 // to EPD CLK
#define EPD_MISO  21 // Master-In Slave-Out not used, as no data from display
#define EPD_MOSI  19 // to EPD DIN

//specific to eink screen
GxEPD2_BW<GxEPD2_290_T94, GxEPD2_290_T94::HEIGHT> display(GxEPD2_290_T94(EPD_CS, EPD_DC, EPD_RST, EPD_BUSY));

void setup(){
    SPI.begin(EPD_SCK, EPD_MISO, EPD_MOSI, EPD_CS);
    display.init(115200);
}

Note that for this library, display.init initialises the Serial.begin function, and thus there is no need to call it again. Calling Serial.begin(115200) before the init will lead to the ESP32 hanging. This was discovered from this source.

Hardware

Case Comments

  • STL Files & PCB Files
  • Holes at the side are used to allow ventillation from surrounding air, allowing the BME280 to read environmental data
  • There was a mistake made in the PCB design, and I was thus forced to reroute the power cables to an external USB-C plug. Hence, OTA is used to program the board while the USB-C cable is used to charge the Lipo Battery.
  • 4 M3 screws are threaded into the case to fix the cover over the bottom case.

Energy

Energy usage was measured using a multimeter. One full cycle of waking up was noted to consume around 0.011mWh. So for a device that refreshes every 10minutes, the energy consumption is 13.65 mW/day. The device can thus last around 36 days on a 500mAH battery.

In designing the firmware, energy saving was taken into consideration. Both the BME sensor (line 514 of esp32_bme.ino) and the ESP32 were designed to go to sleep after completeing their respective jobs.

Enabling or searching for WiFi can be energy consuming. Thus uploading sensor data and updating the time client data was done just before the appliance is about to go to sleep.

About

Use of Adafruit ESP32 Huzzah V2, BME280 and Eink screen to record weather data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published