Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- const char* ssid = "BELL473";
- const char* password = "XXXXXXX";
- const char* host = "ns8451.hostgator.com";
- 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);
- WiFi.begin(ssid, password); //works!
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("");
- Serial.println("WiFi connected");
- Serial.println("IP address: ");
- Serial.println(WiFi.localIP());
- }
- int value = 0;
- void loop() {
- delay(5000);
- ++value;
- Serial.print("connecting to ");
- Serial.println(host);
- // Use WiFiClient class to create TCP connections
- WiFiClient client;
- const int httpPort = 80;
- if (!client.connect(host, httpPort)) { //works!
- Serial.println("connection failed");
- return;
- }
- // We now create a URI for the request
- String url = "/GetData.php";
- url += "?username=";
- url += "aaaa";
- url += "&pin=";
- url += "bbbb";
- url += "&cost=";
- url += "cccc";
- Serial.print("Requesting URL: ");
- Serial.println(url);
- // This will send the request to the server
- client.print(String("GET ") + url + " HTTP/1.1rn" +
- "Host: " + host + "rn" +
- "Connection: closernrn");
- Serial.println();
- Serial.println("closing connection");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement