-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpush_to_ngrok
58 lines (46 loc) · 1.4 KB
/
push_to_ngrok
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* This sketch sends data via HTTP GET requests to data.sparkfun.com service.
*
* You need to get streamId and privateKey at data.sparkfun.com and paste them
* below. Or just customize this script to talk to other HTTP servers.
*
*/
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "Cats in Space";
const char* password = "meowmixer";
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
/* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,
would try to act as both a client and an access-point and could cause
network-issues with your other WiFi-devices on your WiFi-network. */
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// This will send the request to the server
HTTPClient http;
http.begin("http://d0477d82.ngrok.io/lights/chill");
http.addHeader("Access-Control-Allow-Origin", "*");
http.GET();
http.writeToStream(&Serial);
http.end();
Serial.println();
Serial.println("closing connection");
}
int value = 0;
void loop() {
delay(1000000);
}