• 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

  • How to Restrict Certain Posts or Categories In WordPress by CountryJune 6, 2023
  • Influence of Digitization on Procurement : Part 1June 6, 2023
  • How We Can Show Apple Icon, Windows Logo on Website TextJune 5, 2023
  • What is Google Bard? How it WorksJune 5, 2023
  • How to Create a PHP Installer Script to Create Tables in MySQL DatabaseJune 4, 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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT