Skip navigation

Raspberry Pi Projects

5 Posts authored by: severian

My Foginator 2000

Posted by severian Oct 31, 2015

Ralph's Foginator 2000


  It all works nicely, as of this afternoon.  I simplified the audio because I did not get my Raspberry Pi audio cable ready.  With as many Raspberry Pi B+ and newer that have been sold, I wonder why someone does not build audio cables.  Ideally, it would be a short cable with the weird Raspberry Pi trrs connector on one end and a female 3.5 stereo audio jack on the other end.  Then, you could plug cheap computer speakers in.  I mount Raspberry Pis on the back of LCD monitors.  These pften have a 3.5mm stereo jack built in.  Oh, well.


So, I used the network to play the audio.  When the neopixel display lights up, a command is sent through ssh to a desktop Linux machine to play the sound file Charles Gantt calls correct.mp3  I like the effect of it coming from the next room.  This project has been fun and I look forward to starting a new one  I'd like to build a movement tracker using the accelerometer, magnetometer, and gyroscope in the Sense Hat.  I have played with those a bit and I see I need to do some research on smoothing that data to make it useful.  Everyone have a happy All Saints Day(Nov 1).

  I added startup for all the main pieces.  On both Pis, this meant adding a line to near the bottom of /etc/rc.local. The line goes just above the exit line you see at the bottom.  Here is what I added:

  sh /root/ &


I started the shell script running in the background.  The shell script waits 30 seconds, then mounts the samba share of the other Pi.  I start this script in the background so the main console stays ready for logins, if I were to plug a keyboard and monitor in.  On the Raspberry Pi 2 B, it then runs the python script that watches for files in /public and activates the display to show virtual fog.  On the Raspberry Pi B+, I start 2 python scripts in the background.  The first of those watches the PIR and notifies the 2 B when it sees movement.  The second script watches for new files in /public and lights up the NeoPixels when it finds a new file.  I can now power both systems up and with no interaction, itall works fine.  So, I assembled the pieces in the top of a box and I'll leave it running overnight. I'd like to have the spooky audio, so my first task for Saturday is to see if I can make or get an audio cable.  I'll add pictures of the assembled system on the next blog entry.  I need another USB cable to download the pictures.  This has been a fun little project so far and it is nice to see it running.


I am including all those files so you can look at them

  The files are named a little differt in the attachments than how they are on disk, so I will explain. - this is /root/ on the Raspberry Pi 2 B - this is /root/start_watching on the Raspberry Pi B+ - this is the python script to watch the PIR module and notify the 2B - this is the python module to turn on the NeoPixel stick and where the fog machine would be activated - this is the script to turn on the virtual fog on the Sense Hat

  As I mentioned last time, I added a Raspberry Pi B+ to the project, basically to take advantage of its GPIO pins.  Today, I was going to start interfacing the Arduino , which is driving the Neopixel stick.  I had read that there was a nice library for letting ArmV6 Raspberry Pis Raspberry Pis drive NeoPixels.  So, I movel the NeoPixel stick over to the secondary Raspberry Pi in thes project, which is a Raspberry Pi B+.  I tried out the library and it works quite well so far.  So, now this Pi is detecting people walking up with the PIR sensor, and driving the NeoPixe stick.  I expect it will have no problem controlling the relay board.  That is really simple, and timing is not crucial.  I thought I might be keepingthe B+ busy enough that the NeoPixels might not look good, but the Raspberry Pi is doing just fine.  Here is a picture of the B+ with the PIR module, and NeoPixel stick connected.

Raspberry Pi B+ with PIR and NeoPixel stick


The Raspberry Pi B+ is in a nice case I printed from a design on thingiverse.  I am still experimenting with how to mount the Raspberry Pi 2 B with the Sense Hat.  It may justget mounted on a spare VESA plate I laser cut.  The HAT gets in the way for most cases and I can'y getto the laser cutter to design a custom case at the moment.  Let me give you a close up on the breadboard showing the connection a little better.

breadboard with connections from Raspberry Pi B+, PIR module and NeoPixel stick


I will also add a short video showing the NeoPixel stick running from the B+/  The B+ is running the PIR detection script at the same time and is commanding the Raspberry Pi 2 B to scroll fog messages across the Sense Hat.


  The final assembly blog entries by the project designer(Charles Gantt)have not shown up yet, so I am going to  improvise.  I'll probably mount things in a box and tie them down with twine. I'll show more on that next time.

I got a box of nice parts to build my copy of the Foginator 2000

Raspberry Pi 2B, Sense Hat and other parts

  My biggest  confusion was what to do about the other parts I would need.  I did not know if they were arriving seperately or whether I needed to order them.  As time was growing short, I decided to proceed with experimenting and plan to visit Tanners Electronics in Carrollton to get more parts locally.  Fortunately, Tanners is a great local resource if you are near Dallas, Texas.


  I started by connecting the Sense Hat to the Raspberry Pi to see how it works. I found several example programs  on a site where the board was referred to by its old name(i.e., AstroPi)  I tested these and generally I am pleased.  The temperature reads somewhat high.  That is either because it needs calibration, or because the parts around it warm it up. Some calibration seems reasonable.  I have to do that with other temperature sensors I use.


