Created
May 23, 2018 07:10
-
-
Save jtuttas/563936c27c47955b81e1d0a5e73ad7ea to your computer and use it in GitHub Desktop.
Send Data to adafruit Clound
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "esp_wpa2.h" | |
#include <WiFi.h> | |
#include <HTTPClient.h> | |
// SSID to connect to | |
static const char* ssid = "MMBBS-Intern"; | |
// Username for authentification | |
#define EAP_ID "tuttas" | |
#define EAP_USERNAME "tuttas" | |
#define EAP_PASSWORD "geheim" | |
HTTPClient http; | |
void setup() | |
{ | |
Serial.begin(115200); | |
delay(500); | |
WiFi.disconnect(true); | |
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ID, strlen(EAP_ID)); | |
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME)); | |
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); | |
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); | |
esp_wifi_sta_wpa2_ent_enable(&config); | |
WiFi.begin(ssid); | |
// Wait for connection AND IP address from DHCP | |
Serial.println(); | |
Serial.println("Waiting for connection and IP Address from DHCP"); | |
while (WiFi.status() != WL_CONNECTED) | |
{ | |
delay(2000); | |
Serial.print("."); | |
} | |
Serial.println(""); | |
Serial.println("WiFi connected"); | |
Serial.println("IP address: "); | |
Serial.println(WiFi.localIP()); | |
HTTPClient http; | |
http.begin("https://io.adafruit.com/api/v2/jtuttas/feeds/esp32/data"); | |
http.addHeader("Content-Type", "application/json"); | |
http.addHeader("X-AIO-Key", "geheim"); | |
http.POST("{\"value\":\"21.3\"}"); | |
http.writeToStream(&Serial); | |
http.end(); | |
} | |
void loop() | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment