1

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...

https://www.dropbox.com/s/swkbtjk6jpd7c … 1.png?dl=0

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 will work on a better colour range algorithm in time.

Enjoy.

/*
   -- 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
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

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


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,0,0,38,0,128,0,11,24,0,
  130,1,18,3,26,24,25,130,1,1,
  29,98,32,25,68,18,3,31,94,28,
  26,1,190,65,31,20,5,22,20,66,
  132,19,4,24,19,26,16,130,0,27,
  12,8,8,26,67,1,26,13,10,6,
  1,24,11,129,0,20,23,22,3,16,
  84,69,77,80,69,82,65,84,85,82,
  69,0,130,1,56,3,26,24,25,65,
  31,58,5,22,20,66,132,57,4,24,
  19,26,16,130,0,65,12,8,8,26,
  67,1,63,13,12,6,190,27,11,129,
  0,62,23,14,3,16,72,85,77,73,
  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)

DHT dht(DHTPIN, DHTTYPE);

// 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 ();
  dht.begin();
}



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)) {
      delay(10);
    }
    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)) {
      delay(10);
    }
    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.'"