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

This Article Has Been Shared 185 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic 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

  • Capacitive Touch Screen : Brief Details

    Capacitive Touch Screen work on principle of Capacitive sensors which work based on the change in the capacity of a single capacitor or entire system.

  • Computer Appliance : What are Computer appliances ?

    Computer Appliance appliance is an approach to design a combined system of computer hardware and hardware optimized software to run on for optimal performance.

  • Hardware Emulation in Brief

    Hardware Emulation is a terminology used in computer technology, where a system made to falsely behave in certain aspects to get some advantages.

  • Right Colors on MacBook's Display : Reloaded

    Right Colors on MacBook’s Display is not really that easy as 1-2-3 to set due to various wide variety of applications and Standard. Here is how to fix it.

  • How to Convert Paper Documents to PDF (Pro Quality for Free)

    There Are Multiple Ways to Convert Paper Documents to PDF. Printing services and offices use costly professional machines to do it in easy way.

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

Subscribe To Our Free Newsletter

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

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 (20K Followers)
  • Twitter (4.9k Followers)
  • Facebook (5.8k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.2k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Top 10 Anti Hacking Software for Microsoft Windows January 22, 2021
  • What is Software Modernization? January 21, 2021
  • Cloud Computing : Cybersecurity Tips for Small Business Owners January 20, 2021
  • Arduino : Independently Blink Multiple LED January 18, 2021
  • What is a Loosely Coupled System? January 17, 2021

 

About This Article

Cite this article as: Abhishek Ghosh, "Connect Android CLI (Termux) to IBM Watson IoT Like Raspberry Pi," in The Customize Windows, October 5, 2019, January 22, 2021, https://thecustomizewindows.com/2019/10/connect-android-cli-termux-to-ibm-watson-iot-like-raspberry-pi/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

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

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