Saturday, August 25, 2012

Blinking the BeagleBone's heartbeat LED from the iPhone

Following up on the work I was doing last night connecting the iPhone to the BeagleBone using PeerTalk. I've now reached the blinking LED stage, which is more-or-less the "Hello World" stage of any bit of hardware hack.

Blinking the BeagleBone's heartbeat LED using the iPhone

I've been having a great back-and-forth on Twitter with David House while hacking away with this project, who is working away as I type to get this working on the Raspberry Pi. It's been a lot of fun.

If you want to replicate this on the BeagleBone you should first download and build the PeerTalk library, and then build and deploy the iOS and OSX example applications and get that up and running.

Then connect up and boot your BeagleBone. You'll need to power the board using a mains adapter as when you're compiling things it's possible you'll be drawing enough amperage that you're computer will turn off the USB port to protect itself, and as a result power down your BeagleBone. I had this happen to me a couple of times before I finally dug a mains adapter out of my office drawer. However since you're powering the board from the mains you'll also have to connect an Ethernet cable so that you can ssh root@beaglebone.local and log into the board over the network.

1. Go ahead and login to your BeagleBone as root.

2. Download, build and install libusb. Version 1.0.9 builds, links and installs okay.

3. Download, build and install cmake, which you'll need to build usbmuxd later. You'll need to grab the latest Git nightly checkout as older release versions don't build, having problems with the stock libbz2 compression on the BeagleBone.

4. We also need libplist, however this is available as part of the package management system on Ångström Linux, so all you need to do to install this is type opkg install libplist-dev at the prompt.

5. Download, build and install usbmuxd. Version 1.0.8 builds, links and installs okay, although you may beed to use ccmake and configure by hand, rather than using cmake, as it can't seem to find the libusb include files that got installed into /usr/local.

6. Create a usbmux user

   groupadd -r usbmux -g 114
   useradd -r -g usbmux -d / -s /sbin/nologin -c "usbmux user" -u 114 usbmux

7. As the BeagleBoard doesn't have syslog turned on by default, and you'll need it for debugging, turn on syslogd from the relevant script in /etc/init.d.

8. Run up the usbmux deamon, by typing usbmuxd -v -v at the prompt.

9. Plug your iPhone into the (host side) USB on your BeagleBoard, you should see some debug scrolling by in /var/log/messages.

10. Download David House's peertalk-python and its dependances.

11. On your iPhone start the PeerTalk client for iOS.

12. Start the python client on the BeagleBone by typing python ./ at the prompt.

Type in a message at the prompt, and you should see something like this...

Bi-directional communication between the iPhone and the BeagleBone via USB
From there it's pretty trivial to replicate my "Hello World" example, just by hacking around with David's code and toggling the heartbeat LED when the BeagleBone receives any messages.

    def run(self):
        framestructure = struct.Struct("! I I I I")
        ledOn ='echo 1 > /sys/class/leds/beaglebone::usr0/brightness'
        ledOff ='echo 0 > /sys/class/leds/beaglebone::usr0/brightness'
        i = 0
        while self._running:
                msg = self._psock.recv(16)
                if len(msg) > 0:
                    frame = framestructure.unpack(msg)
                    size = frame[3]
                    msgdata = self._psock.recv(size)
                    print "Received: %s" % msgdata
                    if i == 0:
                       i = 1
                       i = 0

Which gets you to this point...

Toggling the BeagleBone heartbeat LED with my iPhone over USB.
Which is pretty much where I've reached right now. Next steps is a proper application on the iOS end of things with more generic control of the BeagleBone's header pins, and a more flexible Python backend on the BeagleBone itself...

Update: David House has managed to get everything up and working on the Raspberry Pi. The only changes from the above is that you should grab libplist using apt-get rather than opkg, and since you won't be logged in as root you should remember to sudo usbmuxd -v -v when you start the USB daemon. Apart from that, you should be good to go...

David House (@davidahouse)
25/08/2012 20:22
Video of iPhone controlling LED on Raspberry Pi.

Controlling a LED connected to a GPIO pin on the Raspberry Pi with an iPhone

Update: Come along to my workshop in London on the 8th of October and get your hands dirty playing with iPhone, Arduino and now the BeagleBone and Raspberry Pi. Get 10% off the Early Bird ticket price today only with code BEAGLE10.

Monday 8th October 2012
Hoxton Hotel, London
Early Bird Price: £499 (until 1st Sept.)
Normal Price: £699
Save 10% with code BEAGLE10

Update: David House has just updated his Github repository with a better description of what he did to get the iPhone to control the Raspberry Pi's GPIO pins.
David House (@davidahouse)
26/08/2012 13:40
@aallan I just updated my github repo with a better description with attributions. Had a blast working with you...

