Project Mince Spy

Project Mince Spy

 

Santa is currently busy in the North pole, cracking on building his list of naughty and nice people and loading up his sleigh with all of the presents ready to deliver on Christmas Eve.

It's a big old journey around the world delivering all those presents to the good children of the world, so to help Santa on his way some people leave out a mince pie for him and a carrot for Rudolph. Come the morning, the mince pie has been eaten and the carrot consumed on the way through, and that way we know Santa has paid a visit to our house.

But... what if using a bit of clever electronics and a couple of Raspberry Pi's we could detect the exact moment that Santa has taken the mince pie and catch him delivering the presents? Behold...

PROJECT MINCE SPY

For this project you will need:

Optional:

Make your Mince Pie Pad

Taking two short lengths of the copper tape, stick them down onto your coaster with about a 1cm gap between them.

Leave approximately 2cm hanging off the end of your coaster. Fold each one in half to make a flat tab to attach your crocodile clip.

Building the Circuit

The first step is to build the circuit to allow us to catch Santa in the act of pinching the mince pie. For this we need to build something called a latch.

A latch circuit allows us to turn on an LED when a circuit has been broken but keep the LED on if the circuit is reconnected, just like if someone picked up a mince pie and then replaced it back on the mat. If the LED stays on we know that the mince pie has been moved. There is also a reset button which allows us to turn off the LED once the mice pie has been replaced.

Take care when placing the resistors that the two 10K resistors are attached to the 555 timer chip and the 1K resistors are used with the LED and as a pull up pin for the Raspberry Pi 3B+.

Connecting to the Raspberry Pi and the Mince Pie Pad

On the breadboard connect up the Pi pins in the following way:

  • Positive rail on the breadboard to a 3.3V pin on the Pi.
  • Negative rail to a GND pin.
  • The green wire in the Fritzing diagram above should be connected to GPIO 21 and pin 3 on the 555 chip.

Connect up the copper tape tabs to the breadboard using the crocodile clips.

At this point we can test the physical circuit by powering up the Raspberry Pi and lifting up the mince pie on the coaster.

 

 

Installing the Software

The LED on our circuit will let us know that the mince pie has moved, but what happens if we're not in the same room as our Mince Pie? Well, we can use a little bit of code to print a message to the Terminal to let us know when our pie has been picked up.

Opening a Terminal on the Pi 3B+ and type:

git clone https://github.com/modmypi/Mince-Spy

Then to run the local Mince Pie alerter:

cd Mince-Spy
python3 mincespysolo.py

Once the code is running we can re-test the mince pie pad by lifting up the mince pie, and along with the LED lighting up on the circuit, the Python script should print "Santa has been!" to the terminal, and once the mince pie is replaced and the reset button is pressed the terminal will show "Mince Pie Reset".

Adding the Mince Pi Zero alerter

We might want to have a bit more of a visual alert in another room from where the Mince Pie is being kept, so Santa doesn't get put off doing his rounds of delivering presents.

For this we're going to need to get our Raspberry Pi Zero and TroPi and connect them together.

 

Once the TroPi is in place, we need to power up the Raspberry Pi Zero and get the alerter code running.

Open a terminal session and type:

git clone https://github.com/modmypi/Mince-Spy
Now we need a little bit of extra code to run the TroPi so next, type into the terminal:
cd Mince-Spy
git clone https://github.com/piborg/TroPi/blob/master/tropi.py

We also need to know the IP address of the Raspberry Pi Zero so we can tell the Raspberry Pi 3B+ attached to the circuit where to send the alert. In the terminal window on the Pi Zero type:

ifconfig

Next to "wlan0" there should be an IP address, ours is '192.168.1.197'. Make a note of your address.

Run the code on the Pi Zero by typing:

python3 mincespyalert.py

Moving back onto the Raspberry Pi 3B+, in the terminal in the Mince-Spy directory type:

nano mincespylatch.py

On line 9, there's a call to "sock.connect" and an argument which reads 'IP HERE'. Replace the text with your IP address. So for example ours would read:

sock.connect(('192.168.1.197',9050)) #Connect to remote server

Save and exit nano (usually CTRL+X and Y to save the file).

Now we're ready to run the code on the Raspberry Pi 3B+. Back in the terminal type:

python3 mincespylatch.py
Now the Raspberry Pi 3B+ attached to the circuit is ready to send a signal to the Raspberry Pi Zero with the TroPi on, to let you know the mince pie has moved.

 

 

 

 

And now we're totally ready for Santa to deliver presents (or to stop your friends eating your Mince Pies).

 

Leave a comment

All comments are moderated before being published.

This site is protected by hCaptcha and the hCaptcha Privacy Policy and Terms of Service apply.