Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ESP8266WiFi.h"
- #include <MAX6675_Thermocouple.h>
- #define SCK_PIN 14 //(D5)
- #define CS_PIN 4 //(D2)
- #define SO_PIN 5 //(D1)
- #define CS2_PIN 0 //(D3)
- MAX6675_Thermocouple* thermocouple = NULL;
- MAX6675_Thermocouple* thermocouple2 = NULL;
- const char server[] = "192.168.10.14";
- const char* MY_SSID = "WWW.........CZ";
- const char* MY_PWD = "................";
- WiFiClient client;
- void setup(){
- Serial.begin(115200);
- thermocouple = new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN);
- thermocouple2 = new MAX6675_Thermocouple(SCK_PIN, CS2_PIN, SO_PIN);
- Serial.print("Connecting to "+*MY_SSID);
- WiFi.begin(MY_SSID, MY_PWD);
- Serial.println("going into wl connect");
- while (WiFi.status() != WL_CONNECTED) //not connected, ...waiting to connect
- {
- delay(2000);
- Serial.print(".");
- }
- Serial.println("wl connected");
- Serial.println("");
- Serial.println("Credentials accepted! Connected to wifi\n ");
- Serial.println("");
- }
- void loop() {
- const double t = thermocouple->readCelsius();
- const double v = thermocouple2->readCelsius();
- Serial.print("Teplota - senzor 1: ");
- Serial.println(String(t) + " st. C");
- Serial.print("Teplota - senzor 2: ");
- Serial.println(String(v) + " st. C");
- delay(20000);
- Serial.println("\nStarting connection to server...");
- // if you get a connection, report back via serial:
- if (client.connect(server, 80)) {
- Serial.println("connected to server");
- WiFi.printDiag(Serial);
- String data = "t="
- + (String) t
- + "&v=" +(String) v;
- //change URL below if using your Sub-Domain
- client.println("POST /polycom/zpracuj.php HTTP/1.1");
- //change URL below if using your Domain
- client.print("Host: 192.168.0.103\n");
- client.println("User-Agent: ESP8266/1.0");
- client.println("Connection: close");
- client.println("Content-Type: application/x-www-form-urlencoded");
- client.print("Content-Length: ");
- client.print(data.length());
- client.print("\n\n");
- client.print(data);
- client.stop();
- Serial.println("\n");
- Serial.println("My data string im POSTing looks like this: ");
- Serial.println(data);
- Serial.println("And it is this many bytes: ");
- Serial.println(data.length());
- delay(20000);
- }
- }
- void printWifiStatus() {
- // print the SSID of the network you're attached to:
- Serial.print("SSID: ");
- Serial.println(WiFi.SSID());
- // print your WiFi shield's IP address:
- IPAddress ip = WiFi.localIP();
- Serial.print("IP Address: ");
- Serial.println(ip);
- // print the received signal strength:
- long rssi = WiFi.RSSI();
- Serial.print("signal strength (RSSI):");
- Serial.print(rssi);
- Serial.println(" dBm");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement