Created
October 17, 2020 13:42
-
-
Save gsampallo/c8440e1869e0358fbdc9bebe270617a4 to your computer and use it in GitHub Desktop.
DPRE - Enviar datos analogicos a ThingSpeak
This file contains 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 <ESP8266WiFi.h> | |
#include "ThingSpeak.h" | |
const char* ssid = "X"; | |
const char* password = "X"; | |
WiFiClient client; | |
unsigned long numeroCanal = X; | |
const char* apiKey = "X"; | |
void setup() { | |
Serial.begin(115200); //9600 | |
WiFi.begin(ssid,password); | |
Serial.print("Conectando"); | |
while(WiFi.status() != WL_CONNECTED) { | |
Serial.print("."); | |
delay(100); | |
} | |
Serial.println("Conectado"); | |
Serial.print("DIRECCION IP:"); | |
Serial.println(WiFi.localIP()); | |
ThingSpeak.begin(client); | |
} | |
void loop() { | |
//unsigned long tiempo = millis(); | |
int valor = analogRead(0); | |
int x = ThingSpeak.writeField(numeroCanal, 1, valor, apiKey ); | |
if(x == 200) { | |
Serial.println("Actualizacion correcta"); | |
} else { | |
Serial.println("Se produjo un problema. HTTP Codigo de error"+String(x)); | |
} | |
delay(10000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment