Aug 07

Friday Post: Raspberry Pi iBeacon

Hey All,

Now that Hack Day at the office is out of the way, I would like to post about what I learned and some examples to get you started.  The following is some example code and an introduction to iBeacons.

Setting up a Raspberry Pi to be an iBeacon

Longer guide available here: Adafruit PiBeacon

On a fresh install of Raspbian, login to the terminal and type:

sudo apt-get update
sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev

Next we want to download, build, and install BlueZ, a bluetooth stack for Linux and the Raspberry Pi.

sudo mkdir bluez
cd bluez
sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.11.tar.xz
tar xf bluez-5.11.tar.xz
cd bluez-5.11
./configure --disable-systemd
make
sudo make install

Now that BlueZ is installed, plug in your Bluetooth Adapter and reboot your Pi with:

sudo reboot

When it is finished rebooting, log back in and go into the bluez folder by typing:

cd bluez/bluez-5.11

Check that your bluetooth device is listed by running:

tools/hciconfig

You should see a few lines appear about hci0 and that it is currently down.

Issue these commands to bring up your bluetooth device:

 sudo tools/hciconfig hci0 up
sudo tools/hciconfig hci0 leadv 3
sudo tools/hciconfig hci0 noscan

Now we are going to turn the device into an iBeacon.

 sudo tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 01 00 00 01 C8 00

The long set of character E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 is actually the iBeacon’s ID.

The next four numbers: 01 00 are the major id and show up as 100.

The next four numbers 00 01 are the minor number and show up as just 1.

You don’t have to worry about the numbers before E2 and after the minor value 00 01.

You can set the major and minor to anything from 0 to 9999. This is how you will be able to tell apart different beacons in your app. The app is currently set to recognize Major 100 Minor 1 and Major 100 Minor 2.

If you change these numbers on your device, make sure to update the app.js code as explained below.

If you reboot your Pi, you will find that the bluetooth device has been reset and that it is no longer functioning as an iBeacon.

To fix this we are going to edit /etc/rc.local.

sudo nano /etc/rc.local

You will want to place the following code above the exit 0 at the end of the file.

sudo /home/pi/bluez/bluez-5.11/tools/hciconfig hci0 up
sudo /home/pi/bluez/bluez-5.11/tools/hciconfig hci0 leadv 3
sudo /home/pi/bluez/bluez-5.11/tools/hciconfig hci0 noscan
sudo /home/pi/bluez/bluez-5.11/tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 01 00 00 01 C8 00

Press ctrl-x then y to save and quit.

Now reboot your Raspberry Pi and it should become an iBeacon on startup.

Application Side

We are now going to create the iBeacon app. The instructions below are to do this on a Mac with XCode, PhoneGap, and an iOS device with a developer subscription.  You can also do this on Android with Linux, OS X, or Windows, the Android SDK, and PhoneGap.

First, you want to install cordova. On a Mac or Linux machine use:

npm install -g cordova

(If you don’t have NPM on a Mac install the amazing tool Homebrew and then install node.js)

Then create your app directory:

cordova create beacon com.yourname.beacon beacon
cd beacon
cordova platforms add ios

(for android do cordova platforms add android, but make sure the android sdk is installed)

Add some basic plugins:

cordova plugin add org.apache.cordova.device
cordova plugin add org.apache.cordova.console

and the ibeacon plugin:

cordova plugin add https://github.com/petermetz/cordova-plugin-ibeacon.git

Now lets rename the www folder in the folder. We don’t need it, it’s the default phonegap application, but it could be a useful example later.

mv www www.example

Now let’s clone the ibeacon example!

git clone https://www.github.com/ssilverm/ibeacon-www www

Edit lines 7 – 23 of app.js to match the ID, Major, and Minor of your beacons. They will trigger the page changes on your device.

app.beaconRegions =
  [
	{
		id: 'Page1',
		uuid:'E20A39F4-73F5-4BC4-A12F-17D1AD07A961',
		major: 100,
		minor: 1
	},
	{
		id: 'Page2',
		uuid:'E20A39F4-73F5-4BC4-A12F-17D1AD07A961',
		major: 100,
		minor: 2
	},


  ]

You can see how the above code is set to the same as the iBeacon we set up above, as well as another beacon with the minor value set to 2.

