Category Archives: Sensors

How to plot the frequency of PIR sensor events?

With a PIR sensor one can detect movements within it’s field of view and trigger other hardware, such as surveillance cameras. It is also possible to record the frequency of movements over time, e.g. to monitor motion activity in a room of your apartment.

pir_sensorWith a PIR sensor attached to my RasPi, I recorded motion events by storing UNIX timestamps in a single-column MySQL table. I wanted to visuaize these data points as a histogram displaying the frequency of motion events over time, but this task turned out to be more complicated than expected using GNUPlot. So here’s a short tutorial how it works:

Continue reading How to plot the frequency of PIR sensor events?

Raspberry Pi to Banana Pi migration

You might have noticed that my site was down for maintenance on Wednesday, 2014-09-17. For better WordPress performance, I decided to migrate my blog to a brand-new Banana Pi server, featuring a Cortex-A7/ Allwinner A20 Dual-core CPU with Mali-400M2 GPU — that’s cheating — I know 😀.

Let’s go bananas … !

It took me a couple of hours and some tinkering to move my WordPress installation including the MySQL database onto the new server. So here are my first impressions:

Continue reading Raspberry Pi to Banana Pi migration

RasPi Bird-O-Matic/ Bird Photo Booth

Since spring has almost arrived, I wanted to check how many birds are still coming to my feeder before removing it from the balcony. Good to have a Raspberry Pi for counting our feathered friends!

There are several ways to detect motion with a Raspberry Pi. The best and most popular method is connecting a PIR sensor, which detects the infrared radiation emitted or reflected from an object. Motion can be also detected by image processing of webcam frames with a software called motion. However, image processing requires CPU power, which is limited on a Raspberry Pi. Furthermore, motion detection with a webcam depends on decent light-conditions and may be triggered from inanimate objects, such as trees or leaves moved by the wind.

Here I wanted to test whether it is possible to count bird visits using an infrared light barrier. I had both a photo diode and a high power infrared LED lying around in my tool box (SFH230-FA and SFH4550). Consider this project as a “proof-of-principle” build and be aware that there are more reliable ways for detecting motion!

Since the SFH4550 has a narrow emission angle of 3°, I designed a circuit which allows to sense the light reflected by an obstacle which moves into the IR beam. The setup is very similar to IR range sensors used in robotics. The detection range is about 30 cm, which is decent to monitor the space within the bird feeder. Furthermore, the diodes are about 0.64 € each, which is much cheaper than a ready-to-use IR distance shield.

Continue reading RasPi Bird-O-Matic/ Bird Photo Booth

Connecting a DS18S20 temperature sensor to RasPi

I’ve been a little reluctant to connect a DS18S20 temperature sensor to my RasPi, since there were rumors that the w1_gpio.ko kernel module exclusively requires a connection to GPIO #4, because of being hard coded. At least that’s what Lady Ada’s tutorial says about it and what one can read in several user forums. Unfortunately GPIO #4 was already occupied on my Pi. Therefore I searched through several Blogs for advice how to change the hard-coded GPIO in the kernel module. It turned out that I wasn’t the only one – so here’s the good news: In Raspbian Wheezy with Kernel 3.10.25+ it is possible to pass the desired GPIO in /boot/cmdline.txt to the kernel using the option:

bcm2708.w1_gpio_pin=<GPIO#>

To be able to read temperatures from the sensor, modprobe the wire, w1_gpio and w1_therm kernel modules. The temperature can be read from /sys/bus/w1/devices/<device_serial_number>/w1_slave.

I’m using the the sensor for outdoor temperature measurement. I soldered about 1 m wire to the sensor (TO92 housing), insulated the solder joints with heat shrink tube and embedded the sensor into an old metal ballpoint cap using epoxy glue.