Tag Archives: raspberrypi

Building a Raspberry Pi Controlled Desk Lamp with LeanDog and CWRU

As mentioned in a previous post, Nick Barendt and the LeanDog Studio have teamed up to offer a Connected Devices Workshop for Case Western Reserve University (CWRU) students in response to a trend of increasing interconnectivity in product design known as the Internet of Things (IoT). In this course, students are gaining practical experience building a proof of concept system: a physical device, web integration, and mobile development.

The goal of the course is to familiarize students with each component in a complicated system, providing them with a systems level understanding of all the technologies and disciplines that go into creating a connected device

Follow along with us as our students create their very own web-controlled desk lamps, which we’ve dubbed “LAMPI” [lamp-ee]. By the final week of the course, students will possess enough experience to build their own prototype for a new product or service, or confidently dive deeper into any of the software components for further study.

The class is comprised of mostly Juniors and Seniors in Electrical Engineering, Computer Engineering, and Computer Science.  That means that there is a broad range of electronics and software development experience in the class, at skill levels ranging from beginner to advanced.  To address the variety in skill sets and levels, students are working in pairs on the lab assignments, switching up pairs each week. This method of “pairing” is widely used in the world of professional software design and a is a key practice in the LeanDog Studio. We will dive a bit deeper into the benefits of pairing in a later post.

Now, without further ado…

Screen Shot 2015-10-15 at 3.08.16 PM

Building a Raspberry Pi Controlled Desk Lamp

CWRU’s IOT course kicked off by getting students familiarized with:

  • Burning an SD card image with Raspbian (a variant of Debian Linux)
  • Booting up a Rasberry Pi (a tiny and affordable computer, with a rich community of hardware and software support)
  • Connecting to a serial console (UART)
  • The basics of Pulse-Width Modulation (PWM)

On the first day of the course, students cracked open their shiny new Raspberry Pi’s, added WiFi adaptors, SD cards, a custom interface circuit board, and serial cables; attached them to the lamp base, added power cords and an LED ribbon cable, and connected the devices to their computer with a serial (UART) USB cable.  While UARTs are “old school” (RS-232 anyone :-), they are still common on embedded devices, and are often your last ditch, never fail, connection option.

Screen Shot 2015-10-15 at 3.10.43 PM

Students connected their LAMPIs to the CWRU Campus Network, and learned how to remotely connect to a Linux shell on the Raspberry Pi with SSH, a basic tool for modern, distributed software development.  

The class was then tasked with installing the pigpio library, for interacting with the General Purpose Input/Output (GPIO) digital pins on the Raspberry Pi.  Three of the GPIO lines are connected to a custom interface board that has three high-power drivers to control a 3W Red Green Blue (RGB) LED.

Screen Shot 2015-10-15 at 3.13.21 PM

Turning a GPIO line on enables the driver circuit for that LED color channel, lighting up that LED color.  By using Pulse-Width Modulation (PWM) support within the pigpio library, the intensity of the LED can be varied from completely off to full brightness by changing the duty cycle of the PWM command.  By varying the intensity of three LEDs, the RGB color (or, equivalently, the Hue and Saturation) can be varied.

By the end of the first week, students were able to write a simple Python program to generate light by cycling through the primary colors (Red, Green, and Blue) and White.

FINAL THOUGHTSScreen Shot 2015-10-15 at 3.21.33 PM

Why a Raspberry Pi?  Honestly, it is overkill for a desk lamp.  We’re actually using a Raspberry Pi 2B, which is 900MHz Quad-core ARM Cortex-A7 processor with 1GB of RAM.  That’s a crazy amount of computing power for a desk lamp.  But, it does allow us a few simplifications for the course.  Typically, embedded devices, like a “smart” desk lamp, are develo   ped using the C programming language.  Teaching the students C would take a few weeks, plus the additional complexity of working in a cross-compiled environment (i.e., writing the software on their Intel based computer to run on an embedded ARM processor).  We decided to trade that time off to expose the students to other important topics in the Connected Device space and use a high-level language, Python.

Why Python?  Python is fast to learn, runs in lots of different environments (embedded, cloud, etc.), and has a huge community of open source development projects.  While interpreted, Python is relatively efficient, and has solid support for integrating with low-level libraries (i.e., those written in C) for hardware interaction.  An additional bonus is that later in the course, when we move to the “cloud” and web development, some of the Python experience can be transferrable.

Why a desk lamp?  It is unclear if the world really needs a web and smartphone controlled desk lamp.  What we need for the course is a device to motivate the exploration of the IoT / Connected Device ecosystem (embedded, UI/UX, Cloud, Bluetooth Low Energy, mobile, etc.), and even a simple desk lamp provides enough complexity to make that exploration interesting.  Light is also a primal and fundamental aspect of our lives. After all, it was our mastery of light and tools that arguably began man’s journey towards technological advancement. Therefore it is fitting that as we begin to explore this new evolution of product design that we bring our modern light and tools together again to help “light the way,” even if our guiding example takes the form of a humble desk lamp.

Stay tuned for more as the course progresses and we drill down into the many interesting and challenging concepts that make up the Internet of Things.

Coming soon: The creative design process behind the LAMPI’s unique shape.