Kod: Markera allt
/*
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>
const char* ssid = "SSID";
const char* password = "PASSWORD";
const char* host = "temperatur.nu";
const char* streamId = "....................";
const char* privateKey = "....................";
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());
}
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)) {
Serial.println("connection failed");
return;
}
// We now create a URI for the request
String request;
String hash ="ba79c368433558812aca7XXXXXXXX";
//String temperatur = getTemp(0);
request = "GET /rapportera.php?hash=";
request += hash;
request += "&t=1.23";
//request += temperatur;
request += " HTTP/1.1";
request += ("\r\n");
request += ("Host: temperatur.nu");
request += ("\r\n");
request += "Connection: close";
request += ("\r\n");
request += ("\r\n");
client.print(request);
Serial.print("Requesting URL: ");
Serial.println(request);
// This will send the request to the server
/*client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");*/
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
// Read all the lines of the reply from server and print them to Serial
while (client.available()) {
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
}
Kod: Markera allt
22:47:08.223 -> Connecting to RNG
22:47:08.748 -> .
22:47:08.748 -> WiFi connected
22:47:08.748 -> IP address:
22:47:08.748 -> 192.168.1.210
22:47:13.762 -> connecting to temperatur.nu
22:47:13.809 -> Requesting URL: GET /rapportera.php?hash=ba79c368433558812acaXXXXXXXXXXX&t=1.23 HTTP/1.1
22:47:13.809 -> Host: temperatur.nu
22:47:13.809 -> Connection: close
22:47:13.809 ->
22:47:13.809 ->
22:47:13.903 -> HTTP/1.1 200 OK
22:47:13.903 -> Date: Mon, 13 May 2019 20:47:13 GMT
22:47:13.903 -> Content-Type: text/html; charset=UTF-8
22:47:13.903 -> Transfer-Encoding: chunked
22:47:13.903 -> Connection: close
22:47:13.903 -> Set-Cookie: __cfduid=dd8dde1757533f3c604bd2880c28cbccd1557780433; expires=Tue, 12-May-20 20:47:13 GMT; path=/; domain=.temperatur.nu; HttpOnly
22:47:13.903 -> Server: cloudflare
22:47:13.903 -> CF-RAY: 4d677c7e8b348671-ARN
22:47:13.903 ->
22:47:13.903 -> a
22:47:13.903 -> ok! (1.23)
22:47:13.903 -> 0
Jo, det kommer fram till textfilen iaf...larky skrev: 14 maj 2019, 07:31 Du kan kolla om det kommer fram genom att läsa textfilen
http://www.temperatur.nu/report/hash_baxxxxxxxxxxxx.txt
Kod: Markera allt
23:15:47.970 -> Wait...
23:15:50.979 -> Initializing modem...
23:16:01.570 -> Modem: ^CINIT: 8, 2048, 1 Ai Thinker Co.LTD A6 V03.03.20161229019H03
23:16:01.570 -> Waiting for network... OK
23:16:05.122 -> Connecting to online.telia.se OK
23:16:10.718 -> IP: 10.177.140.176
23:16:10.718 -> Connecting to temperatur.nu OK
23:16:14.003 -> Sending GET request
23:16:15.000 -> HTTP/1.1 200 OK
23:16:15.047 -> Date: Tue, 14 May 2019 21:16:12 GMT
23:16:15.094 -> Content-Type: text/html; charset=UTF-8
23:16:15.188 -> Transfer-Encoding: chunked
23:16:15.282 -> Connection: close
23:16:15.282 -> Set-Cookie: __cfduid=d68b93e1e1489984769bb1e6ebb3ec3ff1557868572; expires=Wed, 13-May-20 21:16:12 GMT; path=/; domain=.temperatur.nu; HttpOnly
23:16:15.610 -> Server: cloudflare
23:16:15.656 -> CF-RAY: 4d6fe454a958d133-GOT
23:16:15.703 ->
23:16:15.703 -> b
23:16:15.703 -> ok! (23.06)
23:16:15.750 ->
23:16:15.831 -> Server disconnected
23:16:15.868 -> GPRS disconnected
23:17:26.367 -> Waiting for network... OK
23:17:26.414 -> Connecting to online.telia.se OK
23:17:30.649 -> IP: 10.143.93.94
23:17:30.649 -> Connecting to temperatur.nu OK
23:17:34.040 -> Sending GET request
23:17:34.981 -> HTTP/1.1 200 OK
23:17:35.016 -> Date: Tue, 14 May 2019 21:17:33 GMT
23:17:35.124 -> Content-Type: text/html; charset=UTF-8
23:17:35.197 -> Transfer-Encoding: chunked
23:17:35.231 -> Connection: close
23:17:35.302 -> Set-Cookie: __cfduid=d15e950fdce983a38293a12879a62a8261557868652; expires=Wed, 13-May-20 21:17:32 GMT; path=/; domain=.temperatur.nu; HttpOnly
23:17:35.600 -> Server: cloudflare
23:17:35.636 -> CF-RAY: 4d6fe648ec477604-ARN
23:17:35.705 ->
23:17:35.705 -> b
23:17:35.705 -> ok! (23.12)
23:17:35.745 -> 0
23:17:35.745 ->
23:17:35.745 ->
23:17:35.802 -> Server disconnected
23:17:35.870 -> GPRS disconnected
23:18:39.242 -> Waiting for network... OK
23:18:39.309 -> Connecting to online.telia.se OK
23:18:40.487 -> IP: 10.177.209.190
23:18:40.487 -> Connecting to temperatur.nu OK
23:18:40.856 -> Sending GET request
23:18:42.054 -> HTTP/1.1 200 OK
23:18:42.101 -> Date: Tue, 14 May 2019 21:18:39 GMT
23:18:42.148 -> Content-Type: text/html; charset=UTF-8
23:18:42.242 -> Transfer-Encoding: chunked
23:18:42.310 -> Connection: close
23:18:42.343 -> Set-Cookie: __cfduid=d7610cb5377e1a8b450652ae8c646944d1557868719; expires=Wed, 13-May-20 21:18:39 GMT; path=/; domain=.temperatur.nu; HttpOnly
23:18:42.658 -> Server: cloudflare
23:18:42.705 -> CF-RAY: 4d6fe7eac908d13f-GOT
23:18:42.751 ->
23:18:42.751 -> b
23:18:42.751 -> ok! (23.06)
23:18:42.798 ->
23:18:42.845 -> Server disconnected
23:18:42.939 -> GPRS disconnected
23:19:53.407 -> Waiting for network... OK
23:19:53.485 -> Connecting to online.telia.se OK
23:19:57.674 -> IP: 100.65.73.44
23:19:57.674 -> Connecting to temperatur.nu OK
23:20:01.055 -> Sending GET request
23:20:02.196 -> HTTP/1.1 200 OK
23:20:02.233 -> Date: Tue, 14 May 2019 21:20:00 GMT
23:20:02.302 -> Content-Type: text/html; charset=UTF-8
23:20:02.404 -> Transfer-Encoding: chunked
23:20:02.475 -> Cone
23:20:02.475 -> Set-Cookie: __cfduid=db5c5cf14a8a6376288fb8f139cba547d1557868799; expires=Wed, 13-May-20 21:19:59 GMT; path=/; domain=.temperatur.nu; HttpOnly
23:20:02.767 -> Server: cloudflare
23:20:02.802 -> CF-RAY: 4d6fe9dffa12d143-GOT
23:20:02.880 ->
23:20:02.880 -> b
23:20:02.880 -> ok! (27.62)
23:20:02.914 ->
23:20:02.914 ->
23:20:02.914 ->