#Include ESP8266WiFi.h0

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <ESP8266WiFi.

h>
#include <ThingerESP8266.h>

#define USERNAME "your_username"


#define DEVICE_ID "your_device_id"
#define DEVICE_CREDENTIAL "your_device_credential"

#define SSID "your_wifi_ssid"


#define SSID_PASSWORD "your_wifi_password"

// Deklarasi objek Thinger.io


ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {
// Inisialisasi koneksi WiFi
thing.add_wifi(SSID, SSID_PASSWORD);

// Tambahkan sensor sebagai resource di thinger.io


thing["voltage"] >> [](pson &out) {
// Baca data dari komunikasi serial dengan Arduino Uno
String data = Serial.readStringUntil('\n');

// Parse data tegangan


float voltage1 = data.substring(0, data.indexOf(',')).toFloat();
float voltage2 = data.substring(data.indexOf(',') + 1).toFloat();

// Kirim data tegangan ke thinger.io


out["voltage1"] = voltage1;
out["voltage2"] = voltage2;
};
}

void loop() {
// Koneksi ke thinger.io
thing.handle();
}

You might also like