Saturday, February 8, 2014

BeagleBone Black TTL serial camera home security system with private motion activated tweets

In 2013, I bought my first BeagleBone Black with the intention to jump head first into new robotics projects.  I had been reading a lot of books and blogs on robotics over the past few years, with my career starting taking precedence to my passion projects, but it was time to get back into it.  My last robot was a maze navigating and flame detecting & extinguishing mobile robot.  Embedded devices have evolved quite a bit since that HC12 project with the recent popularity of Arduino, Raspberry Pi, BeagleBone and similar products.  It's a perfect storm of embedded electronics fun.

To get started, I bought the BeagleBone Black starter kit from Adafruit (awesome company) and a series of parts and tools from Amazon and The Robot Shop (Canadian!) - more on this in another post.

I also needed a good introductory project to follow the classic embedded equivalent to Hello World: make a LED blink.  Since I was about to head out on a vacation out of the country for two weeks, I decided to build a home security system.

Here's my part list:
  • Weatherproof TTL Serial JPEG Camera with NTSC Video and IR LEDs
  • Adafruit Beagle Bone Black Starter Pack 
  • USB Wifi dongle
  • 2 port USB hub
  • 32Gig micro SD card
  • That's it!
I've always believed in code over hardware in design decisions.  Even with my electrical engineering background, I find it less costly, more flexible and more robust to code solutions rather than to rely on hardware.

Here's a Python code snippet of my project.

 enable_tty01 = 'sudo sh -c \'echo > /sys/devices/bone_capemgr.9/slots\''   
 filepath = "/home/ubuntu/"  
 def initialize():   
   resp = ""  
   while(serial.inWaiting() > 0):  
       data =  
       resp += data  
       if "Init end\r\n" in resp:  
           print "Ready"  
   # Set image size to 640 x 480  
   resp = ""  
   while (serial.inWaiting() > 0):  
     data =  
     resp += data  
     if b'\x76\x00\x54\x00\x00' in resp:  
       print "Size set"  
 #Picture function  
 def takePic():  
   print "Take Picture"  
   # Take picture  
   #Get JPG size  
   resp = ""  
   print "Get image size from serial device"  
   bytes = cam.getbufferlength()  
   # Write image to file  
   print "Read image from serial device"  
   return cam.readbuffer(bytes)  
 # Initialize serial connection.  
 serial = serial.Serial("/dev/ttyO1", baudrate=38400)  
 cam = VCam(serial)  
 # Initialize the camera settings for the first picture.  
 tweet = Tweet()  
 while 1:  
   # Continuously check for motion detection.  
   if (cam.motionDetected()):  
     # If motion is detected, take a pic.      
     frame1 = takePic()  
     string_frame = ''.join(frame1)  
     now =  
     filename = "%d.%02d.%02d.%02d.%02d.%02d.jpg" % \  
       f = open(filepath + filename, 'w')  
       print "Error writing the file to the system."  
     #Post the image to Twitter in a new thread to resume motion detection.  
     t = Thread(target = tweet.postimage, args = (filepath, filename))  

I had a number of challenges in getting my program to work.  The main two include:

  1. The camera's baud rate is rather slow so I wasn't able to implement the motion detection on the computer and had to rely on the built in feature from the camera.  In the future, I will use a USB or IP camera instead.
  2. The wifi dongle was difficult to install but with enough googling, I was able to find working steps.  While I was working on this project, the BeagleBone Black was still relatively new compared to the Raspberry Pi so there were limited examples available online.  This is no longer the case.

And finally, the working prototype!

While I was away, I had pictures of the sun rise and sun set lighting change against the wall of my home office tweeted to me on a daily basis (they were detected as motion).  It was nice to see everything was good at home while being away.

Until next time!


  1. This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. alarm companies port-aransas texas

  2. I needed to thank you for this awesome read!! I certainly getting a charge out of each and every piece of it I have you bookmarked to look at new stuff you post. Visit Now

  3. Woh I am cheerful to discover this site through google.
    House Alarms

  4. However, these can be extremely expensive to purchase and install. In this article you are going to learn about a cheap camera security system that you can install in your home for less than security camera system installation NY

  5. Or he almost accidentally wins a Darwin award, can’t tell.

  6. This will rely upon the nature of the update and the increases you make to your kitchen. As indicated by the land operators, a completely useful and present day kitchen will support the estimation of your property drastically. hardwood Floor Refinishing overland park ks

  7. You create sense out of the foremost complex topics.24 Hour Locksmith Pros

  8. You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. Home Security

  9. You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. full color night vision security camera

  10. The Cori HD Smart Home Security Camera joins the Momentum camera lineup including the Axel HD Smart Camera, Aria LED Floodlight Camera and the Niro Garage Door Controller. Along with all Momentum Wi-Fi cameras, the Cori cameras can be controlled and viewed from the same mobile app, as well as other home-based consumer electronics from NEST.
    Complete Security Alarms System

  11. Great! We will be connecting to this enormous post on our site. Continue the good writing.Marietta locksmith

  12. Surveillance camera frameworks give a lot of assistance in keeping various unlawful acts and have contributed towards reclassifying home security, however security at organizations and working environments. Surveillance cameras that accompany a wide scope of highlights and choices are a
    building intercom system upgrade

  13. There are also scene modes included with compact cameras that allow you to choose a setting to match the scene you are shooting.

  14. Your articles make whole sense of every topic.
    IP camera systems

  15. The superb highly informative blog I’m about to share this with all my contacts.
    self storage security

  16. Picking a play kitchen set relies upon the age of the youngster, your financial plan and your setting. It likewise relies upon your own rationality. Where is that play kitchen made? pressure cooker directions