ติด error ตัวนี้ครับ
exit status 1
‘StaticJsonDocument’ does not name a type; did you mean ‘StaticJsonBuffer’?
โค้ดตามนี้ครับ
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPLNBA9IWf8"
#define BLYNK_DEVICE_NAME "CFE farmF"
#define BLYNK_AUTH_TOKEN ""
#define BLYNK_WRITE
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#include <ArduinoJson.h>
#include <TridentTD_LineNotify.h>
String recv_str_jsondata;
StaticJsonDocument<256> doc_send;
StaticJsonDocument<256> doc_recv;
#define RXD2 16
#define TXD2 17
WidgetLED led1(V30);
WidgetLED ledF1(V61);
WidgetLED ledF2(V62);
WidgetLED ledF3(V63);
WidgetLED ledF4(V64);
WidgetLED ledL3(V65);
#define LINE_TOKEN "vW7CKCYcHRaE8sQGbU8yWWdZYVhhQwcqDEvvp6XTiWR"
char auth[] = "GSMZE1GOi_sm9nexLasDsjn4CI_oZVxR";
char ssid[] = "CFE_Farm";
char pass[] = "12345678";
BlynkTimer timer;
float ts1;
float ts2;
float ts3;
float tlL;
float tlH;
int s1;
int s2;
int s3;
int s4;
int s5;
int s6;
#define Relay2 12
#define Relay3 13
#define Relay4 14
#define Relay5 15
void setup() {
pinMode(Relay2,OUTPUT);
pinMode(Relay3,OUTPUT);
pinMode(Relay4,OUTPUT);
pinMode(Relay5,OUTPUT);
timer.setInterval(1000, set);
timer.setInterval(1000, setoff1);
timer.setInterval(1000, setoff2);
timer.setInterval(1000, setoff3);
timer.setInterval(1000, switch4);
Serial.begin(115200);
Serial2.begin(115200,SERIAL_8N1, RXD2, TXD2);
WiFi.mode(WIFI_AP_STA);
WiFi.begin(ssid, pass);
Blynk.config(auth);
LINE.setToken(LINE_TOKEN);
delay(100);
}
void loop() {
Blynk.run();
timer.run();
// Recieving data (JSON) from Coordinator ESP
if (Serial2.available())
{
recv_str_jsondata = Serial2.readStringUntil('\n');
Serial.println(recv_str_jsondata);
DeserializationError error = deserializeJson(doc_recv, recv_str_jsondata);
if (!error) { // if not error in deserialization
float temp = doc_recv["v5"]; // fetch temprature data from JSON . Here { v1 : 28.55 }
float hum = doc_recv["v6"]; // fetch temprature data from JSON . Here { v2 :32.25 }
led1.on();
delay(500);
led1.off();
if (temp > 0) {
Blynk.virtualWrite(V31, temp); // writing temprature to BLYNK Cloud
Serial.print("temp ="); Serial.println(temp);
}
if (hum > 0) {
Blynk.virtualWrite(V32, hum); // writing temprature to BLYNK Cloud
Serial.print("hum ="); Serial.println(hum);
}
}
else {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
recv_str_jsondata = "";
}
}
BLYNK_WRITE(V33 )
{
s1 = param.asInt();
}
BLYNK_WRITE(V34 )
{
s2 = param.asInt();
}
BLYNK_WRITE(V35 )
{
s3 = param.asInt();
}
BLYNK_WRITE(V67 )
{
s5 = param.asInt();
}
BLYNK_WRITE(V69 )
{
s6 = param.asInt();
}
BLYNK_WRITE(V36 )
{
ts1 = param.asFloat();
}
BLYNK_WRITE(V37 )
{
ts2 = param.asFloat();
}
BLYNK_WRITE(V38 )
{
ts3 = param.asFloat();
}
BLYNK_WRITE(V39 )
{
s4 = param.asFloat();
}
BLYNK_WRITE(V66 )
{
tlL = param.asFloat();
}
BLYNK_WRITE(V68 )
{
tlH = param.asFloat();
}
BLYNK_CONNECTED()
{
Blynk.syncAll();
}
void set(){
float temp = doc_recv["v5"]; // fetch temprature data from JSON . Here { v1 : 28.55 }
float hum = doc_recv["v6"]; // fetch temprature data from JSON . Here { v2 :32.25 }
Serial.println(s1);
Serial.println(s2);
Serial.println(s3);
Serial.println(ts1);
Serial.println(ts2);
Serial.println(ts3);
Serial.println(temp);
if (temp >= ts1 && s1 == 1 )
{
digitalWrite(Relay2,1);
ledF1.on();
if (temp >= ts2 && s2 == 1 )
{
digitalWrite(Relay3,1);
ledF2.on();
if(temp >= ts3 && s3 == 1)
{
digitalWrite(Relay4,1);
ledF3.on();
}
else if (temp < ts3)
{
digitalWrite(Relay4,0);
ledF3.off();
}
}
else if (temp < ts2)
{
digitalWrite(Relay3,0);
ledF2.off();
}
}
else if (temp < ts1)
{
digitalWrite(Relay2,0);
ledF1.off();
digitalWrite(Relay3,0);
ledF2.off();
digitalWrite(Relay4,0);
ledF3.off();
}
}
void setoff1(){
if (s1 == 0){
digitalWrite(Relay2,0);
ledF1.off();
}
}
void setoff2(){
if (s2 == 0){
digitalWrite(Relay3,0);
ledF2.off();
}
}
void setoff3(){
if (s3 == 0){
digitalWrite(Relay4,0);
ledF3.off();
}
}
void switch4(){
if (s4 == 1){
digitalWrite(Relay5,1);
ledF4.on();}
else if(s4 == 0){
digitalWrite(Relay5,0);
ledF4.off();}
}
void linenotifyH(){
float temp = doc_recv["v5"]; // fetch temprature data from JSON . Here { v1 : 28.55 }
float hum = doc_recv["v6"]; // fetch temprature data from JSON . Here { v2 :32.25 }
if ( temp >= tlH && s6 == 1){
LINE.notify("อุณหภูมิเล้า 3 สูงเกิน!!!");
ledL3.on();
delay(1000);
ledL3.off();
}
else if(s6 == 0){
ledL3.off();
}
}
void linenotifyL(){
float temp = doc_recv["v5"]; // fetch temprature data from JSON . Here { v1 : 28.55 }
float hum = doc_recv["v6"]; // fetch temprature data from JSON . Here { v2 :32.25 }
if ( temp <= tlL && s5 == 1){
LINE.notify("อุณหภูมิเล้า 3 ต่ำเกิน!!!");
ledL3.on();
delay(1000);
ledL3.off();
}
else if(s5 == 0){
ledL3.off();
}
}
พิมพ์หรือวางโค้ดที่นี่