Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial mySerial(13,15 ); //RX, TX
- void setup() {
- Serial.begin(2400);
- mySerial.begin(2400);
- }
- void loop() {
- if(Serial.available() > 0){//Read from serial monitor and send over HC-12
- String input = Serial.readString();
- mySerial.println(input);
- }
- if(mySerial.available() > 1){//Read from HC-12 and send to serial monitor
- String input = mySerial.readString();
- Serial.println(input);
- }
- delay(2000);
- }
- include <ESP8266WiFi.h>
- const char* ssid = "Alter_3G";
- const char* password = "xxxxxxx";
- const char* host = "www.hoppaiplurret.se";
- 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);
- 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 url = "/esp8266/index.php?temp=20"; //temp=20 ska bytas ut mot värdet vi hämtar i första loopen
- Serial.print("Requesting URL: ");
- Serial.println(url);
- // 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");
- delay(10);
- // Read all the lines of the reply from server and print them to Serial
- Serial.println("Respond:");
- while(client.available()){
- String line = client.readStringUntil('\r');
- Serial.print(line);
- }
- Serial.println();
- Serial.println("closing connection");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement