/* Comment this out to disable prints and save space */
/* Fill in information from Blynk Device Info here */
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
//#define BLYNK_TEMPLATE_NAME "Device"
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
//#define W5100_CS 10
//#define SDCARD_CS 4
#include <Adafruit_AHTX0.h>
Adafruit_AHTX0 aht;
void setup()
{
// Debug console
Serial.begin(9600);
//pinMode(SDCARD_CS, OUTPUT);
//digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
Blynk.begin(BLYNK_AUTH_TOKEN);
// You can also specify server:
//Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
// For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example
Serial.println("Adafruit AHT10/AHT20 demo!");
if (! aht.begin()) {
Serial.println("Could not find AHT? Check wiring");
while (1) delay(10);
}
Serial.println("AHT10 or AHT20 found");
}
void sensor() {
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp); // populate temp and humidity objects with fresh data
Serial.print("Temperature: ");
Serial.print(temp.temperature);
Serial.println(" degrees C");
Blynk.virtualWrite(V1, temp.temperature); // Convert temperature to compatible data type
Serial.print("Humidity: ");
Serial.print(humidity.relative_humidity);
Serial.println("% rH");
Blynk.virtualWrite(V2, humidity.relative_humidity); // Convert humidity to compatible data type
delay(500);
}
void loop()
{
sensor();
Blynk.run();
}
Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
Pete.
1 Like
You haven’t said exactly which hardware you are using, but this post might help point you in the right direction…
Pete.
I am using the Olimex ESP32-PoE and AM2013C sensor.
You only need to use triple backticks before and after your code, or when you’re posting compiler error messages or serial output.
I have no experience with that board, but maybe the post I linked you to will help.
Pete.