ESPn – Extrasensory Perception via a Network

ESPN_med

Have you ever sent a text message to someone, and thought “wow that was easy.. I wish there was some more complicated way to get less functionality.” If so- this project is for you… I call it… ESPn! (extrasensory perception via a network). I wanted to make a nerdy gift for my girlfriend for our anniversary. I’d previously joked about making her a doorbell and I decided to run with the idea. I made two identical devices, which communicate with each other no matter where they are located. I’d been thinking about the project for a while but I didn’t really think about it seriously until March on a long and boring bus ride. I started out thinking about using the wixel, but quickly switched to the Electric Imp since it seemed flexible with setup and not requiring a PC in different environments.

ESPn is a simple and complex system at the same time. Simple because it doesn’t do much (I might add some more functionality in the future), but complex because I built it from scratch. In essence:

  • Red button LED- currently online (press to ring the other person)
  • Green button LED- other person currently online (press currently unused)
  • Green standalone LED- other person pressed button in the last 12h (they sent a message, and you are now happy)
  • Yellow standalone LED- you haven’t pressed the button in the last 12h (shame led! press the button and the LED turns off!)
  • Speaker to give an audible chirp when the other person presses the button
  • Switches for possible future usage

The screen displays a startup message, and then information about the connection. The top right corner is a quick status indicator (redundant with the LEDs but I still like it)- :( = offline, :) = online, XD = both online. The screen displays a block of text that varies with system state. It will indicate when the other person last pressed the button, when the other person was last online (if they are currently offline), and will give a general message which could vary semi-randomly.  There is also space to receive a message directly from the other person- this requires usage of a custom website. Finally, the progress bar at the bottom is always decreasing. The devices are always constantly pinging each other every 20 seconds- whenever the device receives a ping, the progress bar fills up.

So far it seems to work great. The internet connection works solidly, and it quickly connects when you plug it in. Here is an assembly video:

Onto the engineering….

Main Functionality

This was a fun project. I decided to use the Electric Imp (with dev board) to provide wifi connectivity. I also have an OLED display and an Arduino Pro Mini 3V3. Theoretically I could have used the Imp without any arduino, but I wanted extra offline functionality and the additional I/O that you can only get on the Arduino.

Functionally, the Arduino communicates via its UART interface. The Imp transparently shuttles information back and forth from the cloud. I just have the devices sending messages back and forth to each other. Different serial characters mean different commands. Using UART made it easier to prototype the system, and to make a custom commandset.

Hardware Design

espn_schematic

I created a custom PCB and had it manufactured over at OSH Park. I’ve used them before, and while for these dimensions they were slightly more expensive than Batch PCB, I like the resulting boards and that i get 3 instead of 2 copies. I made it 4″x2″ by tossing the Electric Imp and all necessary resistors on the bottom layer of the board. I also was able to make it fit by totally making up incorrect dimensions for the OLED display. (oops! at least the pins are right)

espn_pwb

 

I used a plethora of simple components in addition to the main Arduino & Imp. You can see them all called out in my BOM over at github. In the end, each board cost about $110 for parts and the pwb (not including shipping, which tacked on quite a bit since I made a number of incremental orders as I tested functionality). This is not a system that will soon find its way into your neighborhood radioshack. I’d highly getting some general components from China/ebay- 2300 0805 resistors and capacitors for $10, 100 RGY 3mm & 5mm LEDs for $4.30, and finally 10 40×1 female and male headers for about $2 each. The 0805 components are tough to solder by hand, but I was able to manage… and I’m horrible at soldering.

As you might have noticed, I implement two breakout boards on my design- one for the OLED display, and one for the Imp. If I really wanted to reduce cost, I would put everything together on my own PCB. Since I was literally only making a couple though, I focused on what I could get working in a month.

Out of my bank of 8 switches, 2 goto the Imp (only one works for some reason) and 4 goto the Arduino. Both input buttons are connected to the Arduino. The two top LEDs (Yellow/Green) and the Green Button LED are connected to the Arduino, while the Red Button LED is an output of the Imp & an input of the Arduino.

Imp Code

espn_back

I based the Imp code off of an example sparkfun project. I kept most of their code exactly but added a few features. First off- I changed it to work via interrupts instead of polling. This seems to work much better (with the stock code I kept getting distorted / unreliable communication). I think this polling callback ability was added to the Imp after the Sparkfun code was created. I also added some watchdog functionality since the Imps kept getting bored and falling asleep. Finally, I added an internet based backdoor so I can send custom messages to either display from a web browser or cellphone.

Arduino Code

The Arduino code is relatively straightforward, and just has a main loop that I tried to keep as small as possible. I use that time to check the UART buffer, and to check I/O to see if someone pressed a button. I also keep track of a few timestamps and perform tasks every so often. For example, I’ll send a ping or update the display based on a preset frequency. I was prepared to elaborate on this code with my button and UART handling (interrupts, debouncing etc) but honestly it all worked well when I made it so I didn’t bother messing with it.

I ran into a lot of limitations of string storage in the Arduino due to its limited memory, and due to the OLED library taking up half of my memory. I considered switching to a text only implementation but decided it wasn’t worth it to figure out how to split it up and still keep my rectangle drawing. I ended up just greatly reducing the string usage in my design.

Timeline

While this isn’t too important, if you are curious here is my timeline. I started seriously thinking about the concept 3/22. Ordered my first Imp on 3/24 ,and had it working somewhat by 3/31. I switched my system over to using a Pro Mini on 4/4, and got a second Imp the same day. Happy with my basic functionality, I started working on final component selection and schematic design on 4/8 and finished it on 4/11 (I rushed this design because I worried about the lead time for the PWB, and any issues I might have with the final design). Took a much-needed small break until the boards arrived 4/22 at which point I was able to assemble one board and test it out. Assembled the second device on 4/29 and then switched over to software (Arduino) development, which ran through 5/7. I was able to finally pack it up in a box, and deliver it a week early! Woo-hoo!

Resources

espn_prototype

I’ve uploaded all of my code and schematics to github. This includes Imp code, Arduino code, my prototype system code (if anyone cares, I can post more information about the design process but this post is already pretty lengthy), and some notes about bugs and possible improvements in the future.

See some photos of my design process on flickr. I even took a time lapse video of assembly of one of the PCBs and I’ll try to edit it together soon.

Drop me a line if you  you have any feedback / suggestions / questions / comments! Thanks for reading!

 

Also read...

Comments are closed.