IOT 23
Mon Jan 08 2024 18:59:51 GMT+0000 (Coordinated Universal Time)
Saved by
@马丽
#include <WiFi.h>
#include "AdafruitIO_WiFi.h"
#define WIFI_SSID "Your_WiFi_SSID"
#define WIFI_PASS "Your_WiFi_Password"
#define IO_USERNAME "Your_AdafruitIO_Username"
#define IO_KEY "Your_AdafruitIO_Key"
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
AdafruitIO_Feed *wdbFeed = io.feed("wdb");
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(100); // Wait for Serial to be available
}
Serial.println("Booting...");
Serial.print("Connecting to Wi-Fi");
io.connect();
while (io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.println("Connected to Adafruit IO!");
// Your data to send to Adafruit IO (replace this with your actual data)
int sensorValue = 123; // Replace with your sensor data or variable value
// Publish the data to the "wdb" feed on Adafruit IO
wdbFeed->save(sensorValue);
Serial.print("Data sent to Adafruit IO: ");
Serial.println(sensorValue);
}
void loop() {
io.run();
// Other tasks can be performed here
}
content_copyCOPY
Comments