14-06-2021, 19:44
Siemanko mam kod i mam cos zle podpowie ktos jak zrobic to
Kod:
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Timer.h>
#include <SimpleTimer.h>
#include <Adafruit_AHTX0.h>
Adafruit_AHTX0 aht;
#define TEMPERATURE_PRECISION 10 // Lower resolution
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "8****i";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "VM6669770";
char pass[] = "******";
void setup(){
timer.setInterval(10010L, TempUpdate);
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void TempUpdate()
{
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
temperature = temp.temperature + Calibration;
temperature = rounded(temperature);
Humidity = humidity.relative_humidity;
///////////////////////////////////// temp /////////////////////////////////////
String T_Int = String(temperature).substring(0, 2);
WriteStr( "home.T_Int.txt", T_Int);
Blynk.virtualWrite(V3, temperature);
Bridge1.virtualWrite(V19, temperature);//MCU55
String D_Int = String(temperature).substring(2, 4); //décimal
WriteStr( "home.D_Int.txt", D_Int);//Send to Nextion
int gauge = map(temperature, 0, 40, 0, 100);
WriteNum( "home.j1.val", gauge);//Send to Nextion
///////////////////////////////////// Hum /////////////////////////////////////
String H_Int = String(humidity.relative_humidity).substring(0, 2);;
WriteStr( "home.H_Int.txt", H_Int);//Send to Nextion
Blynk.virtualWrite(V8, H_Int);
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
}