REVIVE AN OLD SMARTPHONE AS AN IOT SENSOR

USING an MQTT Broker

The idea of using a relatively old smartphone, such as a Samsung Galaxy Nexus for example, is not new, however not many information are available.
To achieve this goal these are the elements of the solution:

The Smartphone

Before installing Sensor Node, it is strongly suggested to upgrade the android system to Lollipop (5.0 – 5.1.1) or Marshmallow (6.0 – 6.0.1), if feasible. A search through XDA Developers Forum will definitely help on this matter

Then install Sensor Node from the android Play Store as any other android app.

There are two version of Sensor Node, the free version and the paid version. The free version would be just fine for getting acquainted to the set up and do some testing.

The Sensor Node app is not a fully foolproof application and bear with it some glitches: it doesn’t support SSL/TLS, it may behave strangely if the smartphone is not kept constantly alive and it may also hangs up sometime, but it would suffice for the casual user.

After all it was a “dust collecting” smartphone, revived…

If, by whatever reasons you cannot install the Sensor Node through the Google’s Play Store, here you can download the apk file and then install it manually on the smartphone.

Once Sensor Node is installed it is possible to check the sensors supported. Those indicated with N/A are either non-existent with the smartphone hardware or may require a non standard or proprietary API to be utilized. In this example, the Samsung Galaxy Nexus has the following sensors:

Gravity (working).

Light Intensity (not working).

Barometric Pressure (working).

Ambient Temperature. (working uncalibrated).

Proximity (working).

Linear Acceleration (working).

Rotation Vector (working).

Accelerometer (working).

Gyroscope (working).

Magnetometer (working).

Noise Level (working).

It is also possible to view the sensor values in graphical mode, although by stopping the MQTT transmission, which is a very convenient way to check the sensors capabilities before using them.

Once the MQTT Stream is configured with:

Mqtt server:
tcp://[ip.ad.dr.ess]:1883

(!!important!! the “tcp” protocol name shall be lowercase for the stream to work correctly)

Base Topic Name:
[anything]/[you]/[like]/[here]

(i.e. “sensornode/livestream/CENX1”)​

Select the sensor/s you want to stream through the MQTT protocol and by pressing the lower button, to change it from “off” to “on”, the MQTT messages of the smartphone will start flowing to the MQTT Broker.

The MOSQUITTO Subscriber

Once the MQTT Stream is flowing from the smartphone to the broker, you can receive the MQTT messages with an MQTT subscriber client, like the MOSQUITTO Subscriber client:

USING a TCP STREAM

Something very similar to what has been described so far, using an MQTT Broker, can be achieved by using a different APP on the smartphone and by using “netcat” or “socat” onto the receiving server.

The SENSOR FUSION App

The SENSOR FUSION App was developed by Gustaf Hendeby as part of introducing the app as part of a lab in the Sensor Fusion course at University of Linköping the spring of 2013, and it was meant for exchanging sensor data with MATLAB. However the app can gather data from the smartphone sensors and send the data through a TCP stream to a configurable port. The App is pretty straight forward to configure and use. Here follows some screenshots:

To access the settings you have to click on the “red gear” in the bottom right corner of the screen, which is a little counter intuitive at the beginning.

Before hitting the “Start” button on the “Log Data” screen, make sure that you have the receiving end, ready to accept the data, by listening on the configured TCP port, in this example “TCP 3400”. You can achieve this by running “netcat” onto a terminal of the server, as follows: