The Pride of Building A Webcam From Scratch

Education Maker News
The Pride of Building A Webcam From Scratch

“IT WORKS!!!”  Everyone in the lab immediately turned towards the source of the outcry.  What we saw was a big smile and a look of victory. While students from other classes, who happened to be in the same lab space, seemed confused as to what could possibly be that exciting in a class lab, the students from my class knew exactly what had happened.  This student had streamed the first successful image from his handmade webcam to a web browser.

To fully understand this experience, we have to take a step back.  When I was an undergraduate in electrical engineering at Northwestern University, I noticed that there were not many hands-on classes that taught ‘maker’ skills that could be used in everyday life.  During my doctorate program, I became fascinated with hobby electronics, such as making a system to detect flooding in my parents’ basement and send them an email if it occurred. Then, during my postdoc, my work led me to become heavily involved in the low-level development of an embedded device.  When I subsequently became a professor at Northwestern University, I knew that I had to fill the educational gap I had noticed as an undergraduate. A few years ago, I was afforded the opportunity to design a new class to do exactly that, and I pursued it using the knowledge I gained about ‘making’ during my PhD and postdoc years.

A poster that hangs in the lab

The class that I designed centers on building a webcam from scratch.  The students start by researching components. Then, they learn how to perform surface mount soldering by hand, where they solder TQFP, QFN, SOT-23-5, and 0805 components for practice, in order to demonstrate proficiency.  After that, they learn about embedded programming using C. The microcontroller that they use is the SAM4S8B, so they program in Atmel Studio. Students start with a simple program that creates an edge-triggered interrupt that is activated with a pushbutton, and then they start writing the main code that will make the webcam work (which they keep writing throughout the term).  Then, students are given PCBs for breakouts of the main components (MCU, WiFi module, and camera module), and they solder them by hand. This allows them to create a breakout version of the webcam, using these breakouts and through-hole components along with breadboards and wires. Then, they learn PCB design in Eagle, and students design their final webcam based on their breakout version.  While the boards are getting manufactured, they design a website for the webcam stream, which is hosted on the WiFi module. After this, they learn CAD for 3D printing, and students make a custom 3D-printed enclosure for their camera. At this point, the manufactured PCBs have arrived and the class solders their boards and connects everything for final testing. This entire process occurs during a ten week span.

At the low level, the camera module captures an image and converts it to JPEG.  The MCU has a parallel interface for camera data, so it captures and buffers this image.  In order to send it to the WiFi module, the students have to know the length of the JPEG image, so they make a function to find it using the control bytes in the JPEG specifications.  Once they know the length of the image, they are able to transfer it to the WiFi module. The WiFi module is configured as a websocket server, so when a user navigates a web browser to the WiFi module’s IP address, they open a websocket connection and see the stream of images coming in.  Using this hardware, the students are able to achieve a stream rate of 11 frames per second at 320×240 resolution, with a total BOM cost of $30.

Hopefully, the excited outcry described in the beginning can now be better understood.  Students spend an immense amount of time in that lab, trying and failing, trying and failing, until finally a success comes along, and it is a major victory.  Students learn quickly that hardware systems are very difficult to design and debug, as a malfunctioning component could be due either to a hardware issue (e.g. a poor soldering connection) or a software issue (e.g. an uninitialized pin on the MCU).  This is why, after spending hours and hours trying to capture an image from the camera and send it over WiFi to the web browser, something actually appears on the screen, students often scream or jump out of their seats. It is an amazing feeling of accomplishment that every ‘maker’ knows.

After having taken this class, most students say that it was both the hardest and the most worthwhile class they have taken at Northwestern.  They say they now know how to approach any design challenge, and are not afraid of complicated systems, knowing they could design them themselves if necessary.  This makes them more confident during the job search, and people have told me it directly helped them with their work. The best part, though, is when students contact me and tell me about a personal system they have built using the skills they gained in class, as I know that these are the people who will showcase their work, either at fairs or simply to their kids, and help start the next generation of makers.

You can actually follow along with Ilya’s class in this playlist of lessons

YouTube player
Discuss this article with the rest of the community on our Discord server!
Ilya Mikhelson

Ilya is an Assistant Professor of Instruction in Electrical and Computer Engineering at Northwestern University. His research specializes in signal processing for biomedical applications, but lately he has focused more on embedded design. His goal is to use his knowledge to empower students to be able to make their dreams reality, by realizing that they can build anything they put their minds to.

View more articles by Ilya Mikhelson