G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 9th, 2020 177 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SoftwareSerial.h>
  2.  
  3. SoftwareSerial mySerial(13,15 ); //RX, TX
  4.  
  5. void setup() {
  6.   Serial.begin(2400);
  7.   mySerial.begin(2400);
  8. }
  9.  
  10. void loop() {
  11.   if(Serial.available() > 0){//Read from serial monitor and send over HC-12
  12.     String input = Serial.readString();
  13.     mySerial.println(input);  
  14.   }
  15.  
  16.   if(mySerial.available() > 1){//Read from HC-12 and send to serial monitor
  17.     String input = mySerial.readString();
  18.     Serial.println(input);  
  19.   }
  20.   delay(2000);
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. include <ESP8266WiFi.h>
  29.  
  30. const char* ssid     = "Alter_3G";
  31. const char* password = "xxxxxxx";
  32.  
  33. const char* host = "www.hoppaiplurret.se";
  34.  
  35. void setup() {
  36.   Serial.begin(115200);
  37.   delay(10);
  38.  
  39.   // We start by connecting to a WiFi network
  40.  
  41.   Serial.println();
  42.   Serial.println();
  43.   Serial.print("Connecting to ");
  44.   Serial.println(ssid);
  45.  
  46.   WiFi.begin(ssid, password);
  47.  
  48.   while (WiFi.status() != WL_CONNECTED) {
  49.     delay(500);
  50.     Serial.print(".");
  51.   }
  52.  
  53.   Serial.println("");
  54.   Serial.println("WiFi connected");  
  55.   Serial.println("IP address: ");
  56.   Serial.println(WiFi.localIP());
  57. }
  58.  
  59. int value = 0;
  60.  
  61. void loop() {
  62.   delay(5000);
  63.   ++value;
  64.  
  65.   Serial.print("connecting to ");
  66.   Serial.println(host);
  67.  
  68.   // Use WiFiClient class to create TCP connections
  69.   WiFiClient client;
  70.   const int httpPort = 80;
  71.   if (!client.connect(host, httpPort)) {
  72.     Serial.println("connection failed");
  73.     return;
  74.   }
  75.  
  76.   // We now create a URI for the request
  77.   String url = "/esp8266/index.php?temp=20"; //temp=20 ska bytas ut mot värdet vi hämtar i första loopen
  78.  
  79.   Serial.print("Requesting URL: ");
  80.   Serial.println(url);
  81.  
  82.   // This will send the request to the server
  83.   client.print(String("GET ") + url + " HTTP/1.1\r\n" +
  84.                "Host: " + host + "\r\n" +
  85.                "Connection: close\r\n\r\n");
  86.   delay(10);
  87.  
  88.   // Read all the lines of the reply from server and print them to Serial
  89.   Serial.println("Respond:");
  90.   while(client.available()){
  91.     String line = client.readStringUntil('\r');
  92.     Serial.print(line);
  93.   }
  94.  
  95.   Serial.println();
  96.   Serial.println("closing connection");
  97. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top