ESP 01 DHT11 and the ThingSpeak Cloud Write Data

Arduino tutorial: This module uses the ESP-01 or the ESP-01S as the master control, and the DHT11 ... Humidity Monitoring Using the ESP-01 & DHT and the ThingSpeak Cloud.

 DHT22 Temperature Humidity Sensor

Code

/*
 
 * DHT Temperature and humidity monitoring using ESP01 and the thingspeak 
 * Description: This examples connects the ESP to wifi, and sends Temperature and humidity to thingspeak IoT platfom over HTTPS GET Request.
 * https://thingspeak.com
 * github: https://github.com/mathworks/thingspeak-arduino
 * DHT11 library (DHT11) found at https://github.com/winlinvip/SimpleDHT
 * More videos : https://www.youtube.com/channel/UCCC8DuqicBtP3A_aC53HYDQ/videos
 */

// includes
#include "ESP8266WiFi.h"
#include "WiFiClientSecure.h"
#include "SimpleDHT.h"

// user config: 
const char* wifi_ssid = "MySSID";             // replace MySSID with your WiFi network name
const char* wifi_password = "MyPassword";         // replace MyPassword with your WiFi password
const char* apiKeyIn = "APIKEYIN";      // replace APIKEYIN with your channel write API Key
const unsigned int writeInterval = 25000; // write interval (in ms)

// thingspeak config.
const char* https_host = "api.thingspeak.com";         // thingspeak host name
const int https_port = 443;                        // https port 
// DHT config.
int pinDHT11 = 2;
SimpleDHT11 dht11(pinDHT11);
// create thingspeak client
WiFiClientSecure client;

void getTem()
{
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    delay(100);
    return;
  }
  if (!client.connect(https_host, https_port)) {
  delay(200);
  return;
  }
  // Create a URL for the request
  String url = "/update?api_key=";
  url += apiKeyIn;
    url += "&field1=";
  url += ((int)temperature);
  url += "&field2=";
  url += ((int)humidity);
  

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + https_host + "\r\n" +
               "Connection: close\r\n\r\n");

  client.connected();
}
void setup() {
  WiFi.begin(wifi_ssid, wifi_password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  // Set Client to insecure
  client.setInsecure();
}

void loop() {
         getTem();
  delay(20000);

}

MAX7219 RTC DS1307 dht11 led matrix clock Arduino

MAX7219 LED Matrix Display & RTC DS1307 - dht11 - Arduino


VCC→5V
GND→GND
DIN→11
CS →10
CLK→13

Schema


Code

// Program to demonstrate the MD_Parola library
//
// Display the time in one zone and other information scrolling through in
// another zone.
// - Time is shown in a user defined fixed width font
// - Scrolling text uses the default font
// - Temperature display uses user defined characters
// - Optional use of DS1307 module for time and DHT11 sensor for temp and humidity
// - DS1307 library (MD_DS1307) found at https://github.com/MajicDesigns/DS1307
// - DHT11 library (DHT11_lib) found at https://github.com/mathworks/thingspeak-arduino
//
// NOTE: MD_MAX72xx library must be installed and configured for the LED
// matrix type being used. Refer documentation included in the MD_MAX72xx
// library or see this link:
// https://majicdesigns.github.io/MD_MAX72XX/page_hardware.html
//

#define USE_DS1307

// Header file includes
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <Wire.h>
#include <MD_DS1307.h>
#include <SimpleDHT.h>
#include "Font_Data.h"

// DHT config.
int pinDHT11 = 2;
SimpleDHT11 dht11(pinDHT11);

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

// HARDWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);




volatile boolean buttonA = false;
volatile boolean buttonB = false;
volatile boolean buttonC = false;
int StateOfbuttonA = 0;
int StateOfbuttonB = 0;  
int StateOfbuttonC = 0;        
int NewStateOfbuttonA = 0;        
int NewStateOfbuttonB = 0;        
int NewStateOfbuttonC = 0;  
int Mode = 0;
int contrast = 0;
int SPEED_TIME = 75;

#define PAUSE_TIME  0

#define MAX_MESG  20

// Global variables
char szTime[9];    // hh:mm
char szsecond[4];    // ss
char szMesg[MAX_MESG+1] = "";

uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C

char *mon2str(uint8_t mon, char *psz, uint8_t len)

// Get a label from PROGMEM into a char array
{
  static const __FlashStringHelper* str[] =
  {
    F("Jan"), F("Feb"), F("Mar"), F("Apr"),
    F("May"), F("Jun"), F("Jul"), F("Aug"),
    F("Sep"), F("Oct"), F("Nov"), F("Dec")
  };

  strncpy_P(psz, (const char PROGMEM *)str[mon-1], len);
  psz[len] = '\0';

  return(psz);
}

char *dow2str(uint8_t code, char *psz, uint8_t len)
{
  static const __FlashStringHelper*  str[] =
  {
    F("Sunday"), F("Monday"), F("Tuesday"),F("Wednesday"), 
    F("Thursday"), F("Friday"),
    F("Saturday")
  };

  strncpy_P(psz, (const char PROGMEM *)str[code-1], len);
  psz[len] = '\0';

  return(psz);
}

void getTime(char *psz, bool f = true)
// Code for reading clock time
{
   RTC.readTime();
  sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
}
void getTim(char *psz, bool f = true)
// Code for reading clock time
{
   RTC.readTime();
  sprintf(psz, "%02d%c%02d", RTC.h, ':', RTC.m);
}

void getDate(char *psz)
// Code for reading clock date
{
  char  szBuf[10];

  RTC.readTime();
  sprintf(psz, "%d %s %04d", RTC.dd, mon2str(RTC.mm, szBuf, sizeof(szBuf)-1), RTC.yyyy);

}
void getTem(char *psz, bool f = true)
// Code for reading clock date
{
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    delay(100);
    return;
  }
  sprintf(psz, "%02d", (int)temperature);

}
void getHumi(char *psz, bool f = true)
// Code for reading clock date
{
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    delay(100);
    return;
  }
  sprintf(psz, "%02d", (int)humidity);

}

void getsecond(char *psz)
// Code for reading clock date
{
  char  szBuf[10];

  RTC.readTime();
  sprintf(psz, "%02d", RTC.s);
}


void gethh(char *psz, bool f = true)
// Code for reading clock time
{
   RTC.readTime();
  sprintf(psz, "%c%02d%c%02d", (f ? ':' : ' '), RTC.h, (f ? ':' : ' '), RTC.m);
}


void getmin(char *psz, bool f = true)
// Code for reading clock time
{
   RTC.readTime();
  sprintf(psz, "%02d%c%02d%c", RTC.h, (f ? ':' : ' '), RTC.m, (f ? ':' : ' '));
}

void getsec(char *psz)
// Code for reading clock date
{
  char  szBuf[10];

  RTC.readTime();
  sprintf(psz, "%02d", RTC.s);
}

void getdyy(char *psz)
{
  char  szBuf[10];

  RTC.readTime();
  sprintf(psz, "%02d", RTC.dd);

}

void getmon(char *psz)
// Code for reading clock date
{
  char  szBuf[10];

  RTC.readTime();
  sprintf(psz, "%s", mon2str(RTC.mm, szBuf, sizeof(szBuf)-1));

}

void getyyyy(char *psz)
// Code for reading clock date
{
  char  szBuf[10];

  RTC.readTime();
  sprintf(psz, "%04d", RTC.yyyy);

}





void setup(void)
{
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  P.begin(3);
  P.setInvert(false);
  P.setZone(2, 0, 3);
  P.setZone(1, 1, 3);
  P.setZone(0, 4, 1);
  P.setFont(1, numeric7Se);
  P.setFont(0, numeric7Seg);
  P.displayZoneText(1, szTime, PA_LEFT, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
  P.displayZoneText(0, szsecond, PA_LEFT, SPEED_TIME, 0, PA_PRINT, PA_NO_EFFECT);
  P.displayZoneText(2, szMesg, PA_CENTER, SPEED_TIME, 0, PA_PRINT, PA_SCROLL_LEFT);
  P.addChar('$', degC);
  RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
  RTC.control(DS1307_12H, DS1307_OFF);
  getTime(szTime);
}

void loop(void)
{
  P.setIntensity(contrast);
  NewStateOfbuttonA = digitalRead(3);
  NewStateOfbuttonB = digitalRead(4);
  NewStateOfbuttonC =   digitalRead(5);
  buttonAisPressed();
  buttonBisPressed();
  buttonCisPressed();


      if (buttonA) {
   if (Mode == 0 ) {
    buttonA = false;
    contrast++;
    if (contrast >= 51 ) {
    contrast = 50;
  } 
    }   
  else if (Mode == 1 ) {
    buttonA = false;
      Mode = 0;
  } 
  else if (Mode == 2 ) {
    buttonA = false;
    RTC.h++;
    if (RTC.h >= 24 ) {
    RTC.h = 0;
  }
    RTC.writeTime();
  }
  else if (Mode == 3 ) {
    buttonA = false;
    RTC.m++;
    if (RTC.m >= 60 ) {
    RTC.m = 0;
  }
    RTC.writeTime();
  }
  else if (Mode == 4 ) {
    buttonA = false;
      RTC.s = 0;
    RTC.writeTime();
  }
  else if (Mode == 5 ) {
    buttonA = false;
    RTC.dow++;
    if (RTC.dow >= 8 ) {
    RTC.dow = 1;
  } 
    RTC.writeTime();
    P.displayReset(2);
  }
  else if (Mode == 6 ) {
    buttonA = false;
    RTC.dd++;
    if (RTC.dd >= 32 ) {
    RTC.dd = 1;
  }
    RTC.writeTime();
  }    
  else if (Mode == 7 ) {
    buttonA = false;
    RTC.mm++;
    if (RTC.mm >= 13 ) {
    RTC.mm = 1;
  }
    RTC.writeTime();
  }      
  else if (Mode == 8 ) {
    buttonA = false;
    RTC.yyyy++;
    if (RTC.yyyy >= 2035 ) {
    RTC.yyyy = 2015;
  }  
    RTC.writeTime();
       }
  }

   else if (buttonB) {
    buttonB = false;
      Mode++;
    P.displayReset(2);
      if (Mode >= 9 ) {
      Mode = 0;
  }
    }


    
   if (buttonC) {
   if (Mode == 0 ) {
    buttonC = false;
    contrast--;
    if (contrast <= 0 ) {
    contrast = 0;
  } 
    }   
  else if (Mode == 1 ) {
    buttonC = false;
      Mode = 0;
  } 
  else if (Mode == 2 ) {
    buttonC = false;
    RTC.h--;
    if (RTC.h <= 0 ) {
    RTC.h = 23;
  } 
    RTC.writeTime();
  }
  else if (Mode == 3 ) {
    buttonC = false;
    RTC.m--;
    if (RTC.m <= 0 ) {
    RTC.m = 59;
  } 
    RTC.writeTime();
  }
  else if (Mode == 4 ) {
    buttonC = false;
      RTC.s = 0;
    RTC.writeTime();
  }
  else if (Mode == 5 ) {
    buttonC = false;
    RTC.dow--;
    if (RTC.dow <= 0 ) {
    RTC.dow = 7;
  } 
    RTC.writeTime();
    P.displayReset(2);
  }
  else if (Mode == 6 ) {
    buttonC = false;
    RTC.dd--;
    if (RTC.dd <= 0 ) {
    RTC.dd = 31;
  } 
    RTC.writeTime();
  }    
  else if (Mode == 7 ) {
    buttonC = false;
    RTC.mm--;
    if (RTC.mm <= 0 ) {
    RTC.mm = 12;
  } 
    RTC.writeTime();
  }      
  else if (Mode == 8 ) {
    buttonC = false;
    RTC.yyyy--;
    if (RTC.yyyy <= 2010 ) {
    RTC.yyyy = 2025;
  } 
    RTC.writeTime();
  }  
       }

  if (Mode == 0) 
  { 
  static uint32_t lastTime = 0; // millis() memory
  static bool flasher = false;  // seconds passing flasher
  P.displayAnimate();
  P.setTextEffect(2, PA_PRINT, PA_NO_EFFECT);
  P.getZoneStatus(1);
  P.getZoneStatus(0);
    if (millis() - lastTime >= 1000)
  {
    lastTime = millis();
    getsecond(szsecond);
    getTime(szTime, flasher);
    flasher = !flasher;
    P.displayReset(1);
    P.displayReset(0);
  } 
  }

  if (Mode == 1) 
  {
  static uint8_t  display = 0;  // current display mode
  P.displayAnimate();
  P.getZoneStatus(2);
if (P.getZoneStatus(2))
  {
    switch (display)
    {
      case 0: // Time
        P.setTextEffect(2, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
         getTim(szMesg);
        break;

      case 1: // Day
        P.setTextEffect(2, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
        dow2str(RTC.dow, szMesg, MAX_MESG);
        break;

      case 2:  // Calendar
        P.setTextEffect(2, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
        getDate(szMesg);
        break;
        
      case 3: // Humidity
        P.setTextEffect(2, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
         getHumi(szMesg);
          strcat(szMesg, "% RH");
        break;
        
       default: // Temperature deg C
        P.setTextEffect(2, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display = 0;
         getTem(szMesg);
          strcat(szMesg, "$");
        break;
    }

    P.displayReset(2);
  } 
  }


    if (Mode == 2) 
  { 
  static uint32_t lastTime = 0; // millis() memory
  static bool flasher = false;  // seconds passing flasher
  P.displayAnimate();
  P.setTextEffect(2, PA_PRINT, PA_NO_EFFECT);
  P.getZoneStatus(1);
  P.getZoneStatus(0);
    if (millis() - lastTime >= 200)
  {
    lastTime = millis();
    getsecond(szsecond);
    gethh(szTime, flasher);
    flasher = !flasher;
    P.displayReset(1);
    P.displayReset(0);
  } 
  }



    if (Mode == 3) 
  { 
  static uint32_t lastTime = 0; // millis() memory
  static bool flasher = false;  // seconds passing flasher
  P.displayAnimate();
  P.setTextEffect(2, PA_PRINT, PA_NO_EFFECT);
  P.getZoneStatus(1);
  P.getZoneStatus(0);
    if (millis() - lastTime >= 200)
  {
    lastTime = millis();
    getsecond(szsecond);
    getmin(szTime, flasher);
    flasher = !flasher;
    P.displayReset(1);
    P.displayReset(0);
  } 
  }


    if (Mode == 4) 
  { 
  static uint32_t lastTime = 0; // millis() memory
  static bool flasher = false;  // seconds passing flasher
  P.displayAnimate();
  P.setTextEffect(2, PA_PRINT, PA_NO_EFFECT);
  P.getZoneStatus(1);
  P.getZoneStatus(0);
    if (millis() - lastTime >= 200)
  {
    lastTime = millis();
    getTim(szTime);
    getsecond(szsecond);
    P.displayReset(1);
    P.displayReset(0);
  } 
  }

 


 

    if (Mode == 5) 
  { 
  static uint8_t  display = 0;  // current display mode
  P.displayAnimate();
  P.getZoneStatus(2);
        P.setTextEffect(2, PA_PRINT, PA_SCROLL_LEFT);
        dow2str(RTC.dow, szMesg, MAX_MESG);

    P.displayReset(2);
  }


 

    if (Mode == 6) 
  { 
  P.displayAnimate();
  P.getZoneStatus(2);
    P.setTextEffect(2, PA_PRINT, PA_NO_EFFECT);
        getdyy(szMesg);
    P.displayReset(2);
  }

    if (Mode == 7) 
  { 
  P.displayAnimate();
  P.getZoneStatus(2);
    P.setTextEffect(2, PA_PRINT, PA_NO_EFFECT);
        getmon(szMesg);
    P.displayReset(2);
  }


 

    if (Mode == 8) 
  { 
  P.displayAnimate();
  P.getZoneStatus(2);
    P.setTextEffect(2, PA_PRINT, PA_NO_EFFECT);
        getyyyy(szMesg);
    P.displayReset(2);
  }
 
 
}
  void buttonAisPressed()
  {
    if (NewStateOfbuttonA != StateOfbuttonA) 
  {
    if (NewStateOfbuttonA == 0) 
    {
      buttonA=true;
    }
    delay(50);
  }
   StateOfbuttonA = NewStateOfbuttonA;
  }

void buttonBisPressed()
{
  if (NewStateOfbuttonB != StateOfbuttonB) 
  {
    if (NewStateOfbuttonB == 0) {
      buttonB=true;
    }
    delay(50);
  }
   StateOfbuttonB = NewStateOfbuttonB;
}

void buttonCisPressed()
{
   if (NewStateOfbuttonC != StateOfbuttonC) 
  {
    if (NewStateOfbuttonC == 0) {
      buttonC=true;
    }
    delay(50);
  }
   StateOfbuttonC = NewStateOfbuttonC;
}

Font_Data.h

// Data file for user example user defined fonts
#ifndef FONTDATA_H
#define FONTDATA_H

MD_MAX72XX::fontType_t numeric7Seg[] PROGMEM = 
{
  0,    // 0
  0,    // 1
  0,    // 2
  0,    // 3
  0,    // 4
  0,    // 5
  0,    // 6
  0,    // 7
  0,    // 8
  0,    // 9
  0,    // 10
  0,    // 11
  0,    // 12
  0,    // 13
  0,    // 14
  0,    // 15
  0,    // 16
  0,    // 17
  0,    // 18
  0,    // 19
  0,    // 20
  0,    // 21
  0,    // 22
  0,    // 23
  0,    // 24
  0,    // 25
  0,    // 26
  0,    // 27
  0,    // 28
  0,    // 29
  0,    // 30
  0,    // 31
  1, 0,   // 32 - 'Space'
  0,    // 33 - '!'
  0,    // 34 - '"'
  0,    // 35 - '#'
  0,    // 36 - '$'
  0,    // 37 - '%'
  0,    // 38 - '&'
  0,    // 39 - '''
  0,    // 40 - '('
  0,    // 41 - ')'
  0,    // 42 - '*'
  0,    // 43 - '+'
  0,    // 44 - ','
  0,    // 45 - '-'
  1, 64,    // 46 - '.'
  0,    // 47 - '/'
  3, 62, 34, 62,  // 48 - '0'
  3, 36, 62, 32,      // 49 - '1'
  3, 58, 42, 46,    // 50 - '2'
  3, 42, 42, 62,    // 51 - '3'
  3, 14, 8, 62,    // 52 - '4'
  3, 46, 42, 58,    // 53 - '5'
  3, 62, 42, 58,  // 54 - '6'
  3, 6, 2, 62,    // 55 - '7'
  3, 62, 42, 62,  // 56 - '8'
  3, 46, 42, 62,  // 57 - '9'
  1, 20,    // 58 - ':'
  0,    // 59 - ';'
  0,    // 60 - '<'
  0,    // 61 - '='
  0,    // 62 - '>'
  0,    // 63 - '?'
  0,    // 64 - '@'
  5, 127, 9, 9, 9, 127,   // 65 - 'A'
  5, 127, 73, 73, 73, 54,   // 66 - 'B'
  5, 127, 65, 65, 65, 65,   // 67 - 'C'
  5, 127, 65, 65, 65, 62,   // 68 - 'D'
  5, 127, 73, 73, 73, 73,   // 69 - 'E'
  5, 127, 9, 9, 9, 9,     // 70 - 'F'
  0,    // 71 - 'G'
  0,    // 72 - 'H'
  0,    // 73 - 'I'
  0,    // 74 - 'J'
  0,    // 75 - 'K'
  0,    // 76 - 'L'
  0,    // 77 - 'M'
  0,    // 78 - 'N'
  0,    // 79 - 'O'
  0,    // 80 - 'P'
  0,    // 81 - 'Q'
  0,    // 82 - 'R'
  0,    // 83 - 'S'
  0,    // 84 - 'T'
  0,    // 85 - 'U'
  0,    // 86 - 'V'
  0,    // 87 - 'W'
  0,    // 88 - 'X'
  0,    // 89 - 'Y'
  0,    // 90 - 'Z'
  0,    // 91 - '['
  0,    // 92 - '\'
  0,    // 93 - ']'
  0,    // 94 - '^'
  0,    // 95 - '_'
  0,    // 96 - '`'
  5, 127, 9, 9, 9, 127,   // 97 - 'a'
  5, 127, 73, 73, 73, 54,   // 98 - 'b'
  5, 127, 65, 65, 65, 65,   // 99 - 'c'
  5, 127, 65, 65, 65, 62,   // 100 - 'd'
  5, 127, 73, 73, 73, 73,   // 101 - 'e'
  5, 127, 9, 9, 9, 9,     // 102 - 'f'
  0,    // 103 - 'g'
  0,    // 104 - 'h'
  0,    // 105 - 'i'
  0,    // 106 - 'j'
  0,    // 107 - 'k'
  0,    // 108 - 'l'
  0,    // 109 - 'm'
  0,    // 110 - 'n'
  0,    // 111 - 'o'
  0,    // 112 - 'p'
  0,    // 113 - 'q'
  0,    // 114 - 'r'
  0,    // 115 - 's'
  0,    // 116 - 't'
  0,    // 117 - 'u'
  0,    // 118 - 'v'
  0,    // 119 - 'w'
  0,    // 120 - 'x'
  0,    // 121 - 'y'
  0,    // 122 - 'z'
  0,    // 123 - '{'
  1, 127,   // 124 - '|'
  0,    // 125
  0,    // 126
  0,    // 127
  0,    // 128
  0,    // 129
  0,    // 130
  0,    // 131
  0,    // 132
  0,    // 133
  0,    // 134
  0,    // 135
  0,    // 136
  0,    // 137
  0,    // 138
  0,    // 139
  0,    // 140
  0,    // 141
  0,    // 142
  0,    // 143
  0,    // 144
  0,    // 145
  0,    // 146
  0,    // 147
  0,    // 148
  0,    // 149
  0,    // 150
  0,    // 151
  0,    // 152
  0,    // 153
  0,    // 154
  0,    // 155
  0,    // 156
  0,    // 157
  0,    // 158
  0,    // 159
  0,    // 160
  0,    // 161
  0,    // 162
  0,    // 163
  0,    // 164
  0,    // 165
  0,    // 166
  0,    // 167
  0,    // 168
  0,    // 169
  0,    // 170
  0,    // 171
  0,    // 172
  0,    // 173
  0,    // 174
  0,    // 175
  0,    // 176
  0,    // 177
  0,    // 178
  0,    // 179
  0,    // 180
  0,    // 181
  0,    // 182
  0,    // 183
  0,    // 184
  0,    // 185
  0,    // 186
  0,    // 187
  0,    // 188
  0,    // 189
  0,    // 190
  0,    // 191
  0,    // 192
  0,    // 193
  0,    // 194
  0,    // 195
  0,    // 196
  0,    // 197
  0,    // 198
  0,    // 199
  0,    // 200
  0,    // 201
  0,    // 202
  0,    // 203
  0,    // 204
  0,    // 205
  0,    // 206
  0,    // 207
  0,    // 208
  0,    // 209
  0,    // 210
  0,    // 211
  0,    // 212
  0,    // 213
  0,    // 214
  0,    // 215
  0,    // 216
  0,    // 217
  0,    // 218
  0,    // 219
  0,    // 220
  0,    // 221
  0,    // 222
  0,    // 223
  0,    // 224
  0,    // 225
  0,    // 226
  0,    // 227
  0,    // 228
  0,    // 229
  0,    // 230
  0,    // 231
  0,    // 232
  0,    // 233
  0,    // 234
  0,    // 235
  0,    // 236
  0,    // 237
  0,    // 238
  0,    // 239
  0,    // 240
  0,    // 241
  0,    // 242
  0,    // 243
  0,    // 244
  0,    // 245
  0,    // 246
  0,    // 247
  0,    // 248
  0,    // 249
  0,    // 250
  0,    // 251
  0,    // 252
  0,    // 253
  0,    // 254
  0,    // 255
};

MD_MAX72XX::fontType_t numeric7Se[] PROGMEM = 
{
  0,    // 0
  0,    // 1
  0,    // 2
  0,    // 3
  0,    // 4
  0,    // 5
  0,    // 6
  0,    // 7
  0,    // 8
  0,    // 9
  0,    // 10
  0,    // 11
  0,    // 12
  0,    // 13
  0,    // 14
  0,    // 15
  0,    // 16
  0,    // 17
  0,    // 18
  0,    // 19
  0,    // 20
  0,    // 21
  0,    // 22
  0,    // 23
  0,    // 24
  0,    // 25
  0,    // 26
  0,    // 27
  0,    // 28
  0,    // 29
  0,    // 30
  0,    // 31
  1, 0,   // 32 - 'Space'
  0,    // 33 - '!'
  0,    // 34 - '"'
  0,    // 35 - '#'
  0,    // 36 - '$'
  0,    // 37 - '%'
  0,    // 38 - '&'
  0,    // 39 - '''
  0,    // 40 - '('
  0,    // 41 - ')'
  0,    // 42 - '*'
  0,    // 43 - '+'
  0,    // 44 - ','
  0,    // 45 - '-'
  1, 64,    // 46 - '.'
  0,    // 47 - '/'
  4, 127, 65, 65, 127,  // 48 - '0'
  4, 0, 66, 127, 64,     // 49 - '1'
  4, 121, 73, 73, 79,   // 50 - '2'
  4, 99, 73, 73, 119,   // 51 - '3'
  4, 15, 8, 8, 127,    // 52 - '4'
  4, 79, 73, 73, 121,   // 53 - '5'
  4, 127, 73, 73, 121,  // 54 - '6'
  4, 3, 1, 125, 3,     // 55 - '7'
  4, 119, 73, 73, 119,  // 56 - '8'
  4, 79, 73, 73, 127,   // 57 - '9'
  1, 20,    // 58 - ':'
  0,    // 59 - ';'
  0,    // 60 - '<'
  0,    // 61 - '='
  0,    // 62 - '>'
  0,    // 63 - '?'
  0,    // 64 - '@'
  5, 127, 9, 9, 9, 127,   // 65 - 'A'
  5, 127, 73, 73, 73, 54,   // 66 - 'B'
  5, 127, 65, 65, 65, 65,   // 67 - 'C'
  5, 127, 65, 65, 65, 62,   // 68 - 'D'
  5, 127, 73, 73, 73, 73,   // 69 - 'E'
  5, 127, 9, 9, 9, 9,     // 70 - 'F'
  0,    // 71 - 'G'
  0,    // 72 - 'H'
  0,    // 73 - 'I'
  0,    // 74 - 'J'
  0,    // 75 - 'K'
  0,    // 76 - 'L'
  0,    // 77 - 'M'
  0,    // 78 - 'N'
  0,    // 79 - 'O'
  0,    // 80 - 'P'
  0,    // 81 - 'Q'
  0,    // 82 - 'R'
  0,    // 83 - 'S'
  0,    // 84 - 'T'
  0,    // 85 - 'U'
  0,    // 86 - 'V'
  0,    // 87 - 'W'
  0,    // 88 - 'X'
  0,    // 89 - 'Y'
  0,    // 90 - 'Z'
  0,    // 91 - '['
  0,    // 92 - '\'
  0,    // 93 - ']'
  0,    // 94 - '^'
  0,    // 95 - '_'
  0,    // 96 - '`'
  5, 127, 9, 9, 9, 127,   // 97 - 'a'
  5, 127, 73, 73, 73, 54,   // 98 - 'b'
  5, 127, 65, 65, 65, 65,   // 99 - 'c'
  5, 127, 65, 65, 65, 62,   // 100 - 'd'
  5, 127, 73, 73, 73, 73,   // 101 - 'e'
  5, 127, 9, 9, 9, 9,     // 102 - 'f'
  0,    // 103 - 'g'
  0,    // 104 - 'h'
  0,    // 105 - 'i'
  0,    // 106 - 'j'
  0,    // 107 - 'k'
  0,    // 108 - 'l'
  0,    // 109 - 'm'
  0,    // 110 - 'n'
  0,    // 111 - 'o'
  0,    // 112 - 'p'
  0,    // 113 - 'q'
  0,    // 114 - 'r'
  0,    // 115 - 's'
  0,    // 116 - 't'
  0,    // 117 - 'u'
  0,    // 118 - 'v'
  0,    // 119 - 'w'
  0,    // 120 - 'x'
  0,    // 121 - 'y'
  0,    // 122 - 'z'
  0,    // 123 - '{'
  1, 127,   // 124 - '|'
  0,    // 125
  0,    // 126
  0,    // 127
  0,    // 128
  0,    // 129
  0,    // 130
  0,    // 131
  0,    // 132
  0,    // 133
  0,    // 134
  0,    // 135
  0,    // 136
  0,    // 137
  0,    // 138
  0,    // 139
  0,    // 140
  0,    // 141
  0,    // 142
  0,    // 143
  0,    // 144
  0,    // 145
  0,    // 146
  0,    // 147
  0,    // 148
  0,    // 149
  0,    // 150
  0,    // 151
  0,    // 152
  0,    // 153
  0,    // 154
  0,    // 155
  0,    // 156
  0,    // 157
  0,    // 158
  0,    // 159
  0,    // 160
  0,    // 161
  0,    // 162
  0,    // 163
  0,    // 164
  0,    // 165
  0,    // 166
  0,    // 167
  0,    // 168
  0,    // 169
  0,    // 170
  0,    // 171
  0,    // 172
  0,    // 173
  0,    // 174
  0,    // 175
  0,    // 176
  0,    // 177
  0,    // 178
  0,    // 179
  0,    // 180
  0,    // 181
  0,    // 182
  0,    // 183
  0,    // 184
  0,    // 185
  0,    // 186
  0,    // 187
  0,    // 188
  0,    // 189
  0,    // 190
  0,    // 191
  0,    // 192
  0,    // 193
  0,    // 194
  0,    // 195
  0,    // 196
  0,    // 197
  0,    // 198
  0,    // 199
  0,    // 200
  0,    // 201
  0,    // 202
  0,    // 203
  0,    // 204
  0,    // 205
  0,    // 206
  0,    // 207
  0,    // 208
  0,    // 209
  0,    // 210
  0,    // 211
  0,    // 212
  0,    // 213
  0,    // 214
  0,    // 215
  0,    // 216
  0,    // 217
  0,    // 218
  0,    // 219
  0,    // 220
  0,    // 221
  0,    // 222
  0,    // 223
  0,    // 224
  0,    // 225
  0,    // 226
  0,    // 227
  0,    // 228
  0,    // 229
  0,    // 230
  0,    // 231
  0,    // 232
  0,    // 233
  0,    // 234
  0,    // 235
  0,    // 236
  0,    // 237
  0,    // 238
  0,    // 239
  0,    // 240
  0,    // 241
  0,    // 242
  0,    // 243
  0,    // 244
  0,    // 245
  0,    // 246
  0,    // 247
  0,    // 248
  0,    // 249
  0,    // 250
  0,    // 251
  0,    // 252
  0,    // 253
  0,    // 254
  0,    // 255
};
#endif

RGB Led Matrix Clock With Arduino

RGB Matrix p4 with arduino mega 64*32 P4-256*128-2121-A2


RGB Matrix p4 with arduino mega 64x32
DS1307 Real Time Clock
64x32 rgb led matrix arduino
64x32 rgb led matrix arduino code
matrice led rgb arduino
 This project with esp32 
 

Schema


Code

// testshapes demo for RGBmatrixPanel library.
// Demonstrates the drawing abilities of the RGBmatrixPanel library.
// For 32x64 RGB LED matrix.

// WILL NOT FIT on ARDUINO UNO -- requires a Mega, M0 or M4 board



#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#include <MD_DS1307.h>
#include <Wire.h>
#define CLK 11 // USE THIS ON ARDUINO MEGA
#define OE   9
#define LAT 10
#define A   A0
#define B   A1
#define C   A2
#define D   A3

RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64);
// Global variables
#define MAX_MESG  4
#define MAX_MES  20
unsigned int NewRTCh = 24;
unsigned int NewRTCm = 60;
unsigned int NewRTCs = 60;
char szTime[12];    // mm:ss\0
char szMesg[MAX_MESG+1] = "";
char szDate[MAX_MES+1] = "";
char *mon2str(uint8_t mon, char *psz, uint8_t len)
// Get a label from PROGMEM into a char array
{
  static const char str[][4] PROGMEM =
  {
    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  };

  *psz = '\0';
  mon--;
  if (mon < 12)
  {
    strncpy_P(psz, str[mon], len);
    psz[len] = '\0';
  }

  return(psz);
}

char *dow2str(uint8_t code, char *psz, uint8_t len)
{
  static const char str[][10] PROGMEM =
  {
    "Su", "Mo", "Tu", "We",
    "Th", "Fr", "Sa"
  };

  *psz = '\0';
  code--;
  if (code < 7)
  {
    strncpy_P(psz, str[code], len);
    psz[len] = '\0';
  }

  return(psz);
}
void getTime(char *psz, bool f = true)
// Code for reading clock time
{
 
  RTC.readTime();
    if (NewRTCh != RTC.h) 
  {
  sprintf(psz, "%02d", RTC.h);
  matrix.setCursor(2, 4); 
  matrix.setTextSize(2);
    matrix.setTextColor(matrix.Color333(7, 0, 7));
  matrix.fillRect(2, 4, 64, 14, matrix.Color333(0, 0, 0));
    matrix.print(szTime);
  sprintf(psz, "%02d", RTC.m);
  matrix.setCursor(28, 4); 
    matrix.setTextColor(matrix.Color333(7, 0, 7));
  matrix.fillRect(25, 4, 25, 14, matrix.Color333(0, 0, 0));
    matrix.print(szTime);
  matrix.setCursor(21, 4); 
  matrix.setTextColor(matrix.Color333(7, 0, 0));
  matrix.fillRect(25, 8, 2, 6, matrix.Color333(0, 0, 0));
    matrix.print(f ? ':' : ' ');
  matrix.setCursor(52, 9); 
  matrix.setTextSize(1);
  matrix.setTextColor(matrix.Color333(7, 7, 0));
  matrix.fillRect(52, 9, 11, 7, matrix.Color333(0, 0, 0));
  sprintf(psz, "%02d", RTC.s);
    matrix.print(szTime);
        getDate(szDate);
  matrix.setCursor(5, 20);
  matrix.fillRect(5, 20, 54, 8, matrix.Color333(0, 0, 0));
  uint8_t y = 0;
  for (y=0; y<10; y++) {
    matrix.setTextColor(Wheel(y));
    matrix.print(szDate[y]);
    }
        getDay(szMesg);
  matrix.setTextSize(1);
  matrix.setCursor(52, 1);
  matrix.setTextColor(matrix.Color333(0, 7, 0));
  matrix.fillRect(52, 1, 11, 7, matrix.Color333(0, 0, 0));
    matrix.print(szMesg);
      NewRTCh=RTC.h;
    }
    else if (NewRTCm != RTC.m) 
  {
  sprintf(psz, "%02d", RTC.m);
  matrix.setCursor(28, 4); 
  matrix.setTextSize(2);
    matrix.setTextColor(matrix.Color333(7, 0, 7));
  matrix.fillRect(25, 4, 25, 14, matrix.Color333(0, 0, 0));
    matrix.print(szTime);
  matrix.setCursor(21, 4); 
  matrix.setTextColor(matrix.Color333(0, 0, 7));
  matrix.fillRect(25, 8, 2, 6, matrix.Color333(0, 0, 0));
    matrix.print(f ? ':' : ' ');
  matrix.setCursor(52, 9); 
  matrix.setTextSize(1);
  matrix.setTextColor(matrix.Color333(0, 7, 7));
  sprintf(psz, "%02d", RTC.s);
  matrix.fillRect(52, 9, 11, 7, matrix.Color333(0, 0, 0));
    matrix.print(szTime);
      NewRTCm=RTC.m;
    }
    else if (NewRTCs != RTC.s/10) 
  {
  matrix.setCursor(21, 4); 
  matrix.setTextSize(2);
  matrix.setTextColor(matrix.Color333(0, 7, 0));
  matrix.fillRect(25, 8, 2, 6, matrix.Color333(0, 0, 0));
    matrix.print(f ? ':' : ' ');
  matrix.setCursor(52, 9); 
  matrix.setTextSize(1);
  matrix.setTextColor(matrix.Color333(0, 0, 7));
  sprintf(psz, "%02d", RTC.s);
  matrix.fillRect(52, 9, 11, 7, matrix.Color333(0, 0, 0));
    matrix.print(szTime);
      NewRTCs=RTC.s/10;
    }
    else
  {
  matrix.setCursor(21, 4); 
  matrix.setTextSize(2);
  matrix.setTextColor(matrix.Color333(0, 0, 7));
  matrix.fillRect(25, 8, 2, 6, matrix.Color333(0, 0, 0));
    matrix.print(f ? ':' : ' ');
  matrix.setCursor(52, 9); 
  matrix.setTextSize(1);
  matrix.setTextColor(matrix.Color333(7, 0, 0));
  sprintf(psz, "%02d", RTC.s);
  matrix.fillRect(58, 9, 5, 7, matrix.Color333(0, 0, 0));
    matrix.print(szTime);
    }
  }
void getDate(char *psz)
// Code for reading date
{
  char  szBuf[10];
  sprintf(psz, "%02d%s%04d", RTC.dd, mon2str(RTC.mm, szBuf, sizeof(szBuf)-1), RTC.yyyy);
}
void getDay(char *psz)
// Code for reading day date
{
  dow2str(RTC.dow, szMesg, MAX_MESG);
}

void setup() {

  matrix.begin();
  matrix.setTextWrap(false);
  RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
  RTC.control(DS1307_12H, DS1307_OFF);
}

void loop() {
  static uint32_t lastime = 0; // millis() memory
  static bool flasher = false;  // seconds passing flasher
  if (millis() - lastime >= 1000)
  
   {
    lastime = millis();
    getTime(szTime, flasher);
    flasher = !flasher;
  }
 
}


// Input a value 0 to 24 to get a color value.
// The colours are a transition r - g - b - back to r.
uint16_t Wheel(byte WheelPos) {
  if(WheelPos < 2) {
   return matrix.Color333(0, 7, 0);
  } else if(WheelPos < 5) {
   WheelPos -= 2;
   return matrix.Color333(7 , 0, 0);
  } else {
   WheelPos -= 5;
   return matrix.Color333(0, 7, 0);
  }
}

ESP8266 Weather Station Clock Read Data From ThingSpeak Cloud

 ESP8266 Weather Station Clock  Read Data From ThingSpeak Cloud
Arduino tutorial:
    Demonstates reading from a public channel which requires no API key and reading from a private channel which requires a read API key.
    The value read from the public channel is the current outside temperature at MathWorks headquaters in Natick, MA.  The value from the
               private channel is an example counter that increments every 10 seconds.
 
  Hardware: ESP8266 based boards
 
  !!! IMPORTANT - Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!!
 

ESP8266 and the ThingSpeak Cloud Read Data

Arduino tutorial:
    Demonstates reading from a public channel which requires no API key and reading from a private channel which requires a read API key.
    The value read from the public channel is the current outside temperature at MathWorks headquaters in Natick, MA.  The value from the
               private channel is an example counter that increments every 10 seconds.
 
  Hardware: ESP8266 based boards
 
  !!! IMPORTANT - Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!!
 

 DHT22 Temperature Humidity Sensor

ESP 01 DHT11 and the AskSensors Cloud

Arduino tutorial: This module uses the ESP-01 or the ESP-01S as the master control, and the DHT11 ... Humidity Monitoring Using the ESP-01 & DHT and the AskSensors Cloud.

 DHT22 Temperature Humidity Sensor

Code

/*
 * DHT Temperature and humidity monitoring using ESP01 and the askSensors 
 * Description: This examples connects the ESP to wifi, and sends Temperature and humidity to askSensors IoT platfom over HTTPS GET Request.
 * Author: https://asksensors.com, 2018 - 2019
 * github: https://github.com/asksensors
 * DHT11 library (DHT11) found at https://github.com/winlinvip/SimpleDHT
 * More videos : https://www.youtube.com/channel/UCCC8DuqicBtP3A_aC53HYDQ/videos
 */

// includes
#include "ESP8266WiFi.h"
#include "WiFiClientSecure.h"
#include "SimpleDHT.h"

// user config: TODO
const char* wifi_ssid = "***********";             // SSID
const char* wifi_password = "***********";         // WIFI
const char* apiKeyIn = "***********";      // API KEY IN
const unsigned int writeInterval = 25000; // write interval (in ms)

// ASKSENSORS config.
const char* https_host = "api.asksensors.com";         // ASKSENSORS host name
const int https_port = 443;                        // https port
const char* https_fingerprint =  "B5 C3 1B 2C 0D 5D 9B E5 D6 7C B6 EF 50 3A AD 3F 9F 1E 44 75";     // ASKSENSORS HTTPS SHA1 certificate
// DHT config.
int pinDHT11 = 2;
SimpleDHT11 dht11(pinDHT11);
// create ASKSENSORS client
WiFiClientSecure client;

void getTem()
{
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    delay(100);
    return;
  }
  if (!client.connect(https_host, https_port)) {
  delay(200);
  return;
  }
  // Create a URL for the request
  String url = "/write/";
  url += apiKeyIn;
    url += "?module1=";
  url += ((int)temperature);
  url += "&module2=";
  url += ((int)humidity);
  

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + https_host + "\r\n" +
               "Connection: close\r\n\r\n");

  client.connected();
}
void setup() {
  WiFi.begin(wifi_ssid, wifi_password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  // Set Client to insecure
  client.setInsecure();
}

void loop() {
         getTem();
  delay(10000);

}