Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94e2515

Browse filesBrowse files
authored
Add files via upload
1 parent b4b8e41 commit 94e2515
Copy full SHA for 94e2515

File tree

Expand file treeCollapse file tree

1 file changed

+57
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+57
-0
lines changed

‎ThingSpeak/ThingSpeak.ino

Copy file name to clipboard
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include <ThingSpeak.h>
2+
3+
4+
#include "ESP8266WiFi.h"
5+
#include "ThingSpeak.h"
6+
7+
// Wifi config
8+
const char ssid[] = "mySSID";
9+
const char password[] = "myPassword";
10+
11+
// ThingSpeak config
12+
const unsigned long channel_id = 555842
13+
const char write_api_key[] = "OC8PZ442W9EPTR3M";
14+
15+
// WiFi client object
16+
WiFiClient client;
17+
18+
19+
void setup() {
20+
21+
// Initialize Serial
22+
Serial.begin(9600);
23+
delay(100);
24+
25+
// Connect to WiFi
26+
Serial.print("Connecting to ");
27+
Serial.print(ssid);
28+
WiFi.begin(ssid, password);
29+
while(WiFi.status() != WL_CONNECTED ){
30+
delay(500);
31+
Serial.print(".");
32+
}
33+
Serial.println();
34+
35+
// show that we are connected
36+
Serial.println("Connected!");
37+
38+
// Connect to ThingSpeak
39+
ThingSpeak.begin(client);
40+
41+
randomSeed(micros());
42+
}
43+
44+
void loop() {
45+
46+
// generate random numbers 1-100
47+
int rando = random(1,101);
48+
49+
// write values to our ThingSoeak channel
50+
Serial.println("Posting " +String(rando) + "to ThingSpeak");
51+
ThingSpeak.setField(1, rando);
52+
ThingSpeak.writeFields(channel_id, write_api_key);
53+
54+
delay(30000);
55+
56+
57+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.