Everything comes together for a 1st prototype

This week my 1st self designed PCBs arrived from eurocircuits.com.

Below you see the frontside view, which is holding basically all components, more to that later.
PCB front

This is the PCB backside where actually only the 2X13 PIN connector goes in.
PCB backside

I used some one-way plastic soup bowls to assort the components for the three prototypes.
Assorted components

In the step below all resistors and the two ICs (MCP 3008 and MCP 23S17) have been soldered to the board.
ICs added

Almost there, connector for PIR and IR proximity added, DHT22 (Temperature & Humidity Sensor) and 7-segment displays added.
DHT22 and connector for IR proximity added

Completely assembled it looks like this.
Fully loaded shield prototype

To put it on the RaspberryPi I needed some extra tall stacking headers.
Stacking header für Raspberry Pi (extra tall)

Finally, this is how the shield looks when it is added to the Raspberry Pi.Prototype Shield on Raspberry Pi

Temperature and humidity sensor

To control the heating, the Pi needs to know temperature and humidity, this is possible by using the combined sensor DHT22. I got my unit from Adafruit here. It comes with the required 4.7K – 10K resistor, to be used as a pullup from the data pin to VCC. How the wiring on the breadboard works you can see depicted further below.

Initially I wanted to interface the DHT22 temperature and humidity sensor with perl. After some time it became obvious that perl on the Pi is not fast enough to read successfully from the sensor.

At that point I decided to use the great C-code from Adafruit (available on Github) and simply embed it into my perl script. A very useful tutorial from Adafruit is available here.

The picture below shows how the wiring looks like on the breadboard
Temp/Hum Sensor

This is how this translates into the Fritzing breadboard view
Temp/Hum Fritzing

The script calls the Adafruit C-code with the parameters 22 (for the sensor type) and 4 (which is the GPIO pin to be used). As even this code is not able to perform a successful measurement at every run I created a small loop to ensure that the logging only happens when the values have been extracted successfully. You may also notice the counter variable in the code, this variable can be used to track how many loops are required until a successful measurement could be taken. In practice the values are between 2 and 5 loops, maximum I noticed so far was 11.


# logfile handling
sub logging {

  my $logfile = "/appco.de/log/appco.de.log";

  if ( ! open LOG, ">>", $logfile ) {
    die "Kann Logdatei nicht anlegen: $!";

  my ($sekunden, $minuten, $stunde, $tag, $monat, $jahr) = localtime;
  my $echtes_jahr = $jahr + 1900;
  my $echter_monat = $monat + 1;
  printf LOG "%s.%02s.%02s %02s:%02s:%02s %s\n", $echtes_jahr, $echter_monat, $tag, $stunde, $minuten, $sekunden, $_[0];
  close LOG;


my $bin = './Adafruit_DHT 22 4';
my $check = 0;
my $counter = 0;

#run until a temperature and humidity value has been logged
while ($check == 0){
  # run the C program
  $result2 = `$bin`;

  # extract the strings
  my @array = split("\n", $result2);

  $counter = $counter + 1;

  # logging only if the string is not empty
  if ($array[2] ne "") {
    &logging ("$array[2]");
    &logging ("$counter");
    $check = 1;

Raspberry Pi and sensors

Inspired by the Nest® learning thermostat I want to improve the HomeAutomation capabilities of the Raspberry Pi by adding some sensors to enhance the functionality.

Temperature and humidity sensor
To measure the rooms temperature and humidity and to control the electrical valve accordingly. The reason to choose the sensor DHT22 over the DHT11, is the much higher precision. For example for temperature measures: ±0.5°C accuracy (DHT22) vs. ±2°C accuracy (DHT11). To my believe ±2°C is not acceptable for steering the temperature in a room.
Temp/Hum Sensor
Temp/Hum Sensor (on the right hand side) already hooked up to the T-Cobbler on a breadboard

The Pi should be able to notice whether someone is in the room and regulate the temperature accordingly. Over time the server should be able to build a schedule and maintain this schedule. I’ll use this sensor from adafruit.com
PIR Sensor

IR distance / proximity
With this sensor the server should be able to detect a human being close to itself and enable interaction by making the user inteface available. For the time being I will work with the Sharp GP2Y0A21YK0F and may move to a DIY version later on.
IR Distance Sensor