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
.
I am new to this environment, and I am not so deep into it yet...
This is the RX part:
and this is the WD part:
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
.
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
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
.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
.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