I see one problem, and I expect I will have to modify the project a bit to get around it.  There are no GPIO pins to directly connect to on the Sense Hat.  The project author mentions getting a special pin extender, but I don't have time for that.  So, I'll just use another Raspberry Pi.  I'll do GPIO stuff, like the PIR sensor on the second unit.  The primary Pi will be the master program and use the Sense Hat.  I'll talk between them over ethernet.

Next, I went to the NeoPixel stick and a NeoPixel Ring.and connected them to an Arduino, like the project author does.  I have used longer LED strips on a couple of projects, but never the NeoPixel stick or ring.  They both work quite well, just as I expected.  I can see several uses for these products on other projects.  I'll need to measure power consumption on the ring for one hand held devive I had prototyped with 5mm LEDs.  The NeoPixel will look much better, and should fit well with the LilyPad, a GPSmodule, and a battery.


  The other Raspberry Pi I have with me tonight is running Ubuntu Mate 15.04.  I tried it with the PIR sensor and got a segmentation error.  I'll bring a Raspberry Pi B+ or 2 B with a fresh Raspbian image in tomorrow to try that again.

I need to pck up another 1000 micro farad cap so I can connect the stick and the ring.

I am going to stop here for now.  I have another point or two, but I want to see if I can edit a blog entry on this platform.


Note:  This content appeared in my own blog area yesterday.  I meant it to appear here.  I could not figure out how to move it, so I recreated it/

  This is my second blog entry about this project.  I must have saved the first one to the wrong area on Element14, and I'll work on moving it after I finish this entry.  As I mentioned in part 1, I could not get the special pin extender in time to mount the PIR detector on the Raspberry Pi with the Sense Hat.  So, I elected to add another Raspberry Pi to the project and connect all devices other than the Sense Hat to it.  It is a Raspnerry Pi B+, which I had as a spare.I connected the HC-SR501 PIR module using 3 pins.  I first tried using 3.3V on the Raspberry Pi to go to the HC-SR501 module.  I had read a couple of places that the module worked better at that voltage.  Well, not for me.  I connected Vcc on the HC-SR501(henceforth referred to as PIR) to 5Von the Pi, out on the PIR to GPIO7 on the PI, and ground on the PIR to ground on the PI.  I turned the sensitivity down a bit(counter clockwise on the left pot).


  I then setup samba on the Raspberry Pi 2 B.  I am going to use a simple method to communicate.  When motion is detected on the B+, it will create a file in the directory the 2B is sharing.  The 2 B runs a script that watches that directory and when the file is created, the fog machine gets turned on, and the notification file is deleted, so we can get the next notification.


  Here are the two programs I used for my PIR communications.  I have not figured out how to make them look right on the blog, and I apologize for that  The B+ has the PIR device and has the samba share mounted in a directory called /lee/lemonpi.  The workgroup name I use for samba is lee and the Raspberry Pi 2B has a hostname of lemonpi.  Th Pi B+ runs the following Python script(

from subprocess import call

import RPi.GPIO as GPIO                           #Import GPIO library

import time                                       #Import time library

GPIO.setmode(GPIO.BOARD)                          #Set GPIO pin numbering

pir = 7                                          #Associate pin 26 to pir

GPIO.setup(pir, GPIO.IN)                          #Set pin as GPIO in

print "Waiting for sensor to settle"

time.sleep(2)                                     #Waiting 2 seconds for the sensor to initiate

print "Detecting motion"

while True:

   if GPIO.input(pir):                            #Check whether pir is HIGH

      nice_time = time.strftime('%l:%M%p %Z on %b %d, %Y') # ' 1:36PM EDT on Oct 18, 2010'

      print "Motion Detected at", nice_time


      time.sleep(2)                               #D1- Delay to avoid multiple detection



  The Raspberry Pi 2B is running samba.  It is sharing a directory called /public and the last few lines of /etc/samba/smb.conf look like this:


   comment = Lemon Pi's public area

   path = /public

   guest ok = yes

   browseable = yes

   create mask = 0775

   directory mask = 0775

   read only = no


  The Raspberry Pi 2 B is running the following Python script(

import pyinotify

from sense_hat import SenseHat

import time

from subprocess import call


sense = SenseHat()

start_time = 0     # start at 0 so first pir event will trigger


class EventHandler(pyinotify.ProcessEvent):

    def process_IN_CLOSE_WRITE(self, event):

        global start_time

        elapsed_time = time.time() - start_time

        if elapsed_time > 60:   # Only trigger once per this many seconds

            start_time = time.time()        # reset timer

            sense.show_message("Fog envelops you")  # or start fog machine here

            print "Triggered by closing file name " + event.pathname

       # if you want to see when ignored events come in, uncomment this block

       # else:

       #       print "ignoring pir notice", elapsed_time

        # if a second trigger comes in while I was busy processing the first, an

        # error message will be printed.  It may safely be ignored.

        call(["sudo","rm", event.pathname])


def watch(filename):

    wm = pyinotify.WatchManager()

    mask = pyinotify.IN_CLOSE_WRITE

    wm.add_watch(filename, mask)


    eh = EventHandler()

    notifier = pyinotify.Notifier(wm, eh)



if __name__ == '__main__':

    watch('/public')  # trigger on any new file in this directory


  The only thing you may not recognize there is import pynotify.  If you don't have that installed, you can just do a "sudo pip install pynotify".  If you don't have pip installed, just do a "sudo apt-get install python-pip"


This all proves my idea for using 2 PIs should work.  I'll have to modify Charles Hantt's programs to incorporate similar logic.

Filter Blog

By date: By tag: