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
#8

(06-06-2018, 20:34)t3gathome Wrote:  ...
I was very interested in the humidity data of the Display, because I have it in my bath... That's where the idea was born.
...

The bathroom always has been a place where many ideas was born.  Smile

(06-06-2018, 20:34)t3gathome Wrote:  ...
So I can live with any solution which could include the data of the Display in the whole weatherduino environment, that fits best according to your experience Wink
...

Instead of replacing the data of the local T/H sensor on the RX by the data of the local Wireless Display sensor, I'm thinking in allow to map those data to any of the seven Extra Sensors. User can choose which one by using the WeatherDuino mapping scheme.
Taking it even a step further, T/H data from up to four WD units can be mapped to any of the seven Extra Sensors. I'm sure you are seeing the possibilities...  Cool

Note the new "Source 5"!

Code:
// --------------------------------------------------------------------------------------
//   Extra Sensors Mapping
// --------------------------------------------------------------------------------------
// ---- Define the source and sensor type / number for each of the seven extra sensors, insert 9 if not used.
//      Sensors SHT31, SHT21 or HTU21D are type 0, sensors SHT1x or DHT22 are type 1
//
// ---- Source 0 means TX unit0, 1 means TX unit1...
// ---- Source 5 is for Temperature/Humidity from the Wireless Display units
// ---- Source 6 (Reserved)
// ---- Source 7 is for BIOS Sensor (Only Temperature is shown)
// ---- Source 8 is for Temperature/Humidity from the Air Quality Monitor
//
// ---- First field = Sensor source, Second field = Sensor type (0 or 1 for TX units) or number
// ---- Example:
// ----                          ES0   ES1   ES2   ES3   ES4   ES5   ES6    
//#define EXTRASENSORS_SOURCE { {0,1},{1,1},{5,1},{5,0},{9,9},{9,9},{8,0} }
//               {0,1} - First extra sensor (ES0), will be sensor 1 from TX unit0
//               {1,1} - Second extra sensor (ES1), will be sensor 1 from TX unit1
//               {5,1} - Third extra sensor (ES2), will be T/H data from WiFi Sensor 1 (Wireless Display 1)
//               {5,0} - Fourth extra sensor (ES3), will be T/H data from WiFi Sensor 0 (Wireless Display 0)
//               {9,9} - Fifth extra sensor (ES4), not used - not mapped
//               {9,9} - Sixth extra sensor (ES5), not used - not mapped
//               {8,0} - Seventh extra sensor (ES6), will be Temperature / Humidity from the Air Quality Monitor
//
//-----                        ES0   ES1   ES2   ES3   ES4   ES5   ES6    
#define EXTRASENSORS_SOURCE  { {0,1},{0,0},{5,0},{1,0},{9,9},{9,9},{8,0} }

#define EXTRASENSORS_SOURCE  { {0,1},{0,0},{5,0},{1,0},{9,9},{9,9},{8,0} }

With this we will have T/H from Wireless Display 0 mapped to third Extra Sensor... can be to any other!


Maybe by the weekend I will have a test version. Would you like to test it?

Currently I'm fine tuning some things.
uint8_t buffer[1024] = {0}; This is too large, system will crash in 2 or 3 days or even less.
StaticJsonBuffer can also be reduced to 100 bytes (50 may be enough, have to check it better).

Execution time is also a crucial item in all WeatherDuino routines.

Code:
create tcp OK
204
637
Routine took: 174 mS

create tcp OK
204
637
Routine took: 264 mS

create tcp OK
204
637
Routine took: 136 mS

create tcp OK
204
637
Routine took: 346 mS

create tcp OK
203
638
Routine took: 85 mS


This is a new routine for the RX, where almost all of your code is included.


Code:
//---------------------------------------------------------
//     Get Temperature / Humidity from WiFI sensors (Usually the local T/H sensor on Wireless Display units)
//---------------------------------------------------------
#if (ENABLE_INTERNET == 1 && ENABLE_GET_TH_FROMWD == 1)
 void getTHfromWD()
   {
     uint8_t mux_id = 3;
     uint32_t uploadApiTimer = millis();       // Used to check how long it takes to execute

     for(byte i=0; i<WIFIsensors; i++)
       {
         if (wifi.createTCP(mux_id, WIFIunit_IPaddress [0] [i], 80, 0))      
           {
             Serial.print(F("create tcp OK\r\n"));
             const char* prefix = "GET / HTTP/1.1\r\nHost: ";            
             const char* postfix =" host:80\r\nConnection: close\r\n\r\n";
             String ipaddress = WIFIunit_IPaddress [0] [i];
             String url = prefix + ipaddress + postfix;
             wifi.send(mux_id,(const uint8_t*)url.c_str(), strlen(url.c_str()));
             
             //first receive for header
             memset(temp_buffer, 0, sizeof(temp_buffer));      
             uint16_t len = wifi.recv(&mux_id, temp_buffer, sizeof(temp_buffer), 1000);
             //second receive for payload
             memset(temp_buffer, 0, sizeof(temp_buffer));
             len = wifi.recv(&mux_id, temp_buffer, sizeof(temp_buffer), 1000);
             if (len > 0)
               {
                StaticJsonBuffer<100> jsonBuffer;
                JsonObject& root = jsonBuffer.parseObject(temp_buffer);
                if (root.success())
                 {
                   Serial.println( (int16_t)(root["T"]));
                   Serial.println( (int16_t)(root["H"]));
                   WiFi_THdata [i][0] = (int16_t)(root["T"]);
                   WiFi_THdata [i][1] = (int16_t)(root["H"]);                    
                 }        
              }                      
            }
         wifi.releaseTCP(mux_id);            
       }

     for (byte i=0; i<7; i++)
      {
        if (ExtraS_Source[i][0] == 5)
         {
           ExtraS_Data[i][0] = WiFi_THdata [ExtraS_Source[i][1]] [0];  // Temperature Data
           loopData.extraTemperatures [i] = (ExtraS_Data[i][0] * 0.18)  + 122.5;
                 
           ExtraS_Data[i][1] = WiFi_THdata [ExtraS_Source[i][1]] [1];  // Humidity Data
           loopData.extraHumidities [i]   = (ExtraS_Data[i][1] + 5.0) * 0.1;
               
         }  
      }

     Serial.print(F("Routine took: ")); Serial.print((long)(millis() - uploadApiTimer));
     Serial.println(F(" mS")); Serial.println();            
   }
#endif

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)