-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwi_ficode.ino
42 lines (38 loc) · 920 Bytes
/
wi_ficode.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "ThingSpeak.h"
#include <ESP8266WiFi.h>
//-------- Enter Your Wi-Fi Details -----//
char ssid[] = ""; //SSID
char pass[] = ""; //Password
//--------------------------------------//
WiFiClient client;
unsigned long myChannelField = ; // Channel ID
const int ChannelField = 1; // Which To Field Write
const char * myWriteAPIKey = ""; // Write API Key
String value = "";
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
}
void loop()
{
if (Serial.available() > 0)
{
while (Serial.available() > 0)
{
int inChar = Serial.read();
value += (char)inChar;
}
}
if (WiFi.status() != WL_CONNECTED)
{
while (WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid, pass);
delay(5000);
}
}
ThingSpeak.writeField(myChannelField, ChannelField, value, myWriteAPIKey);
value = "";
}