@Xilef
Hi,
thats great news.
The screenshot shows that you setup the ESP32 and the sensor correctly.
The main problem is that the ESP now displays a webpage.
There are two possible ways now. Either you embed the webpage (as it is) into the mirror with a module like MMM-EmbedURL or to get the ESP to display the data machine readable.
Maybe the sketch you flashed to the ESP already contains a way to read the data in a different format? Which one did you use?
Edit: I think it is this one, am i right? Then there is no easy way.
I think i can provide a sketch that is more “mirror friendly” but you will need to set a static IP for the ESP. Is this ok for you?
You will need to change to your needs:
- ##ADD_WIFI_SSID_HERE
- ##ADD_WIFI_PASSWORD_HERE
- IPAddress local_IP(192, 168, 0, 2);
- IPAddress gateway(192, 168, 0, 1);
- IPAddress subnet(255, 255, 255, 0);
- IPAddress primaryDNS(192, 168, 0, 1);
#include <WiFi.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
const char* ssid = "##ADD_WIFI_SSID_HERE";
const char* password = "##ADD_WIFI_PASSWORD_HERE";
//ENTER STATIC IP OF THE ESP32 BOARD HERE
IPAddress local_IP(192, 168, 0, 2);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(192, 168, 0, 1);
IPAddress secondaryDNS(8, 8, 8, 8);
Adafruit_BME280 bme;
WiFiServer server(80);
void setup()
{
Wire.begin();
Serial.begin(115200);
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
Serial.println("STA Failed to configure");
}
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.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("ESP Mac Address: ");
Serial.println(WiFi.macAddress());
Serial.print("Subnet Mask: ");
Serial.println(WiFi.subnetMask());
Serial.print("Gateway IP: ");
Serial.println(WiFi.gatewayIP());
Serial.print("DNS: ");
Serial.println(WiFi.dnsIP());
if (!bme.begin(0x76);) {
Serial.println("Couldn't find sensor!");
while (1);
}
server.begin();
}
void loop()
{
float temp = bme.readTemperature();
float tempf = temp * 1.8 + 32;
float rel_hum = bme.readHumidity();
WiFiClient client = server.available();
if (client) {
Serial.println("New Client.");
client.println("{");
client.print(" \"temperature_c\": ");
client.print(temp);
client.println(",");
client.print(" \"temperature_f\": ");
client.print(tempf);
client.println(",");
client.print(" \"humidity\": ");
client.print(rel_hum);
client.println(",");
client.println(" \"error\": false");
client.println("}");
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
delay(100);
}
You can use netcat to fetch the data:
/bin/nc -w3 THE_IP_OF_THE_ESP 80
And the result will be something like:
{
"humidity": 32.61236572265625,
"temperature_c": 25.50150878906249,
"temperature_f": 77.9027158203125,
"error": false
}
This kind of JSON object then can be read by my MMM-Temperature module.