HI guys,in my project i succeed displaying DHT22 data on a led matrix 488 with MAX27XX driver,but in displaying the humidity value is displaying twise at the same time ,instead i just need how to display the temperature and humidity succevelly without this problem,and to know how can i add alert scrolling messages in case the values are bigger than the average.
thanks for advance.
#include <MD_Parola.h>
#include "DHT.h"
#define DHTPIN 14
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
//specify the CS pin’s connection with the ESP32 which is pin 5
#define CS_PIN 5
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
#define SPEED_TIME 50
#define PAUSE_TIME 0
#define MAX_MESG 20
char szMesg[MAX_MESG+1] = "";
uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C
void getHumidit(char *psz)
{
float h = dht.readHumidity();
dtostrf(h, 3, 0, szMesg);
strcat(szMesg, " % ");
}
void getTemperatur(char *psz)
{
float t = dht.readTemperature();
dtostrf(t, 3, 0, szMesg);
strcat(szMesg, " $");
}
void setup(void)
{
Serial.begin(115200);
P.begin(3);
P.setInvert(false);
P.setZone(0, 0, 3);
P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, 0, PA_PRINT, PA_SCROLL_LEFT);
P.addChar('$', degC);
dht.begin();
}
void loop()
{ static uint8_t display = 0;
P.displayAnimate();
if (P.getZoneStatus(0)){
switch (display)
{
case 0:
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
getTemperatur(szMesg);
display++;
break;
case 1:
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
getHumidit(szMesg);
display++;
break;
default:
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display = 0;
break;
}
P.displayReset(0);
}
}