Introduction: Food Cam

This project was inspired by the food cam project done by the MIT Media Lab. This project is part of the college service Coding For Good at UWCSEA East in Singapore. The goal of this project is to reduce the amount of food wasted by our community by giving people an alternative to throwing away their uneaten food.

The food cam project allows food that would have otherwise been wasted to be placed under a camera, have a photo taken of it and uploaded to Twitter for the entire community to view. Thereby allowing anyone to come to finish off the free food. This instructable will take you on our journey of making and implementing the Food Cam in our school community.

Step 1: Collecting the Electronics

In order to get started with the electronics part of the project, we first need to collect the following list of parts (below). The power bank is optional and only necessary if you require this device to be portable. In our case, we planned to have a stationary product with an extended micro-USB to USB cord supplying power to the Pi. Additionally, the specs of the button do not matter much with the exception of the button being a PTM (push to make) switch or a momentary switch. This will be important later on for the functionality of both the camera and code.

As for the hardware, don't worry about that for now. If you are looking to complete that, skip to step 11.

Here is what you must have as a prerequisite to attempting this project:

1. A Stable Internet Connection

2. HDMI Cable

3. Monitor

4. Mouse

5. USB port

The Electronics (BOM) *Soldering Iron Required:

1x Raspberry Pi 3 Model B

2x LEDs (1x Red, 1x Green)

1x Raspberry Pi Cam (V2.1)

6x Female To Female Wires

1x Big Red Button (PTM)

2x 470 Ohm Resistor

1x Power bank (5500 mAh) (Optional)

1x USB to micro-USB cable

1x Micro SD Card

1x Micro SD Card Reader

Step 2: Insert the Camera Into the Raspberry Pi

Insert the flex cable from the camera into the flex cable port on the Raspberry Pi board. Do this with care as replacing these parts can be quite expensive!

Step 3: Solder the Resistors to the Cathode Legs on Each LED

If you are looking to complete this project on a breadboard first, as shown in the top right photo, then you may skip this step. However, if you are planning to make it permanent, continue through with this step.

Before soldering, make sure you have the right setup. You should be working on a heatproof mat, with glasses, and proper ventilation. These safety steps are crucial in order to minimize the risk of injury or damage in case of an accident.

There are two ways to solder the resistors onto the legs of the LEDs. You may either solder the resistor directly onto the LED or use a wire to connect both the resistor and LED (shown above). Whichever way you choose to go, make sure you insulate your wires in order to avoid any short circuit. This can be seen in the bottom right photo. The cathode of the LED is the shorter leg.

Step 4: Connect the LEDs and the PTM Switch to the Raspberry Pi

Ideally, male to female wires should be used so that it is easy to connect the wires to the Raspberry Pi module. While the other (male) ends of the wires can be soldering to the LEDs and switch. However, if male to female wires isn't accessible, it is recommended that multi-core wire is used instead of the solid core due to flexibility and the reduced risk of dry joints.

Here are the required connections (use the GPIO pin scheme attached in the photos above):

  • Red LED Anode: GPIO Pin 13
  • Red LED Cathode: Any GND Pin
  • Green LED Anode: GPIO Pin 7
  • Green LED Cathode: Any GND Pin
  • Button Leg 1: GPIO Pin 12
  • Button Leg 2: Any GND Pin

Any of these ports can be changed by modifying the code later on.

Step 5: Power Supply

As discussed earlier, there are two ways that the Pi can be powered depending on its use. By power bank (or external battery) or by a direct plug into the wall. In our case, we used a micro-USB to USB so that it could be powered by either source.

Although, the cable needs to be extended so that the wire can reach a port given the height of the final product. To do this, the micro-USB to USB cable must be cut in half, stripped on both ends, and then an extension wire of any required length can connect the negative and positive terminals of both halves of the wire as shown above.

Step 6: Installing Raspbian on the Micro-SD Card

This step is crucial to setting up your pi if you haven't already done so.

You will need to download NOOBS:

And an SD card formatter:

For the complete instruction guide on how to install raspbian on your card, visit this website as it does a great job in detailing the install process.

Step 7: Hooking Up the Pi to the Monitor

Using the photo above as a guide, connect each of the relevant ports to the monitor and additional hardware such as a keyboard, mouse, etc. If everything is setup correctly, once the power is turned on the screen should show the Pi OS starting up as seen in the image above.

Step 8: Generating Your Twitter API

*Note - to do this, you must have a twitter account with a verified phone number

From the same web browser where you are logged into your twitter account, go to

1. Click on Create New App

