1 (edited by Gunner 2021-11-17 23:56:18)

Topic: Simple DHT Display for my desk using ESP-01 and and old tablet.

As the title says, this is just a simple DHT based Temperature and Humidity desktop display that I made for my desk.

To keep the hardware simple, I used an ESP-01 connected to a DHT11 (I didn't have any spare DHT12) and an old Samsung 8" Tablet that is much too slow for anything else.

The idea I had was for Arc Level gauges that dynamically change colour based on their ranges, via the RGB features of the LED as a background.  But lack of Element background transparency became an issue.  So this is what I currently have...


At the moment the LED colours are an extremely simple range between green and red for temperature and green and blue for Humidity.  But I may work on a better colour range algorithm in time.


   -- Temperature and Humidity --

   This source code of graphical user interface
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 2.4.3 or later version
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
     - for ANDROID 4.7.12 or later version;
     - for iOS 1.4.7 or later version;

   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

//        RemoteXY include library          //

// RemoteXY select connection mode and include library
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "ESP-01_Temp_Humid"
#define REMOTEXY_WIFI_PASSWORD "12345678"

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,0,0,38,0,128,0,11,24,0,
  68,73,84,89,0 };

// this structure defines all the variables and events of your control interface
struct {

  // output variables
  float temp_graph;
  float hum_graph;
  uint8_t temp_led_r; // =0..255 LED Red brightness
  uint8_t temp_led_g; // =0..255 LED Green brightness
  uint8_t temp_led_b; // =0..255 LED Blue brightness
  int8_t temp_level; // =0..100 level position
  char temp_txt[11];  // string UTF8 end zero
  uint8_t hum_led_r; // =0..255 LED Red brightness
  uint8_t hum_led_g; // =0..255 LED Green brightness
  uint8_t hum_led_b; // =0..255 LED Blue brightness
  int8_t hum_level; // =0..100 level position
  char hum_txt[11];  // string UTF8 end zero

  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

//           END RemoteXY include          //

#include <Adafruit_Sensor.h>
#include <DHT.h>

#define DHTPIN 0     // Digital pin connected to the DHT sensor

// Uncomment the type of sensor in use:
#define DHTTYPE    DHT11     // DHT 11
//#define DHTTYPE    DHT22     // DHT 22 (AM2302)
//#define DHTTYPE    DHT21     // DHT 21 (AM2301)


// current temperature & humidity, updated in loop()
float t = 0.0;
float h = 0.0;

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;    // will store last time DHT was updated

// Updates DHT readings every 10 seconds
const long interval = 10000;

void setup() {
  RemoteXY_Init ();

void loop() {
  RemoteXY_Handler ();

  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    // save the last time you updated the DHT values
    previousMillis = currentMillis;
    // Read temperature as Celsius (the default)
    float temperature = dht.readTemperature();
    // Read temperature as Fahrenheit (isFahrenheit = true)

    // if temperature read failed, don't change t value
    if (isnan(temperature)) {
    else {
      RemoteXY.temp_graph = temperature;
      RemoteXY.temp_level = temperature;
      dtostrf(temperature, 0, 0, RemoteXY.temp_txt);
      RemoteXY.temp_led_r = map(temperature,0,40,0,255);
      RemoteXY.temp_led_g = map(temperature,0,40,255,0);
    // Read Humidity
    float humidity = dht.readHumidity();
    // if humidity read failed, don't change h value
    if (isnan(humidity)) {
    else {
      RemoteXY.hum_graph = humidity;
      RemoteXY.hum_level = humidity;
      dtostrf(humidity, 0, 0, RemoteXY.hum_txt);
      RemoteXY.hum_led_b = map(humidity,0,100,0,255);
      RemoteXY.hum_led_g = map(humidity,0,100,255,0);
"And voila, which is French for.......'and then I found out.'"


Re: Simple DHT Display for my desk using ESP-01 and and old tablet.