Reading data from Raspberry PI
In the previous recipes we saw how to communicate something to Raspberry PI, in this recipe we are going to close the recipes about Raspberry PI with the opposite operation: how to read data that Raspberry PI controls.
Getting ready
In this recipe we will use the same circuit built previously. The goal is to make small changes to the TCP / IP server, so that at the request of a specific light bulb status it responds with a code to identify whether it is ON or OFF.
We are going to use:
- Raspberry PI 3 Model B
- Two Channel Relay Modules (http://wiki.sunfounder.cc/index.php?title=2_Channel_5V_Relay_Module)
- Two light bulbs and relative supply power (the important thing is that the light bulbs have their own power supply)
- Jumper wires
For the management of the GPIO the TRaspberryPI
class is used, for any need refer to the recipe How to blink a LED using Raspberry PI where there is a good explanation.
How to do it...
For the part related to the Raspberry PI code, you can find...