2. Fill in Name, Description, and Website (if you do not have a website for your project, any valid website will do - just remember the "http://"

3. Agree to T&Cs

4. Click Create your Twitter application button

5. Click on Permissions Tab, select Read and Write, press Update settings

6. Click on the Keys and Access Tokens tab, then click on the Create my access token button

7. After you press the Create my access token button, you will see the Access Token and Access Token Secret fields. Keep all of these field values handy. You will need them for the Python code.

Consumer Key (API Key)

Consumer Secret (API Secret)

Access Token

Access Token Secret

Step 9: Programming Your Pi

Download the source code attached here. Read through the comments and add in the required information, including the keys generated in the last step. Remember to check that the pin numbers you fill in are the correct numbers that you connected the components to earlier.

Step 10: Setting Up Your Code to Run Automatically

In your Terminal (Pi OS), type in:

sudo nano /etc/profile

This will open a file which automatically runs on startup. All you need to do is make sure your code also runs by adding it to this file. To do this, type at the bottom of this the line:

sudo python /home/pi/

where /home/pi/ is replaced by the path (the folders and then the name of the file separated by slashes) of what you called your coding file.

Then, press Ctrl-X to exit, hit Y to save and press Enter as necessary to fully save/exit out of the file.

Step 11: The Housing (BOM)

For the housing, we used a black box future kit and made a stand out of extrusion in order to hold the camera above the food placement board.

What we used for the housing:

1. Wooden Board

2. Extrusion

3. 2x M12 Nut

4. 2x M12 Bolt

5. Black Future Kit Box

Step 12: Drilling LED, Camera, and Switch Holes Into the Box

In order to secure the button, camera, and LEDs in place, we must drill holes to place each component.

In our case, here are the diameters for each hole:

LED Holders: 8mm

Camera Hole: 6mm

Button Hole: 22mm (depends on the button you use)

When drilling, make sure you hold the drill perpendicular to the surface that you are drilling and don't apply too much pressure which may increase the risk of the case cracking. Make sure to use washers and nuts to secure each component in place.

Make sure that the component you are drilling a hole for will have enough space to fit before making the hole in that area of the box!

Step 13: Power Switch and Wire

This step is optional and requires an SPST rocker switch in order to control the power supply. This will enable to shut down the device without unplugging the USB cord and therefore, is a function for convenience. You will need the extended USB to micro-USB cable (as discussed earlier) as it will need to be cut to run it through the switch.

We first measured and drew out the size of the hole we would need to drill in order to support the switch. Then using an 8 mm drill bit, we drilled two holes side by side so that we could file out a rectangular slot in order to fit the shape of our rocker switch.

Once the rocker switch was pushed in place, the positive extension wire was cut. The two ends were then soldered to the common terminal and an adjacent terminal of the rocker switch as can be seen above.

Step 14: Adding the Camera to the Box

Adding the camera to the box is a very tricky part. We did it using a hot glue gun which allows us to remove the camera with relative ease if something were to go wrong.

First, position the camera in place and make sure that it takes it's a picture the right way around. Also, make sure that the photo it takes isn't tilted in any way. Once these variables are fixed, take the glue gun and glue the sides of the Pi camera to the box. Although make sure the gun doesn't touch the camera lens!

Step 15: Attaching the Box to Extrusion

In order to complete this step, first get an aluminum strip as seen above and bend it 90 degrees so that it wraps around your box. Next drill two sets of holes (12mm in diameter) both in the box and on the aluminum strip so that they line up. Use M12 bolts and nuts to secure the aluminum strip in place along the edge of the box. The excess strip coming off the box can then be used to secure the box to extrusion as will be shown in the following steps.

Make sure to use instruments such as vernier calipers and rulers in order get everything aligned up. Any offset can result in a tilt in the image produced.

Step 16: Attaching the Stand to the Base

First, cut out a long piece of extrusion (*see below). Then get two brackets/ribs as shown above and do a dry fit of the brackets and the extrusion on the wooden baseboard. Next, take a pencil and mark out where you will drill the necessary holes to secure the brackets to the board.

Drill those holes (around 8mm) and secure the brackets to the board using M8bolts and nuts. Next, get the required t-shape screws for extrusion and secure the extrusion column in between the two brackets as seen above.

*It is important to note that the height of the extrusion is dependent on what you want your camera to see in its field of view. For us, we had it sitting at around 60 cm above the board in order to capture the written message on the board. We decided on this height after testing the camera at different heights and examining the images on Twitter.

Step 17: Attaching the Camera Box to the Stand

In this step, first cut out another smaller piece of extrusion. The length of it should be based on how far out you would like your camera to reach as seen above.

Next, take the aluminum strip that comes off the box and drill two 6mm holes through it (main photo). Then, take the smaller piece of extrusion and attach underneath the aluminum strip using the t-shaped screws (bottom right photo). Ensure that the holes are aligned so that the image does not appear tilted.

Finally, in order to attach the two piece of extrusion at a 90-degree angle, we used a small bracket/rib and secured it to the two pieces using the required t-shape screws which lock into the extrusion.

Step 18: Conclusion

Finally, just run the power cable from the Pi to a USB port and screw up the back of the power box. That's it!

All that is left to do now is to put the device near a place where people eat and advertise the free food twitter account that you created.

A link to our twitter page can be found here.


This instructable was written and created by Rehaan Irani and Justin Chan from the Coding For Good service at UWCSEA East under the supervision of Mr. David Kann. This was also produced with the help of the college service Circle Enterprise and the UWCSEA East DT department. Additional thanks to Sewen Thy and Vatsal Agarwal for their contribution to the project.