ESP8266 and ThingSpeak library
Posted: Sun Jul 02, 2017 4:23 pm
Hello guys and girls!
First time,first post
I am wondering is my code going to work.
I need to create small numbers of weather stations for school project and i need confirmation of my code so they can order all needed parts.The data should be uploaded to ThingSpeak every 60 minutes.
First time,first post
I am wondering is my code going to work.
I need to create small numbers of weather stations for school project and i need confirmation of my code so they can order all needed parts.The data should be uploaded to ThingSpeak every 60 minutes.
Code: Select all
#include "ThingSpeak.h"
#include "ESP8266WiFi.h"
/*------wifi data ------*/
char ssid[] = "Ivica_wifI";
char wifipass[] = "Ivicawifi0968";
/*-------ThingSpeak data-------------*/
char api_write_key[] = "umetni kljuc ovdje";
long api_write_channel = 123456;
WiFiClient ts_client;
void setup() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, wifipass);
while (WiFi.status() != WL_CONNECTED) {
}
ThingSpeak.begin(ts_client);
}
void loop() {
int val1 = random(0,999);
ThingSpeak.setField(0, val1);
ThingSpeak.writeFields(api_write_channel, api_write_key);
ESP.deepSleep(60 * 1000 * 60);
}