Created
August 28, 2015 02:02
-
-
Save kuc-arc-f/674b45b156c802667215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
extern "C" { | |
#include "user_interface.h" | |
} | |
const char* ssid = ""; | |
const char* password = ""; | |
const char* host = "aaa1234.com"; | |
int mNextTime =300; | |
// | |
uint get_toutValue(){ | |
uint ret=0; | |
ret= system_adc_read(); | |
return ret; | |
} | |
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.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()); | |
} | |
void loop() { | |
int nextTm =mNextTime * 1000; | |
delay( nextTm ); | |
uint tVal= get_toutValue(); | |
Serial.print("connecting to "); | |
Serial.println(host); | |
WiFiClient client; | |
const int httpPort = 80; | |
if (!client.connect(host, httpPort)) { | |
Serial.println("connection failed"); | |
return; | |
} | |
String sTout=String(tVal); | |
String url="/api5678.php?mc_id=1&rkey=r900&snum_1="+ sTout; | |
Serial.print("Requesting URL: "); | |
Serial.println(url); | |
client.print(String("GET ") + url + " HTTP/1.0\r\n" + | |
"Host: " + host + "\r\n" + | |
"Connection: close\r\n\r\n"); | |
delay( 3000 ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment