// Program for attiny3216 to control esp32 // created by Jans Hendry // Universitas Gadjah Mada, Indonesia // Kamakura Node, Japan // fab academy MIT - 2022 // This should be placed at the mosttop of your codes. #define BLYNK_TEMPLATE_ID "TMPL9DyBehiR" // from blynk #define BLYNK_DEVICE_NAME "IoTATTiny" //from blynk // auth token taken from blynk website (your account) #define auth_key "njCapvUbA2LmiWZ4n5Pw-QBN6_jd4RRm" #define BLYNK_PRINT Serial // directives #include // wifi directive #include #include // blynk directive #include "DHT.h" //sensor // wifi //char ssd[] = "Baskom";///Enter your wifi name //char pass[] = "masukajah";// Enter wifi password #define SSID "Baskom" #define password "masukajah" // variable temperature and humidity const int sens = 4; const int esp2at = 15; // control to attiny3216 int stt; //dht DHT; // create object from sensor BlynkTimer timer; DHT dht(sens, DHT11); void setup() { // Debug console Serial.begin(115200); delay(1000); WiFi.begin(SSID, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } // Use this syntax to ensure the blynk connection working. // New blynk server is "blynk.cloud", instead of the old one "blynk-cloud.com" Blynk.begin(auth_key, SSID, password, "blynk.cloud", 80); // setup signal pinMode(esp2at, OUTPUT); digitalWrite(esp2at, LOW); } // You should put this function before the setup and loop to make it executed before the blynk run in loop mode BLYNK_WRITE(V15) // this command is listening when something is written to V15 { int signling = param.asInt(); // assigning incoming value from pin V15 to a variable if (signling == 1){ stt = 1; } else{ stt = 0; } Serial.println(signling); } void loop() { // send to blynk dht.begin(); float humid = dht.readHumidity() - 10.0; float temper = dht.readTemperature() - 5.0; // or dht.readTemperature(true) for Fahrenheit Blynk.virtualWrite(V8, temper); // virtual pin in blynk for temperature Blynk.virtualWrite(V9, humid); // virtual pin in blynk for humidity Blynk.run(); // run blynk // read button from blynk if (stt == 1){ digitalWrite(esp2at, HIGH); //send signal to at1614 Blynk.virtualWrite(V5, 1); // turn ON led in blynk } else{ digitalWrite(esp2at, LOW); Blynk.virtualWrite(V5, 0); } delay(1000); // take data every 1 second // try not to send data to blynk faster than 100 ms or 0.1 second }