is websocket better or setInterval http request better?
Posted: Tue Sep 21, 2021 4:57 pm
I am building a wifi PIR system. When the PIR is triggered it will send the positive value to a site served on the esp32 server.
I have thought of 2 ways for this to work
1) Use a websocket to constantly trasmit data of PIR status (HIGH or LOW)
2) Build the HTML page served by the esp32 server and use javascript setInterval to constantly send http request to esp32 webserver to check the PIR status.
I built both and tested both. They both work as intended function wise. However which way is better ? There are some factors that i cant test such as which consumes more power etc etc..
I have thought of 2 ways for this to work
1) Use a websocket to constantly trasmit data of PIR status (HIGH or LOW)
2) Build the HTML page served by the esp32 server and use javascript setInterval to constantly send http request to esp32 webserver to check the PIR status.
I built both and tested both. They both work as intended function wise. However which way is better ? There are some factors that i cant test such as which consumes more power etc etc..