Monitor Arduino Sensor using Smartphone and ESB: IoT Tutorial

July 13, 2015
Topics covered

Arduino board

WSO2 ESB Proxy

Read sensor using arduino board

This post is the application of the IoT reference architecture shown in the previous post about Internet of things Arduino Android and ESB. What if we want to read a remote sensor connected to arduino board using our smartphone? As explained previously, we can connect directly our Android smartphone to arduino and read the sensor data or we can use a different approach where there is an Enterprise Service Bus (ESB) that stands in the middle between the arduino board and the smartphone. Even if the system is a little bit more complex as stated in the previous post using ESB we have a lot of advantages. It is time to show things work:

  •  an ESB proxy using WSO2 ESB that send HTTP request to arduino board and transforms response from arduino board to our smartphone
  • Arduino Webserver that handle HTTP connection and read the temperature sensor
  • Android app that shows the temperature value in our smartphone

How to implement an WSO2 ESB Proxy

The first thing we do is implementing a proxy that lives in our ESB that handle incoming connection from the Android smartphone on one side and on the other side handles HTTP connection toward arduino board.
The ESB proxy is very simple, the picture below shows how it works:

WSO2 ESB Custom Proxy

As said, the proxy accept incoming connection and forward it to the arduino web server that reads the environment temperature and returns a simple XML response. This response is transformed by the proxy and becomes an JSON response.This is the proxy code:

Internet of Things: Arduino, Android, ESB

July 6, 2015
Topics covered




Internet of things (IoT) is one of the most emerging topic and one of the most discussed lately. What is Internet of things? When talking about IoT, we mean a set of smart objects that are connected together and can exchange information.
In this way, it is possible, for example, to create a sensor network and we get information from them using our smartphones. In this world, Arduino plays an important role, because it is a low cost system that can be used in several contexts.
In the previous post, we talked about a simple project that uses Arduino and Android to control a remote led. This post shows a different approach and the Android smartphone does not connect directly to the Arduino and its sensors but uses a component that decouples the Android client and the source of information (Arduino).

IoT Architecture

Recently i came across an interesting article explaining the IoT architecture. This architecture is quite complex and general purpose, i want to simplify it using just some components.
This image show the simplified architecture:

iot reference architecture
Instead of connecting directly the Android smartphone to the Arduino, i used a component called ESB (Enterprise Service Bus). In this case, my preference is for WSO2 ESB because it is an full open source project and it fits perfectly in the IoT ecosystem. Moreover, WSO2 proposed the reference architecture.

Internet of Things with Android and Arduino: Control remote Led

June 2, 2015
Topics covered

Internet of things


Integrate Android with Arduino

Arduino web server

Nowadays a new emerging technology is Internet of Things (IoT): in other words all the physical objects (things)  are connected together  using internet infrastructure. Arduino borard is one of the most important object in this ecosystem. In this post, we will explore how to integrate Android with Arduino making a first step in IoT.Even Goole at io15 presented its new IoT infrastructure called Brillo.
This android tutorial describes how to create an arduino project and android app to control a remote Led.

Internet of things (IoT) overview

The picture below shows the main objects involved in the IoT project:

Internet of things overview

What we need is:
  • Arduino Uno
  • Ethernet shield
  • Smartphone with Android
All the objects are in the same network for simplicity. The idea is that the smartphone sends an HTTP request to the Arduino. A very small and simple Web server runs on Arduino, accepting HTTP request. For simplicity, the app sends JSON data that holds the led status.

Android parcelable tutorial: List and inner class

May 21, 2015
Topics covered

Android Parcelable

Android Parcelable List

Android Parcelable inner class

When we want to pass objects between two components in Android, these objects have to implements Parcelable interface.Parcelable Android is a serialization and deserialisation mechanism as we are used in Java. This post describes how we can use Parcelable interface to pass objects between two Android Activity.
We talked about some basic concepts of Parcelable in Android, in this post we will analyse some more complex example and we will look how we can parcel a List of objects or parcel a class that contains inner class.

Android Parcel object

We know that if we want that Android OS can "serialize" an object it must implement Parcelable interface. To make an object parcelable we have to implements two methods defined in Android Parcelable interface:
Moreover, we have to provide Parcelable.Creator that is used to create an instance of the class from the Parcel data.
So let us suppose we have a simple class that contains a contact info:

public class ContactInfo {

    private String name;
    private String surname;
    private int idx;

    // get and set methods

So to make this object parcelable we have:

public class ContactInfo implements Parcelable {

    private String name;
    private String surname;
    private int idx;

    // get and set method

    public int describeContents() {
        return 0;

    public void writeToParcel(Parcel dest, int flags) {

    // Creator
    public static final Parcelable.Creator CREATOR
            = new Parcelable.Creator() {
        public ContactInfo createFromParcel(Parcel in) {
            return new ContactInfo(in);

        public ContactInfo[] newArray(int size) {
            return new ContactInfo[size];

    // "De-parcel object
    public ContactInfo(Parcel in) {
        name = in.readString();
        surname = in.readString();
        idx = in.readInt();

Android Google map: Add weather data tile

March 30, 2015
Topics covered


Google map in Android

Weather tile

Add tile to a map

This post describes how to add weather layer to google map. We want to add weather data to a map or in other words add to Android google map a tile so that the app; shows clouds, temperature, pressure and so on.
In the previous post we talked about how to get weather information and how to parse the data to create a UI, now we want to add other weather tile to a map. To do it, we start creating a sample project that contains a map activity.
If we use Android Studio (as i suggest) it is very simple and fast.

Create Android Map project in Android Studio

The first step is creating a google map project in Android. As always, we select File->New project and after inserting some project information we land to this page:

Android studio new project

Now select Google Map Activity. Android Studio will create all the things to handle google map in our project. The last thing to do is to add the key to use the map. If you look in the files inside the project you will find the way to create your debug key. Once you have the key, it is time to use the map.