Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5

[Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www
#3

Hi Werk_AG,

nice to hear that.
I will try to add the changes in my post.
Probably the line numbers may be incorrect, so I added some example lines.
And if you would paste some parts/functions somewhere else --> feel free Big Grin.
I am new to this environment, and I am not so deep into it yet...

This is the RX part:

Code:
Install ArduinoJson library from Benoit Blanchon Main file: Between lines 67&69: #include <ESP8266.h> #include "VPcrc.h" Add: #include <ArduinoJson.h> Between lines 531&539:    #endif    // Check latest software version Add:    if (wifi.enableMUX()) {        Serial.print("multiple ok\r\n");    } else {        Serial.print("multiple err\r\n");    } Config_Options.h: After: // -------------------------------------------------------------------------------------- //   Define the type of your inside Temperature / Humidity Sensor // -------------------------------------------------------------------------------------- Replace with: #define INSIDE_TH_SENSOR   8   // 0= BME280, 1= HTU21D, 2= SHT21, 3= SHT31, 8=T/H over Wifi Routines.ino: After line 378: Add:  #if (INSIDE_TH_SENSOR == 8)  // T/H over Wifi    #if (ENABLE_INTERNET == 1)      uint8_t buffer[1024] = {0};      static uint8_t mux_id = 3;      //Change HOSTNAME String if differs: (wifi.createTCP(&mux_id,HOST_NAME, HOST_PORT,0)) {      if (wifi.createTCP(mux_id, "WirelessDisplay-"+String(Relay_ID), 80, 0)) {        //Serial.print("create tcp ok\r\n");      } else {        Serial.print("create tcp err\r\n");      }      //Change HOSTNAME if differs: s_Relay_ID String      String s_Relay_ID = String(Relay_ID);      char *prefix = "GET / HTTP/1.1\r\nHost: WirelessDisplay-";      char *postfix =" host:80\r\nConnection: close\r\n\r\n";            String url = prefix +s_Relay_ID+ postfix;      const char *get_json = url.c_str();  //Some Examples instead of const char *get_json = url.c_str() above: Attention: IP/Hostname must be the same as in wifi.createTCP      //char *get_json = "GET / HTTP/1.1\r\nHost: 192.168.1.140 host:80\r\nConnection: close\r\n\r\n";      //char *get_json = "GET / HTTP/1.1\r\nHost: ESP-17F41F host:80\r\nConnection: close\r\n\r\n";      //char *get_json = "GET / HTTP/1.1\r\nHost: 93.229.107.176 host:80\r\nConnection: close\r\n\r\n";            wifi.send(mux_id,(const uint8_t*)get_json, strlen(get_json));      //first receive for header      uint32_t len = wifi.recv(&mux_id,buffer, sizeof(buffer), 1000);      //second receive for payload      len = wifi.recv(&mux_id,buffer, sizeof(buffer), 1000);      if (len > 0) {        StaticJsonBuffer<300> jsonBuffer;        JsonObject& root = jsonBuffer.parseObject(buffer);        if (!root.success())        {          Serial.print("ParseObject() failed");          return;        }        TemperaturaInt = (int16_t)(root["InsideT"]);        Output_H_Int   = (int16_t)(root["InsideH"]);        }            if (wifi.releaseTCP(mux_id)) {        //Serial.print("release tcp ok\r\n");      } else {        Serial.print("release tcp err\r\n");      }    #endif  #endif  

and this is the WD part:
Code:
Install ArduinoJson library from Benoit Blanchon Main file: Between lines 43&44: #include <ESP8266WiFi.h> #include <ESP8266mDNS.h> Add: #include <ESP8266WebServer.h> #include <ArduinoJson.h> Between lines 172&173:  WGForecast forecasts[maxForecasts]; #endif   Add:  //---------------------------------------------------------  //     Start WebServer  //---------------------------------------------------------    ESP8266WebServer server(80);    // set Server Port  void set_data() {      StaticJsonBuffer<200> jsonBuffer;      JsonObject& jsonObj = jsonBuffer.createObject();      char JSONmessageBuffer[200];        if (Display.InsideT == 0)          server.send(204);      else {          jsonObj["InsideT"] = Display.InsideT; //inside T for example          jsonObj["InsideH"] = Display.InsideH; //inside H for example          jsonObj.prettyPrintTo(JSONmessageBuffer, sizeof(JSONmessageBuffer));          #ifdef PRINT_DEBUG_WIFI            Serial.println(JSONmessageBuffer);          #endif          server.send(200, "application/json", JSONmessageBuffer);      }  } Between lines 275&277:  connectWifi();  if (WiFi_connected) Add:  //  Handle events  server.on("/", HTTP_GET, set_data);  server.begin();               // Start the webserver Between lines 359&361:  if (ask433.available()) ReceiveDataRF();  // --- Things inside this, run once per minute Add: server.handleClient(); Routines: Between lines 71&72:  delay(100);  WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Add: WiFi.hostname("WirelessDisplay-"+String(Relay_ID));
 
So I always tried to show the important lines, in between there should be added sth.
e.g. WiFi.hostname MUST be before WiFi.begin...

If you have any questions - I will help you out and could explain every loc.

I hope it will help to enhance this great project a bit Smile.

You can test if the WD provides data by typing in the IP or the hostname in your browser and it should write sth. like:
{
 "InsideT": 248,
 "InsideH": 604
}

So these are the internal values (multiplied by 10) --> in JSON double values could also easily be transmitted... but I would stay at your data format!

regards,
t3gathome
Reply


Messages In This Thread
[Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 04-06-2018, 23:36
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 05-06-2018, 22:12
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 05-06-2018, 22:24
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 05-06-2018, 22:36
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 05-06-2018, 22:49
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 05-06-2018, 22:41
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 06-06-2018, 20:34
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 07-06-2018, 03:23
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by markkkk42 - 07-06-2018, 06:26
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 07-06-2018, 19:19
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 07-06-2018, 21:03
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 08-06-2018, 03:15
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 08-06-2018, 20:37
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 08-06-2018, 22:05
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 09-06-2018, 02:16
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by engolling - 10-06-2018, 22:04
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 12-06-2018, 21:59
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by engolling - 13-06-2018, 20:52
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 11-06-2018, 00:56
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 12-06-2018, 22:10
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 12-06-2018, 22:17
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 12-06-2018, 22:33
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 13-06-2018, 23:32
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 13-06-2018, 23:37
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 14-06-2018, 01:22
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 25-06-2018, 17:16
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 25-06-2018, 23:24
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 20-06-2018, 22:27
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 01-07-2018, 19:36
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 25-06-2018, 17:10
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 03-07-2018, 15:41
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 04-07-2018, 22:54
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by t3gathome - 08-07-2018, 21:02
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by werk_ag - 08-07-2018, 23:17
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by uncle_bob - 09-07-2018, 08:56
RE: [Pro2 Plus RX] Integrating RESTful Sensor Data - working solution for local wifi/www - by hornychz - 08-07-2018, 23:40



Users browsing this thread: 1 Guest(s)