• 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 » Connect Android CLI (Termux) to IBM Watson IoT Like Raspberry Pi

By Abhishek Ghosh October 5, 2019 10:00 am Updated on October 5, 2019

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

Advertisement

Android smartphones can be made to partially work like Raspberry Pi like single board computers. That is probably useful for different reasons. To follow the steps of this guide, you need to read our previous guide for the basic setup with Termux. Although in that guide, we mainly focused on how to use Node-RED, there are is the installation of termux-api and some useful links. Any Android device has restriction around using the GPIO. But actually, we can collect the sensor data using the termux-api, install Python data science tools and also it is possible to indirectly control LED, servo motors connected with an ESP32 over Bluetooth. It will be a complicated idea to build Android-version of TJBot in this way.

Connect Android CLI Termux to IBM Watson IoT Like Raspberry Pi

We are completely avoiding the steps on how to add any IoT to a device on the IBM Watson IoT web interface. That is like we did with ESP32. You must complete adding the device step to get the auth token and other details. For port number 1883, you will have to set the policy as “TLS optional”. Many newbies forget to make “TLS optional” (as it is the developmental purpose) and failed to connect – it is a common matter with IBM Watson IoT.

Open Termux. Update it and run the below command to install Python :

Advertisement

---

Vim
1
2
3
#
pkg install clang python
#

The package includes pip and probably python-dev. Just to recall, on Raspberry Pi, we would run :

Vim
1
2
3
4
#
sudo apt-get install python-dev python-pip
 
#

Upgrade pip :

Vim
1
2
3
#
python -m pip install --upgrade pip
#

Install Watson IoT SDK, you can separately install the dependency paho-mqtt :

Vim
1
2
3
4
#
pip install paho-mqtt
pip install wiotp-sdk
#

IBM has one example repo for Raspberry Pi, you can wget it for testing purpose :

Vim
1
2
3
4
5
6
7
8
9
#
apt install wget
pip install psutil
wget https://github.com/ibm-watson-iot/iot-python/archive/master.zip
unzip master.zip
cd iot-python-master/samples/psutil/src
python iotpsutil.py --quickstart
 
#

psutil will not work anymore on newer Android. You’ll get erroneous permission error against /proc/stat. But, the output will assure you that the setup is otherwise perfect. But, you can look at the samples provided in the GitHub repo of IBM Watson IoT SDK (which you have installed a few minutes/steps before) :

Vim
1
2
3
4
5
#
 
https://github.com/ibm-watson-iot/iot-python
 
#

Like this example “Python Simple Device” (it connects & disconnects, which is possible to trace from IBM Watson IoT’s account dashboard) :

Vim
1
2
3
#
https://github.com/ibm-watson-iot/iot-python/tree/master/samples/simpleDevice
#

There are various ways to set up the environment to “remember” your credentials. One is running these commands (after edit) :

Vim
1
2
3
4
5
6
7
8
9
#
 
export WIOTP_IDENTITY_ORGID=myorgid
export WIOTP_IDENTITY_TYPEID=mytypeid
export WIOTP_IDENTITY_DEVICEID=mydeviceid
export WIOTP_AUTH_TOKEN=myauthtoken
 
 
#

Another way for “Python Simple Device” like Python applications is to create a file named device.cfg in the simpleDevice directory and add the org, device type, device id and the authentication token (edit it) :

Vim
1
2
3
4
5
6
7
[device]
org=$org
type=$type
id=$id
auth-method=token
auth-token=$token
clean-session=true

.

There is an example termux-api wrapper for Python :

Vim
1
2
3
#
https://github.com/Ublimjo/termux
#

You can edit the “Python Simple Device” script and execute the termux-api commands to grab data from the sensor.

This ends this small guide.

Tagged With android termux mqtt paho , how do i access Ibm cloud from termux , ibm cli on 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 Connect Android CLI (Termux) to IBM Watson IoT Like Raspberry Pi

  • 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.

  • 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 […]

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

    We can use any modern Android Smartphone something like a Raspberry Pi with camera, all the sensors & send the collected to any IoT platform.

  • WROOM ESP32 Example Codes For IBM Watson IoT Platform

    Here Are Few WROOM ESP32 Example Codes For IBM Watson IoT Platform So That Anyone Can Get Started With Both of Them Without Huge Experience.

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