E-Paper Temperature Monitor

 

E-Paper Temperature Monitor With Web Server

November 2022
Monitor   Graph

 

This project is very similar to the ESP8266 Temperature Logger/Plotter but uses a 1.54" e-paper display instead of the Nokia 5110 LCD. The PC Server/Plotter in this project will work equally well with either the ESP8266 or the ESP32.

Download PC Server/Plotter software

Circuit Diagram

 

The simple circuit is built around a Wemos ESP32 LoLin32 v1.0.0. It should work equally well with an ESP8266 module but, so far, I've not been successful in getting the e-paper display to work with an ESP8266 Mini D1.

Some LoLin ESP32 modules provide access to the battery voltage and even have a dedicated GPIO Pin but, as there's no access to the actual battery connection on the LoLin32 v1.0.0 module, it's not possible to monitor the battery voltage directly from the module.

On the PCB layout, below, the 18650 battery plugs into a separate PH2 JST connector. From there, two 100k resistors form a potential divider across the battery with their junction connecting to the LoLin32 modules GPIO Pin 13 in order to monitor the battery voltage. A short jumper lead connects to the PH2 connector on the LoLin32 module.


Printed Circuit Board

This PCB is based on the ESP32 WeMos LoLin32 v1.0.0. Other ESP32 modules should work but the pin layout will be different so the PCB will need adjusting to suit.

Download Actual size PCB Artwork in PDF format.

Download PCB Artwork in PCB Wizard format.

PCB Wizard Website

 

Setting up the Arduino IDE

If you haven't used the ESP32 in the Arduino environment before, it's necessary to install the ESP32 Board definitions into the Arduino IDE.

In the Arduino IDE, select File -> Preferences.

In the Additional Boards Manager URLs text box, enter: https://dl.espressif.com/dl/package_esp32_index.json then click the OK button. If another entry is already in the Additional Boards Manager URLs text box, separate them with a comma (,).

Select Tools -> Board -> Board Manager...

Wait for the platforms index to download then scroll down the list to esp32 and click Install.

Close the Arduino IDE.

 


Copy the Arduino sketch below and paste it into the IDE.

Find the following four lines near the top of the sketch, edit them to your own WiFi SSID, WiFi Password, your PC's Network address, the Port number and Device ID you've selected for this project and upload the sketch to the ESP32 WeMos LoLin32.

const char* ssid = "**********";                    // Your router's WiFi SSID
const char* password = "**********";                // Your router's Wifi Password

String serverIP = "192.168.1.3:8835";               // Your PC's network address and the port
                                                    // you've chosen for this project.

String device_id = "room";                          // The device ID for this project.

 

 

The Arduino Sketch


#include <GxEPD.h>

#include <GxGDEH0154D67/GxGDEH0154D67.h>       // 1.54" b/w epaper display

#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>

#include <Fonts/FreeSansBold18pt7b.h>

#include <OneWire.h>
#include <DallasTemperature.h>

#include <WiFi.h>
#include <HTTPClient.h>

#define ONE_WIRE_BUS 15
#define VOLTS_PIN 13


OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// Waveshare e-paper connections to ESP32

// Vcc -> 3v
// GND -> GND
// DIN -> MOSI (GPIO 23)
// CLK -> CLK  (GPIO 18)
// CS  -> SS   (GPIO 5)
// DC  -> GPIO 17
// RST -> GPIO 16
// BUSY-> GPIO 4

GxIO_Class io(SPI, /*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16); // arbitrary selection of 17, 16
GxEPD_Class display(io, /*RST=*/ 16, /*BUSY=*/ 4);        // arbitrary selection of (16), 4

 
RTC_DATA_ATTR  float  previous_temperature = 0.0;   // This variable's value is retained when 
                                                    // the ESP32 resets.                                                    

const char* ssid = "**********";                    // Your router's WiFi SSID
const char* password = "**********";                // Your router's Wifi Password

String serverIP = "192.168.1.3:8835";               // Your PC's network address and the port
                                                    // you've chosen for this project.

String device_id = "room";                          // The device ID for this project.

int sleep_interval = 5;          // minutes to wait between temperature measurements.
int retry_interval = 1;          // minutes to wait before retrying to connect WiFi.


boolean METRIC = true;           //Set true for celcius; false for fahrenheit.

float temperature = 0.0;

float mVolts = 0.0;              

long rssi;


float getTemperatureFromSensor(){
  sensors.requestTemperatures();
  if(METRIC)  {
    temperature = sensors.getTempCByIndex(0);
  }else  {
    temperature = sensors.getTempFByIndex(0);
  }
  temperature = round(temperature * 10) / 10;
  return temperature;
}


void setup() {

 sensors.begin();

 int vref = 1100;
 uint16_t v = analogRead(VOLTS_PIN);                    // Read adc value at R1/R2 junction

 float mVolts = ((float)v / 4095.0) * 2 * 3.2 * vref;   // Convert value to mVolts.

 temperature = getTemperatureFromSensor();              // Get temperature from DS18B20

 WiFi.begin(ssid, password);                            // Start the WiFi connection.

 int wifi_timeout = 0;                                  // Attempt to connect
 while (WiFi.status() != WL_CONNECTED) {
    delay(10);
    wifi_timeout++;
    if (wifi_timeout > 1000)   {                        // Connect to WiFi failed - deep sleep...
       deepSleep(retry_interval);                       // .. for the retry interval.
    }
 }

 if (WiFi.status() == WL_CONNECTED)  {                  // WiFi connected to router.
  
    rssi = WiFi.RSSI();                                 // Get WiFi signal strength.

    HTTPClient http;                                    // Create an HTTP Client instance.

    // Specify the HTTP request's destination, including port and your GET variables
     
    String http_request = "";
    
    http_request = "http://" + serverIP  + "/?";
    http_request += "id=" + device_id;
    
    http_request += "&leftaxis=" + String(temperature);
    http_request += "&rightaxis=" + String(mVolts);

    http_request += "&rssi=" + String(rssi);  
    http_request += "&interval=" + String(sleep_interval);
      
    http.begin(http_request);  

    // Send the request
    int httpCode = http.GET();

    // Check the returning HTTP code
    if (httpCode > 0) {
      // Get a response back from the server
      String payload = http.getString();
    }

    // Close the HTTP connection
    http.end(); 
 }      

 if (abs(previous_temperature - temperature) > 0.1 ) {   // If the temperature has changed by
                                                         // more than 0.1 degrees, then update display.
   previous_temperature = temperature;
   display.init();
   display.setRotation(45);
    
   display.setTextColor(GxEPD_BLACK);
  
   display.fillScreen(GxEPD_WHITE); 
   display.setTextSize(2); 
   display.setCursor(20, 10);
   display.print("TEMPERATURE C");
   
   display.setCursor(10, 180);
   display.print(mVolts / 1000, 2);
   display.print("v");

   display.setCursor(120, 180);
   display.print(rssi);
   display.print("dB");
   
   display.setFont(&FreeSansBold18pt7b);
   
   display.setCursor(30, 120);
   display.print(temperature, 1); 

   display.update();

 }

 deepSleep(sleep_interval);             

}

void deepSleep(int interval) {
  esp_sleep_enable_timer_wakeup(interval  * 60  *1000 * 1000);                 
   
  esp_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);

  esp_deep_sleep_start(); 
}


void loop() {
  // Nothing to see here.
}

 

Back to Index

 


This site and its contents are © Copyright 2005 - All Rights Reserved.