Category Archives: Raspberry Pi

SSL support for Nginx

In order to take part in the “Reset the NET Campaign” (see the previous post) and to honour the first anniversary of Edward Snowden’s revelations, I configured my self-hosted server to support HTTPS/SSL requests. Now you can reach this site also at https://raspberryblog.de. Furthermore, I highly recommend using the Firefox HTTPS everywhere plugin of the Electronic Frontier Foundation to encrypt your traffic while visiting all sites supporting SSL.

Here’s a brief tutorial how it works: If you haven’t installed Nginx, yet, please see the documentation at nginx.org. For an existing installation, create a subdirectory in /etc/nginx to store your SSL certificates.

sudo mkdir /etc/nginx/ssl
cd /etc/nginx/ssl

Next, create the server key and certificate signing request. Start by creating the private server key. During this process, you will be asked to enter a passphrase. Be sure to remember this phrase! If you forget it or lose it, you will not be able to access the certificate again.

Continue reading SSL support for Nginx

What performs better on a RasPi: Apache, Lighttpd or Nginx?

As I’m hosting my blog on a Raspberry Pi, I did some research on the web about it’s performance as a server. I started this site with Apache and migrated after a while to Lighttpd which already reduced server response time (3.6 seconds, according to Google’s PageSpeed Insights it reached 72/100 points) and improved performance. With an DSL upload speed of only 676 kbit/s one shouldn’t expect miracles anyway. Google’s PageSpeed results, which suggested to make a couple of changes to my site, and a comparison of Lighttpd vs. Nginx convinced me to migrate to Nginx.

Continue reading What performs better on a RasPi: Apache, Lighttpd or Nginx?

Home automation – Driving a relay with RasPi/ ATtiny

So far I’ve attached devices to my Raspberry Pi or Arduino Uno with ratings less than 100 mA. These devices were connected to the output pins through a transistor or optocoupler. However, for heavy load currents a relay must be used. As a noob, it is somewhat difficult to chose parts with the right specs for driving a relay — so here are some hints.

Continue reading Home automation – Driving a relay with RasPi/ ATtiny

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.