Sense and Control Using Raspberry PI
Hickmat 100000QA3T Visits (5272)
After my success with MQTT, Mosquitto and driving the GPIO on my PI I decided it was time to try and sense external event via the GPIO.
Goal... When IR sensor detects a block switch on a LED. Progressively move through set of 4 LED's
This time round my language of choice this time was Java. To support this I had found the raspberry-gpio library via the Web but when I went to check for it as part of writing this entry it appears to have vanished. In its place I discovered pi4j. I've not had chance to play with this library yet but it looks interesting (I feel another project coming on ). Anyway the raspberry-gpio library worked by providing an API which allowed the direction of a pin to be set and then the value of the pin read and set via get and set methods. What it didn't provide me with (which pi4j appears to) was a mechanism to detect a change of state on a pin. As this was key to my work I needed to create a solution which would address this. Whilst look at this issue I figured out that what I really needed to create was a service which could read a properties file and based on the contents for the this file manage a number of pins. Based on this I created the following structure for my properties file.
Based on this I decided to use the follow architecture to achieve my goal.
In terms of the electronics... For controlling the LED's I used the circuit I've documented earlier in this blog but for the Infrared Sensor I used this kit from Maplin. As I was going to need to enhance this circuit (basically to set the GPIO pin rather than sound the buzzer) I ditched the PCB's and recreated the circuit on breadboards based on the following circuit diag
The results of this can be seen in the following Video
So that concludes this Blog post. If there are bits that you'd like more detail on please feel free to ask and I'll do my best to respond.