menyambungkan esp 8266 dengan geeknesia
#include <
AltSoftSerial.h>
#include <stdlib.h
>
String apiKey = "835210516a36e5e3b45916ede3dxxxxx"; AltSoftSerial ser; #define SSID "Wifi" //SSID #define PASS "Pass" //Password void setup() { ser.begin(9600); // RX -> D8 ; TX -> 9 (Tetap) arduino uno delay(3000); if(ser.find("OK")){ Serial.println("GET HERE"); } ser.println("AT+RST"); delay(2000); ser.println("AT+CWMODE=1"); delay(2000); String cmd="AT+CWJAP=\""; cmd+=SSID; cmd+="\",\""; cmd+=PASS; cmd+="\""; ser.println(cmd); delay(5000); cmd=""; } void loop() { int val = 0; String cmd = "AT+CIPSTART=\"TCP\",\""; cmd += "geeknesia.com"; cmd += "\",80"; ser.println(cmd); delay(2000); cmd=""; if(ser.find("Error")) { return; } String getStr = "GET /api/data?api_key=835210516a36e5e3b45916ede3dxxxxx&attributes={\"humidity\":\"65\"}"; getStr += "\r\n\r\n"; cmd = "AT+CIPSEND="; cmd += String(getStr.length()); ser.println(cmd); delay(2000); if(ser.find(">")) { ser.print(getStr); } else { ser.println("AT+CIPCLOSE"); } cmd=""; delay(1000); }