• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How to Use Android Smartphone as IoT Device (Termux, Node-RED)

By Abhishek Ghosh September 28, 2019 6:56 am Updated on September 28, 2019

How to Use Android Smartphone as IoT Device (Termux, Node-RED)

Advertisement

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 :

Advertisement

---

Vim
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 :

Vim
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 Use Android Smartphone as IoT Device

 

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 :

Vim
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 :

Vim
1
2
3
4
5
#
 
termux-sensor -s "TCS3701 Light"
 
#

It gave me a continuously updated value :

Vim
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 sensors , node-red-contrib-keyboard-mouse-triggers termux , termux iot , termux read camra data in mobile , use mobile phone as iot , node red on termux , node red android iot termux , iot with termux arduino , how to get a cloud data using termux
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How to Use Android Smartphone as IoT Device (Termux, Node-RED)

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Getting Started with Node-RED for ESP32 Arduino (localhost & IBM Cloud)

    Here is Getting Started Guide with Node-RED for ESP32 Arduino to Learn on localhost & IBM Cloud. Node-RED is a way to visualize data on IBM Watson IoT platform.

  • Connect Android CLI (Termux) to IBM Watson IoT Like Raspberry Pi

    Here is How to Setup Your Android So that You Can Connect Python Scripts to IBM Watson IoT Platform from CLI (Termux) Like Raspberry Pi.

  • IoT Based Pulse Oximeter With ESP32, MAX30102 and IBM Watson IoT

    Pulse oximeters are in use since long during an operation, in intensive care, in the emergency room and other places such as in unpressurized aircraft. The COVID-19 pandemic made pulse oximetry technology for the consumers. Most of the finger pulse oximeters in the market lack BLE and Wi-Fi. There are only a few finger pulse […]

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

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy