I need to connect some sensors wireless using an ESP8266 which transfers data over my home Wi-Fi network from sensor to Raspberry Pi. Now, I was told on the Raspberry Pi Stack Exchange that when using the ESP8266, there would be no need of physically connecting the sensor to the Pi using wires. But how to do that wireless? What is the code in Python?
A powerful and simple communication protocol is MQTT.
MQTT is a protocol that is suitable for communication between low power devices like ESP8266 and Raspberry Pi. It is lightweight and simple to implement.
MQTT is a broker/Client system and there are libraries to ESP8266/Arduino as well as Python.
For the ESP8266/Arduino part, there are several instructive videos on Youtube by Andreas Spiess among others.
Andreas Spiess: https://www.youtube.com/channel/UCu7_D0o48KbfhpEohoP7YSQ
Step 1: Install nodeJs on Pi.
Step 2: Create REST Api by using angular 2-4 with database . Refer: https://www.sitepoint.com/angular-rxjs-create-api-service-rest-backend/ Step 3: configure WI-FI module and trigger the rest services through it. Elaboration: Rest Api is triggered through wifi module through which data of sensor was sent to the database through which you will able to do actuation.
NOTE: In python scenario the creation and triggering of REST Api is through python.