Skip to content

Instantly share code, notes, and snippets.

@gsampallo
Created October 17, 2020 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsampallo/c8440e1869e0358fbdc9bebe270617a4 to your computer and use it in GitHub Desktop.
Save gsampallo/c8440e1869e0358fbdc9bebe270617a4 to your computer and use it in GitHub Desktop.
DPRE - Enviar datos analogicos a ThingSpeak
#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