Hello.
I would like to ask a question about the implementation of a system that notifies the user of the temperature of a room and handles some other background tasks based on the temperature.
The scenario is the below:
A user can connect to a web server that will show a temperature real-time graph(this is based on the already implemented example on the github page).
The webserver will be hosted in the esp32 module.
The esp32 module will run a task that checks a DHT 22 module for the temperature of the room that it is located within.
The approach that i am facing my major problem with is how can i integrate the webserver and the task that checks the temperature and enable communication between them.
The idea is to have a controller within the webserver task that asks the other task, which checks the temperature.
I am required to implement it this way because, i dont know what might happen if i simply copy over the function that checks the temperature within the controller of the webserver and once a user is connected in order to view the graph the temperature questions that the ESP32 will ask the DHT will becomed doubled in the same amount of time.
That is why i wish to implement a path of communication between these two tasks so that the DHT task check the temperature/handles background logic and the Webserver task acts as a wrapper in order to get the data in the graph format.
I read about queues, but i am worried if i use the queues they simply hold data that are not requested by the webserver if no users are connected.
Can the above be implemented with message buffers? if so, can anyone share an example please?
Thanks for your time reading my starter post
starter project - a question about implementation
Re: starter project - a question about implementation
From my reading it appears that the web server and the dht code will be on the same esp32.
In that case in the dht code write the formatted or unformatted result to a global variable and in the server code pick it up.
Tom Meyers
In that case in the dht code write the formatted or unformatted result to a global variable and in the server code pick it up.
Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic
Santiago, Dominican Republic
Re: starter project - a question about implementation
Thanks for the reply Tom!
Affirmative, the code block will be run on one esp32 module. It was my fault not mentioning it.
Following your suggestion, i believe that locks should be implemented to in order to regulate the reading and writing transactions on the global variable, correct?
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: starter project - a question about implementation
You would use a mutex for that. If it fits you can also use an atomic variable to store your data (you're limited to 32 bits then, though), in which cases no mutexes are needed.
Who is online
Users browsing this forum: Baidu [Spider] and 117 guests