We can use any modern Android Smartphone something like a Raspberry Pi with a camera, all the sensors & send the collection to any IoT platform. Although it will sound like a complex work it is easy because of a lot of development by many hundreds of developers. There are ready to use Android applications which does the similar job from GUI and connect with IoT platform like IBM Watson IoT but, in this guide we will show the way from command line and Node-RED. We have used Samsung A50s for testing purpose.
Required Applications to Install on Android Smartphone
Install Termux application and Termux API application from Google Play. It is practical to use some physical mouse-keyboard via USB OTG. Also, you can share the smartphone screen to some screen which is bigger (like laptop, Smart TV).
Launch Termux. Run these commands :
---
1 2 3 4 5 6 7 8 9 10 |
apt update apt upgrade apt install termux-api apt install coreutils nano nodejs npm install -g --unsafe-perm node-red cd ~/.node-red ls -al npm install node-red-dashboard npm install node-red-contrib-ibm-watson-iot npm install node-red-contrib-collector |
The volume-down
key and c
on touchscreen keyboard works as ctrl+c
to exit any application on Termux. Now, you can start node-red :
1 2 3 |
# node-red # |
Node-RED will now run on localhost (127.0.0.1
) on the Android phone. It will show the IP address and port (1880
) it is running on in Termux. You can point a browser to 127.0.0.1:1880
and it will open up Node-RED flows editor.

How to Get the Sensor Data on Termux
You can open a new session in Termux by swiping the left drawer and clicking the new session option. This command will list all the sensors of your phone :
1 2 3 |
# termux-sensor -l # |
The names on the list will vary on the handset model. For Samsung A50s, there are a lot of sensors which starts with the name “Samsung”. There is an extensive official documentation on how to use the commands related to Termux-API. We can grab data of one sensor by this kind of command :
1 2 3 4 5 |
# termux-sensor -s "TCS3701 Light" # |
It gave me a continuously updated value :
1 2 3 4 5 6 7 |
{ "TCS3701 Light": { "Values": { 118 } } } |
The light sensor is near the selfie camera. You can block the light falling on it with palm to get near-zero value to test the thing.
We can use Node-RED’s exec
node to run the above command and get the sensor data into Node-RED’s flow editor. We need to convert that data into JSON. The final step is to push it to the IoT platform of your choice, like IBM Watson IoT. This was a generic guide to grab the data, we are not going into the details of how you will send the data. Your logical flow on Node-RED will be :
[timestamp node] –> [exec node] –> [json node] –> [function node to extract the number] –> [function node to format for your favourite IoT platform] –> [http request node] –> [msg payload node]
If we think IBM Watson IoT as the IoT platform then that platform will identify your device in the same manner as it does with Raspberry Pi.
Essentially, on IBM Watson IoT, you have to follow the same steps like we did with ESP32. So, the total procedure is easy.
Tagged With node red android sensors , termux iot , termux read camra data in mobile , node-red-contrib-keyboard-mouse-triggers termux , termux sensors , use mobile phone as iot , node red termux , node red Android send gyroscope data , iot with termux arduino , how to smart pfone function using iotHere’s what we’ve got for you which might like :
Additionally, performing a search on this website can help you. Also, we have YouTube Videos.
Take The Conversation Further ...
We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!
If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.
Contact Us