I'm having problems with the ttglo lora32 oled, I programmed it in Arduino IDE. The code basically does the following; It obtains the temperature and humidity data from a DHT22, displays them on the integrated OLED screen, then, using the JSON library, creates a string with json format and finally sends the string with a serial.Print through the serial port.
Everything works correctly for a few minutes (approximately 15) and then the microcontroller sends the following error through the serial port:
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
Core 1 register dump:
PC : 0x400d335c PS : 0x00060e35 A0 : 0x800d3434 A1 : 0x3ffb20b0
A2 : 0x0001f7e4 A3 : 0x00000001 A4 : 0x3ffc1cec A5 : 0x00000001
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x00027100 A9 : 0x0001f7e4
A10 : 0x00000001 A11 : 0x00000000 A12 : 0x7f170ed5 A13 : 0x00002000
A14 : 0x00000028 A15 : 0xff000000 SAR : 0x0000000d EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x400845e5 LEND : 0x400845ed LCOUNT : 0x00000027
Backtrace: 0x400d3359:0x3ffb20b0 0x400d3431:0x3ffb20d0 0x400d3609:0x3ffb2230 0x400d1658:0x3ffb2250 0x400d2111:0x3ffb2270 0x400d5b71:0x3ffb2290
The code is the following:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
#include <ArduinoJson.h>
#define DHTPIN 13
String resultS = "";
int var = 0;
int num = 1;
boolean db = false;
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
Adafruit_SSD1306 myDisplay = Adafruit_SSD1306(128,64,&Wire);
int t = 0;
int h = 0;
float tp,hp;
void setup()
{
Serial.begin(9600);
dht.begin();
myDisplay.begin(SSD1306_SWITCHCAPVCC, 0x3C);
num = 1;
}
void loop()
{
db = false;
for(int i = 1; i <= 900; i++) //tiempo en segundos para cada muestra en la base de datos
{
lectura();
display();
myDisplay.display();
delay(1000);
json();
}
db = true;
lectura();
display();
myDisplay.display();
delay(1000);
json();
num++;
}
void lectura ()
{
hp = dht.readHumidity() * 0.9598 - 4.6208 + 1;
tp = dht.readTemperature() * 0.8779 + 1.9411 -1;
t = ((int)(tp * 10));
h = ((int)(hp * 10));
}
void display()
{
myDisplay.clearDisplay();
myDisplay.setTextColor(WHITE);
myDisplay.setTextSize(2);
myDisplay.setCursor(0,0);
myDisplay.print("Temp: ");
myDisplay.setTextSize(2);
myDisplay.setCursor(43,16);
myDisplay.print(tp);
myDisplay.print(" C");
myDisplay.setTextSize(2);
myDisplay.setCursor(0,34);
myDisplay.print("Hum: ");
myDisplay.setTextSize(2);
myDisplay.setCursor(43,50);
myDisplay.print(hp);
myDisplay.print(" %");
}
void json ()
{
StaticJsonDocument<96> doc;
doc["N"] = num;
doc["Dispositivo"] = "dosificado_2_ss";
doc["Temperatura"] = t;
doc["humedad"] = h;
doc["db"] = db;
String output;
serializeJson(doc, output);
Serial.println(output);
}
Thanks in advance for the help.