// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPLoIdpoJ_a"
#define BLYNK_TEMPLATE_NAME "Quickstart Template"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI
#include "BlynkEdgent.h"
#include <Adafruit_AHTX0.h>
#include <wire.h>
Adafruit_AHTX0 aht;
Adafruit_Sensor *aht_humidity, *aht_temp;
// Declaring a global variabl for sensor data
//long temp;
//long humidity;
// This function creates the timer object. It's part of Blynk library. the timer has the code neccesarry to read the sensor data which is written
// to the blynk app when the timer function is called.
BlynkTimer timer;
void myTimer()
{
sensors_event_t humidity;
sensors_event_t temp;
aht_humidity->getEvent(&humidity); // gets the sensors humidity reading and stores it in the humidity variable.
aht_temp->getEvent(&temp);// gets and stores temperature readings.
/**** display sensor readings on the serial monitor*/
Serial.print("\t\tTemperature ");
Serial.print(temp.temperature);
Serial.println(" deg C");
/* Display the results (humidity is measured in % relative humidity (% rH) */
Serial.print("\t\tHumidity: ");
Serial.print(humidity.relative_humidity);
Serial.println(" % rH");
Serial.print("\t\tTemperature: ");
Serial.print(temp.temperature);
Serial.println(" degrees C");
delay(100);
// This function describes what will happen with each timer tick
Blynk.virtualWrite(V0, temp.temperature); //writes the temperature to the bynk server
Blynk.virtualWrite(V1, humidity.relative_humidity);//writes humidity to the bynk server virtual pin.
}
// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
Blynk.syncVirtual(V0);//**stores the previous temperature reading. this enables the device recall the last reading before it was turned off useful for switches*/
Blynk.syncVirtual(V1);//stores the previous pressure reading
}
void setup()
{
BlynkEdgent.begin();
timer.setInterval(2000L,myTimer);
//* AHT20 SETUP DETAILS***//
Wire.begin(SDA0_Pin, SCL0_Pin);
Serial.begin(115200);
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit AHT10/AHT20 test!");
if (!aht.begin()) {
Serial.println("Failed to find AHT10/AHT20 chip");
while (1) {
delay(10);
}
}
Serial.println("AHT10/AHT20 Found!");
aht_temp = aht.getTemperatureSensor();
aht_temp->printSensorDetails();
aht_humidity = aht.getHumiditySensor();
aht_humidity->printSensorDetails();
//***end of AHT20 SENSOR SETUP****//
}
void loop() {
BlynkEdgent.run();
timer.run();
}
after trying to upload this to my esp8266 I get this error message
C:\Users\HADAD\Documents\Arduino\Edgent_ESP8266_AHT20\BlynkEdgent.h:16:2: error: #error "Please specify your BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME"
16 | #error "Please specify your BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME"
| ^~~~~
exit status 1
Compilation error: #error "Please specify your BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME"
i dont know what is the problem because I am able to upload ordinary bynk code on the esp. also the same code is runing well on my esp32 and I was able to upload it last week using arduino 2.3.2