Controlling a LED connected to a GPIO pin on the Raspberry Pi with an iPhone


  1. There is a syslog running, the systemd journal. Just do 'journalctl -f' to see the entries scroll by.

    1. Looks like I have a very different version of Ångström running that you, because that certainly isn't the case for me...

    2. The one that comes in the box:

  2. This comment has been removed by a blog administrator.

  3. Apple may publicly disavow the rumor Web sites that scramble for scraps about the companies plans, but secretly their marketing department must be delighted. It would cost a lot to buy that kind of Web advertising."rastreador de iphone

  4. I have been searching to find a comfort or effective procedure to complete this process and I think this is the most suitable way to do it effectively. iPhone Repair Dubai

  5. This is a interesting line of content, very nice article. Thanks for sharing this post, good way of bring this subject to discussion. Keep up the great work ! lensesforsnap

  6. ncandescent bulbs are very affordable but they are a real burden to the environment.Dimmable LED Bulb They cost too much to use because they consume too much electricity.

  7. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. KRM Light+

  8. Thanks you for the blog. You really make it more informative. It make the day more informative. LED Sign Boards in Chennai Name Board Makers in Chennai

  9. It was really a nice experience to be on your blog and get the lots of information. Shop offer quality cell phone repair parts & screen repair services from cell phone repair las vegas

  10. Thankyou for sharing useful information . I would like to know more about Iphone repair prices.
    Iphone repair prices

  11. Admiring the time and effort you put into your blog and detailed information you offer. provide replacement of broken IPad screen and other apple devices at teh best prices. For the more details you have to do just one click ipad screen replacement

  12. This comment has been removed by the author.

  13. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. Cell Phone Repair Brick Nj

  14. Found this article is full of informative and helpful content, really love to read it. Get the phone repairs services at the best prices from

  15. hi nice concept good work

  16. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often. ipad mockup

  17. very nice article thanks for sharing ......iPhone Service Center

  18. Great job for publishing such a nice article. Your article isn’t only useful but it is additionally really informative. Thank you because you have been willing to share information with us. Iphone 7 Screen Replacement Near Me

  19. Very informative article, which you have shared here about iphone. After reading your article I got very much information and it is very useful for us. I am thankful to you for sharing this article here. iPhone screen replacement

  20. Nice information i would also tell you if you have apple macbook in india and want to repair in Delhi-NCR you please contact for best price MacBook repair service we offer good price even we make assure your not let you down in terms of repairing.
    call-us +91-9971909844

  21. Nice post, impressive. It’s quite different from other posts. we provide high quality led signs at affordable prices. to know more visit our website.

  22. By using this PCB prototype in the electronic device, the inventor can see if the prototype serves its purpose in the invention. 99% pure gold), immersion silver, flash gold, immersion tin (white tin), carbon ink, and SN 100CL, an alloy of tin, copper, and nickel.

  23. I am grateful to the owner of this site which really shares this wonderful work of this site.That is actually great and useful information.I'm satisfied with just sharing this useful information with us. Please keep it up to date like this.Thank you for sharing.

  24. This is very interesting, You are a very skilled blogger.

  25. I admit, I have not been on this web page in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues. iPhone black friday sale

  26. It looks very complicated process to me.
    Tecno Mobile Price in Pakistan

  27. A data sim card for travel is a small, removable card that allows you to connect to the internet while you are away from home. It is a great way to stay connected while you are traveling, and it can also be a great way to save money on your phone bill. Data Sim Card for Travel

  28. Read this article and found it useful content and totally informative. I enjoyed reading the content of this article post very much as it contains information about IPHONE repair in Melbourne. At we offer all IPHONE repairs at a reasonable price.

  29. Great post. If you're ever in Las Vegas make sure to stop by gadgetmates

  30. Breaking an iphone is a bad dream for me because I am a lover of that particular phone. it's features are awesome and I am also a photographer and serving wedding photographer and videographer with cheapest pricing.

  31. When it comes to iPad Repair in Dubai, Egghead Fixers emerges as the trusted and reliable choice. Their team of skilled technicians, commitment to quality, efficient service, transparent pricing, and customer-centric approach make them a standout option for anyone seeking to revive their malfunctioning iPad. Don't let a damaged iPad disrupt your routine – head to Egghead Fixers for swift and reliable repairs that you can trust.

  32. Thanks for your article, your information is very useful to me. If you need any related mobile service course in Madurai contact our Office eCareerpluz Info india pvt ltd
    mobile repairing advanced course mobile phone repair training center mobile repairing advanced course mobile phone repair training center

  33. Thanks for your article, your information is very useful to me. If you need any related mobile service course in Madurai contact our Office eCareerpluz Info india pvt ltd

  34. This comment has been removed by the author.

  35. Thanks for your article, your information is very useful to me. If you need any related Laptop service course in Madurai contact our Office eCareerpluz Info india pvt ltd
    motherboard repair training course, mobile and laptop repairing institute, mobile and laptop repairing course

  36. Your article is a treasure trove of useful information. Thanks a lot for sharing your knowledge. Looking forward to more content from you. LED Signs for Business