Adding pressure and changing temp data
BreatheEasy - DEVLOG #8
Hello everyone! I hope you’re doing well…
Today, I have some exciting changes to talk about .
What has changed?
First of all, I made the decision to start taking temperature data from the BMP280 since it is generally more accurate than the DHT11.
Talking about the BMP280….
There is a new measurement on the frontend of BreatheEasy!
Atmospheric pressure!
This metric is usefull for predicting upcoming weather coditions.
Something I realized I have never explained is how the data gets from the ESP32 to the actual website…
It is quite simple:
We send a json string using:
String json = "{";
json += "\"temperature\":";
json += isnan(temperature) ? "null" : String(temperature, 1);
json += "}";
And on the webpage side we have a function that decodes the data sent and displays it on HTML card elements:
async function updateDashboard(){
try {
const response = await fetch('/data');
const data = await response.json(); console.log("Updating dashboard...", data);
if (data.temperature !== null && data.temperature !== undefined) {
if(data.temperature > maxTemp){
maxTemp = data.temperature;
if (tempMaxElem) tempMaxElem.innerHTML = maxTemp + " °C";
}
if(data.temperature < minTemp){
minTemp = data.temperature;
if (tempMinElem) tempMinElem.innerHTML = minTemp + " °C";
}
Which also handles the Min/Max parts of the UI.
I want to ask a favour from anyone who reads this…
Please recommend a color for the 3D-Printed case!
(I’m thinking transparent…)
Anyway, that’s it for today I wish you all a nice day!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.