2

I am working on a project where I have got an ESP32 device (Wifi & Bluetooth), which reads data from some sensors, such as temperature and soil moisture (outdoor environment). The data is then sent to a Raspberry PI which is 15 meters far, the PI then sends the data over the Internet. Now, The Raspberry will be plugged into an external stable power source, while the ESP32 will be running by a 3.3 Volt battery, so I need to design well the way the 2 devices communicate to save energy. At first glance I was thinking about simple RESTful API, basically, a flask app running on the PI with the ESP32 to wake up from deep sleep mode every 3 hours to send POST Request to the server. After a bit of research, I then found that my ESP32 supports also BLE (Bluetooth Low Energy), so I was playing a bit with that, and I have been able to exchange some data between the PI and the ESP32. The way I do is:

  • The ESP32 advertises itself, writing the value of the sensors in a characteristic
  • The PI scans continuously for the ESP32 and when found reads the data
  • The ESP32 to deep sleep after every cycle.

Even If I managed to make that work, I think the Flask approach is much cleaner because there is no loop as there is now in the PI. The point is that the ESP32 is almost always deep sleeping so I need to loop (in the PI) to find it and if found read the data. I am reading around that in BLE design the sensor is the server, but I think it might be better if the PI would be the Server advertising itself and the ESP32 to discover it and write the value of the sensor in one characteristic. I still need to fully understand the best pattern here.

Any suggestion from someone which some more experience in the above?

3
  • "The data is then sent to a Raspberry PI which is 15 meters far, the PI then sends the data over the Internet." if that is all that it does, then this sounds overly complicated, since ESP32 has WiFi. Van you explain why you need a Pi at all?
    – Mawg
    Commented Oct 20, 2020 at 8:28
  • "The point is that the ESP32 is almost always deep sleeping so I need to loop (in the PI) to find it and if found read the data." - why? The ESP32 can deep sleep, for a given time, then wake up briefly to send measurements by WiFI and then sleep again, until the next time to measure or send. There are lots of code samples, if you search for them.
    – Mawg
    Commented Oct 20, 2020 at 8:29
  • 1
    WIFI is an option, BLE might be slightly better from a current consumption point of view. I am experimenting and found some solutions, but I need to measure the current consumption to see the difference.
    – Edge7
    Commented Oct 20, 2020 at 9:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.