- PRODUCT SHOWCASE
- VERTICAL SOLUTIONS
- DEVELOPER ZONE
The Raspberry Pi has long been the “go-to” board for makers and experimenters alike, so it’s no wonder we here at Zatar chose it to demo how a Linux-based computer can be easily connected to Zatar. We’ve come up with a simple demo program that you can download to your Pi and run that will do it all for you. Here’s what we did.
The goals of this experiment as follows:
We started with ARM’s mbed Client (which is available directly from ARM via github) and a blog post from ARM instructing us how to connect a RPi using mbed Client to ARM’s mbed Connector Cloud. That got us connected to ARM’s test servers with the Raspberry Pi running the code, but we wanted to be connected to Zatar. Also, we needed to expose bi-directional properties, and show something that gave us feedback that the board was operating properly.
For the Zatar connection, we had to modify ARM’s code to do the following:
Since Zebra is a licensed ARM IoT Cloud Partner, we already incorporate the ARM mbed Device Server (mbedDS) in our cloud system. So we knew the mbed Client code would work as soon as we modified it to employ any Zatar-specific features. So we got this step done pretty quickly.
After getting the board connected, we had to add something to give us I/O’s as well as visual feedback. Since the Pi doesn’t really have much in the line of lights/switches built onto the board, we knew we had to pick an add-on board for the Pi. We wanted something simple, that anyone could use with minimal effort and cost. We chose the PiBrella* from Pimoroni (you can get one at Amazon here). It is a simple add-on board for the Pi which will work on any version of the Pi (even the Pi Zero if you have a header) by attaching it to the GPIO header. It has three large colored (Red, Yellow, Green) LEDs, a large button, a buzzer, and eight protected I/O’s, each with small white LEDs. Great for what we needed to show.
Our final demo program exposes the Raspberry Pi with some simple properties like IP Address, serial number, firmware version, the three colored PiBrella LEDs and button, and a button count, all into an Avatar on Zatar. You can toggle each LED from Zatar’s Device Portal, the Zatar iPhone app (version 2.2 or higher), or directly via the API using our interactive API tool. When you push the button on the PiBrella, the button status (UP/DOWN) will show in the Avatar and a counter will increment. Also, you can reset the button counter from the Pi’s Avatar. This showcases bi-directional communication with Zatar in near-real-time using mbed Client and our mbedDS interface.
For immediate local feedback, we are using 4 of the small white LEDs to show that the program is “alive”. As long as the program is running, these LEDs run through a little pattern to show you things are working properly. When you push the button, the LEDs all turn on and freeze until the button is released.
So, are you interested in getting your Pi onto Zatar? Cool. We have two programs that you can download and run to make that happen. They are:
You can download these programs directly, or simply clone the public github repo. Using these two programs will allow you to get your Pi onto Zatar literally in a few seconds. Then all you need to do is log onto Zatar, and add your Pi into your account using the serial number of the device. The mbed-client-rpi-zatar program will display the serial number for you on the Pi’s console when you run it. It will also display some feedback about its operation, along with a “success” message when it connects properly to Zatar.
That’s it! All you need to connect your Raspberry Pi to Zatar is one program. The IoT can’t get much easier than this!
If you are interested in cracking open the code and interfacing custom functionality from your Pi or any Linux device, we will be releasing the source code for this demo in the near future, along with instructions on how you can create a custom Avatar Definition to expose whatever properties and methods you want. Then you’ll be able to create Zatar-connected devices that do literally anything! So stay tuned, and thanks for your interest in the IoT and Zatar!
*Note: you can run the programs without the PiBrella board, but of course you will have no local feedback and not be able to do much. It’s really a much better demo with the PiBrella board attached.