I have tried various diffrent codes but still cant seem being able to connect to adafruit. And if the code runs fine it show "netowrk disconnected" in the arduino serial monitor.
code: #include <Adafruit_AHTX0.h>
#define DATA_PIN 5
Adafruit_AHTX0 aht;
void setup() {
// start the serial connection
Serial.begin(115200);
while(! Serial);
aht.begin();
// connect to io.adafruit.com
Serial.print("Connecting to Adafruit IO");
io.connect();
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(io.statusText());
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
}
void loop() {
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");
Serial.print("Humidity: "); Serial.print(humidity.relative_humidity); Serial.println("% rH");
I am connecting the AHT20 to an ESP32. I dont know what you mean with a controller (I am new to arduino). The code I am using is already there and I dont know the circuit diagram (the wiring?).
I just got told from my friend that I have to use arduino uno. I am gonna try again if it not works then I will seek help from you again. I am sorry for taking from your time.
Hi,
When you have more instructions from your teacher, can you post the exact words he/she gives in those instructions, or post an image of the problem sheet.
This will give us a better idea of what you are having problems with.
Hello. Look, what I am trying to do is getting the aht20 sensor send information to adafruit io dashboard. But when I run the code, it says in the serial monitor "network disconnected"
// Adafruit IO Temperature & Humidity Example
// Tutorial Link: Overview | Adafruit IO Basics: Temperature & Humidity | Adafruit Learning System
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016-2017 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.
// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients. #include "config.h"
/************************ Example Starts Here *******************************/ #include <Adafruit_AHTX0.h>
Adafruit_AHTX0 aht;
// set up the 'temperature' and 'humidity' feeds
AdafruitIO_Feed *temperature = io.feed("temperature");
AdafruitIO_Feed *humidity = io.feed("humidity");
void setup() {
// start the serial connection
Serial.begin(115200);
// wait for serial monitor to open
while (! Serial);
// initialize dht22
aht.begin();
// connect to io.adafruit.com
Serial.print("Connecting to Adafruit IO");
io.connect();
// wait for a connection
while (io.status() < AIO_CONNECTED) {
Serial.print(io.statusText());
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
}
void loop() {
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");
Serial.print("Humidity: "); Serial.print(humidity.relative_humidity); Serial.println("% rH");