An Android-based device OS for the Internet of Things. Android Things let developers build professional, mass-market products on a trusted platform, without previous knowledge of embedded system design. And with Low Barrier to Entry, Developers can take advantage of Google's platform and support to scale from prototypes to complete products quickly.
Read more at:
And since Android things is Android-based. This means we can use Xamarin to create our app. As a C# Developer, this is great, I can use my .NET Skills and apply them to Android and IoT. This opens up ability to reuse some of .NET shared libraries that I can expose to Android and IoT.
Step 1: Setup Raspberry Pi with Android Things(Excerpt from Salman Faris tutorial)
Go to the Google Android Things website by clicking here. Go to the CONSOLE section.
Sign in with your Google ID in the following page.
Select CREATE A PRODUCT.
Type the Product Name. Select SOM as Raspberry Pi 3 (SOM = System On Module). Give a Product Description. Hit CREATE. In the following page, select appropirate FACTORY IMAGES.
Click the CREATE BUILD CONFIGURATION. It creates a new field Build configuration list.
Click the Download build and wait:
.Zip file will be downloaded like this:
Unzip/extract the zip using 7zip.
It will take 1 min to extract.
After the extraction, you will get .img file (a.k.a OS image file).
Next burn the image to SD card.
We are using Etcher (Etcher is an open source project by resin.io). Connect SD card to Computer via a SD card Reader and open Etcher.
Select image and select SD Card and hit Flash. Wait for it. After the Flash, unplug the SD Card Reader and insert it into our Raspberry Pi 3.
Connect Raspberry Pi 3 to a Ethernet via RJ 45 cable and power it up with 5v adapter.
Note: We are not using a display/HDMI monitor because the latest Android Things preview does not support most display units, also we are not going to use it in this project.
Open your router panel or use a mobile app to obtain IP Address of Raspberry Pi.
Now here our Local IP is 192.168.0.22.
https://www.nuget.org/packages/Xamarin.Android.Things/
Don't forget to connect a USB mouse/keyboard and a HDMI Monitor for this. Our sample app we'll demo is a simple to-do list.
Step 2Once you know the IP Address, Open up the Terminal, type adb connect <ipAddress>:
> adb connect 192.168.0.22
This will allow you to see deploy from Visual Studio.
Step 3: Open Visual Studio.I'm going to Demo Visual Studio for Mac. Create a new Project. We'll just create a new Forms App.
Type the App name, Organization Identifier. Make sure to select Android. You don't need iOS. Then Click Next.
Click Create. This will generate a template project using:
2 projects will get created: the Xamarin Forms part and the Droid app.
For those familiar with UWP and WPF Xaml, this is a good transition to create UI for Android Things app. The default sample project is a TODO app. where you can add/modify/delete items on a list.
Step 4: DeploymentWe can deploy this project to Android Things already. No further code changes. Just select Raspberry Pi on the then click the Play button. Wait few minutes. It will display properly.
Here's what it would look like.
Of course you can do this on your Android device, but why would you want to do this in Android Things? If you want to create a user interface to your device, this is the easy way to accomplish. It works with Raspberry Pi Touch Display out of the box.
https://www.raspberrypi.org/products/raspberry-pi-touch-display/
Step 5: Expanding further.Now that we can successfully deploy apps to Android Things. We can expand our project and add reference to Xamarin.Android.Things from Nuget.
You can read more about this here:
If you're interested about Android Things Rainbow Hat, and accessing it sensors inside Xamarin.
The Google Contrib drivers provides for the following components:
- Sparkfun ADC Block for Intel Edison – adcv2x
- Apa102 RGB LED strip
- Bmx280 temperature and pressure sensor
- Push button over GPIO
- Cap12xx capacitive touch buttons
- GPS
- Ht16k33 7-digit alphanumeric segment
- Mma7660fc accelerometer sensor
- PWM speaker/buzzer
- Metadriver for the Rainbow HAT
- Metadriver for the Sense HAT
- Ssd1306 OLED display
- Tm1637 4-digit numeric segment display
You can find more details on each can be found within the Android Things Github repo: https://github.com/androidthings/contrib-drivers
Here's a project to test out.
Let me know if this is useful. I'm currently working on getting Tensorflow Android Things bindings for Xamarin. I will start writing about it soon. Think of it this way, be able to do Image Recognition on the edge using C# and Android Things. If this project made you interested in Xamarin or Android Things, click on the "Thumbs Up" button and follow me.
Comments