The next steps are how to build your iBeacon app for an ios device like an iPhone or iPad. I don’t have an Android device, but as long as you have the Android sdk the functions should be the same. Change ios for android.

When you have finished editing app.js, save it and then type:

cordova build ios

After a few minutes your terminal should read Build Succeeded.

Open the platforms/ios folder and double click on the beacon.xcodeproj file to launch XCode. With your device connected you should be able to run your app on the device.

Make sure location services are enabled for the app.

Now go walk around to where you set up the beacons and the pages should automatically change as you get closer to them. It will also revert to the main page as you move out of range.

Screen Shot 2015-08-07 at 11.06.17 PM

I hope this has been helpful!

Have a great weekend all!

-Shea

GitHub Code: https://github.com/ssilverm/ibeacon-www

 

Jul 25

Friday Post: Even more 3D printing…

Hey All,

This has felt like one of the longest weeks of my life.  Had a couple meetings about Maker Faire Orlando, pushed out some software that 60,000 students will be using in a month. It’s super stressful.  Luckily it’s Friday and I can end up sleeping until Sunday 😀

I was hoping to have some cool stuff to show this week about the 3D printing software, but of course at the last minute stuff wasn’t working.

My 3D printer is a Micro3D 3D printer.  It’s a small $300 3D printer that is only now just getting people to hack on it.  With 3D Printing, you usually have two steps from model to plastic.

The first step is to run your model (an .STL file) through a slicer.  There are many slicers out there, Cura, Simple3D, Slic3r, etc.  These literally slice your model into layers which are written out as Gcode.

Gcode is an industry standard for 3D Printing and CNC milling that can control extruders, X Y and Z axis motors, temperature controls, etc.  Everything your print will do is going to be from a line of gcode commands.

The printing portion is actually a program that reads the gcode and sends it to the printer to act out.

OctoPi

There is a really cool open source suite of tools called OctoPrint, that combines a gcode processor and a beautiful web frontend to manage your 3D Printer.  A Raspberry Pi distribution was made call OctoPi which allows you to control most 3D printers from your Pi!

octoprintscreen

Because the Micro3D is so new, support is just starting to come out for it and the gcode processors are a little iffy at the moment.  I was able to get OctoPi to talk to my printer and manually move the axis, but it could not process the gcode properly.  Bummer 🙁

I am sure this will be fixed in the coming weeks though.  I am really happy with this printer.

Be on the lookout for a new PiPlay image.  It’s been too long!

-Shea

IMG_5401This hasn’t been cleaned up yet 😀

IMG_5403 IMG_5405 IMG_5406 IMG_5407 IMG_5408 IMG_5409 IMG_5410 IMG_5411 IMG_5412

Jul 17

Friday Post: More 3D Printing

Hey All,

Happy Friday!  Brain fried from a week of getting some new software at work prepped and ready to be moved to production.  Scary doing a push because some 60,000 faculty and students might run into an issue.  We test as well as we can, but theres always that one case that you miss.  So nerve wracking.

For the past two weeks my coworkers and I have been printing out tons of things on the Micro 3D Printer. After the first week, everything started to shift horribly to the left on each new layer.  Nothing would print right.  A vocal minority was also having this issue on the forums.  Micro3D has a huge support backlog, so communication was very sparse, BUT they DID keep us in the loop on how they were fixing the issue.  Two new software releases in 2 weeks and it seems to be working fine again.  I am extremely happy with the prints now.

Eevee (with support structure)

IMG_8146 copy IMG_5376 copy

Winnie the Pooh bear (with support structure cleaned off)IMG_5372 copy

Don’t mind the weirdness with the Eevee, that’s the support structure that pulls off.  I’m mailing it to a friend so I’m leaving it intact.  It’s like 3D printed bubble wrap, I can’t deny her the joy of ripping it off 😀  You can see a couple remnants of the support structure on the pooh bear as well.  I need to clean it up a bit more before I send it to my Mom.  She will love it.

My conclusion: It’s a $300 3D printer,You get what you pay for.  I am extremely happy with it.  It was broken, now it’s fixed to Micro3D’s credit.   I am hoping the shifting issue is now in the past and that it was just a software bug.

Have a good weekend all!

-Shea

Jul 10

Friday Post: Make Magazine!

Hey All,

Happy Friday!

This week just flew by, but projects are going really well, and I am hoping to have a cool announcement in the next week or so.  In the meantime…

PiPlay was featured in Make Magazine!!!!!!!

I’m seriously fanboying over here.  To have my project featured in Make is like having a researcher’s paper featured in Science or Nature magazine.  I’m just blown away.

The article is about making a home arcade system and controlling the games with an Arduino Esplora.

M45_Cover_LowRez_Sq_1024x1024

 

Have a good weekend all!

-Shea

 

Jul 03

Friday Post: 3D Printing and Raspberry Pi live streaming

Hey All,

Happy Friday and happy 4th of July weekend!

On Monday I recieved a 3D Printer from the company M3D.  It is the blue Micro 3D printer.  If you use the coupon code “refurb” you can get one for $300 dollars (plus about $12 shipping).

microBlueSo far I’ve printed out a bunch of things, ranging from Bulbasaurs, and Ford Fiesta ST scale models, to characters from Dota and keychains.  So far it has been an awesome little printer.  Now, it’s slow, a little loud, and only has a print size of 6x6x6, but that hasn’t been an issue yet.

I’m using a Raspberry Pi with the camera module to livestream my printer.


Broadcast live streaming video on Ustream

bulba

2015-07-01 (1)

IMG_5327 IMG_5336 IMG_5326 IMG_5325

Livestreaming from USTREAM on the Raspberry Pi

Here is a quick guide to livestreaming on the Raspberry Pi with USTREAM and an RPI Camera Module

References from: https://ustream.zendesk.com/entries/63723444-Raspberry-Pi-Streaming-video-to-Ustream and http://www.oz9aec.net/index.php/dvb/490-turn-your-raspberry-pi-into-a-live-hdtv-transmitter

  • Install Raspbian to your Raspberry Pi SD Card
  • Install the Raspberry Pi Camera Module
  • Using Raspi-Config activate the camera module
    • sudo raspi-config
    • Enable Camera
  • You are going to need a version of ffmpeg installed.  The version from apt-get will not work.
    • You can download a working binary here: http://files.oz9aec.net/datv/490-rpi-hdtv/ffmpeg
      • wget http://files.oz9aec.net/datv/490-rpi-hdtv/ffmpeg
      • chmod +x ffmpeg
    • Or you can download and compile the ffmpeg sources via git
      • git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
      • cd ffmpeg
      • ./configure
      • make
      • sudo make install
  • Set up a ustream script:
    • nano ustream
    •  #!/bin/bash
      RTMP_URL=<rtmpurl>
      STREAM_KEY=<streamkey>
      while :
      do
          raspivid -n -vf -hf -t 0 -w 960 -h 540 -fps 25 -b 500000 -o - | ./ffmpeg -i - -vcodec copy -an -metadata title="Streaming from raspberry pi camera" -f flv $RTMP_URL/$STREAM_KEY
          sleep 2
      done
    • Change RTMP_URL and STREAM_KEY to match the keys you get from your USTREAM Channel settings page.
    • If you compiled and installed your own version of ffmpeg, remove the ./ffmpeg and replace it with just ffmpeg in the code above.
    • chmod +x ustream
    • ./ustream
  • With any luck, you will now be streaming to your USTREAM channel.

 

 

 

 

 

Apr 17

Friday Post: PyCon 2015!

Hey All,

PyCon 2015 is over.  It was an amazing time in Montreal.  My coworker and I presented ProctorHub, the homegrown proctoring solution that we created for our university.

We met a lot of fellow educators, tons of fellow pythonistas, and learned a ton!

A PiPlay kit was also auctioned off during the PyLadies auction, where it brought in $200!

All of the talks are up on YouTube:

https://www.youtube.com/channel/UCgxzjK6GuOHVKR_08TT4hJQ

I’ve also picked up two of these nrf24l01+ Transceivers.

11038420_10104069360076632_3430831120835634129_o

I have a neat project I’m working on involving a Raspberry Pi and an Arduino.  Hopefully I’ll have the prototype to show next week 😀

Have a good weekend!

Mar 22

Very Late Friday Post: 2 Years!

Hey All,

Sorry for the very late post this week.  Trying to figure out why I’m having such connectivity issues to my web host.  Replaced the router.  Still happens.  Modem is fine.  It’s not my host.  But my ISP can’t see it as being down since it comes up 5 minutes later.  I can VPN into work and access my host from there.  So weird.

Anyways,

Tomorrow marks my 2nd Wedding Anniversary.  It feels like it’s been a day and a half 🙂 K, I love you.  Thank you for putting up with me.

PiPlay

0.8 Beta 9 is coming along.  It should be released in a day or so.  This is the best version yet, and I’m so sorry for the Beta 8 release.  Trying to get everything working on both the Pi and Pi2 has been a challenge.  But I think this version will be great.  We have upgraded to the latest Raspbian image, moved more emulators into GitHub / Git and now can update most of PiPlay with a Git Update.  Mark has created an awesome file watching script which automatically updates the frontend when a new file has been uploaded.  No more running the scraper, it all happens in the background.

Mario Party 10

Mario Party 10 came out this week.  I had a chance to play it with a group, and, well, it feels like Mario Party Lite.  The game is gorgeous, the levels are beautiful, but there are only three game modes.  Amiibo Party, Bowser Party, and “Mario Party” which isn’t like previous games.  Everyone works together to get to the end in a vehicle, basically pooling dice rolls.  The classic game has been shortened and moved to Amiibo Party.  It feels like a lot of content is missing.  The load times are also really long.  I really wanted to love this game, but I feel like its a demo.  I’m hoping patches and some free DLC fix that.

SmartiPi

I backed the SmartiPi kickstarter a short while ago, and received my case the other day.  I think this is one of the best designed cases out there.  It easily wraps around the whole Pi, and has LEGO compatible pegs on the case.

IMG_4913

 

Have a great week(end)!

-Shea

Mar 14

Late Friday Post: Pi Day!

Hey All!

Happy Pi Day!!!  Sorry about the late posting.  My internet has been acting up for the past two days.  Yay.

The past few days have been the Orlando FIRST Regional Robotics Competition hosted at UCF.  I am a FIRST Alumni from 2002, a member of Team 108 SigmaC@Ts.  It was so awesome to see the competition again after all these years.

PiPlay is coming along.  Fixed the bugs with the joysticks.  Working on improving more things.

Thanks!

-Shea

 

.

Jan 02

Friday Post: 2015!!!!

Hey All,

Happy New Year!!! 2014 was an amazing year for me:

  • Got contracted to write a second book (almost done)
  • Ran a successful Kickstarter
  • Had YTD 64,000 downloads of PiPlay
  • Spoke at PyCon, Computers in Libraries, and EDUCAUSE conferences
  • Participated in Orlando Maker Faire
  • Was able to hire the very talented Elizabeth Williams to be part of my team at work
  • Developed software that is helping 60,000 students
  • Added a very cute and very annoying kitten to our family
  • Learned a few new technologies that I had been putting off
  • Watched my wife get a great new job
  • Watching my friends start families
  • Made some new friends

Not to say everything has been great, but the good has totally outweighed the bad.  I have to thank all of my readers as well.  I couldn’t have done without you all.  Thank you!

Amiibos

So I’ve been hit by the Amiibo bug.  I started cutting out these stands for my collection.

IMG_4653 IMG_4654 IMG_4655 IMG_4656 IMG_4657 IMG_4658 IMG_4659 IMG_4660 IMG_4661 IMG_4662 IMG_4652I may have gone a little overboard.

PiPlay

The next version of PiPlay is really coming along.

snapshot

You can see our game listing screen now shows a lot more info.  We are also moving a lot of our configs into SQLite DB files for faster retrieval.  This is going to be an awesome release!

Happy 2015 everyone!

 

Dec 03

Encade Portable Raspberry Pi Gaming Console Kickstarter

Hey All,

Just wanted to post a cool Kickstarter that I’m backing.  The people at Nzen Mods are designing a really cool Raspberry Pi based project.

https://www.kickstarter.com/projects/2032055368/the-encade-a-portable-raspberry-pi-gaming-console

It’s a portable Raspberry Pi based gaming console.  They are so close to hitting their goal, and only have 22 hours left.

Enjoy!

-Shea