Skip to content
Johnny-Five TCP Client for Android devices running Termux
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes
.gitignore
Johnny-Five-Android-Termux.PNG
LICENSE Initial commit Jan 4, 2020
README.md
index.js
package-lock.json
package.json

README.md

Johnny-Five-Android-Termux

Johnny-Five TCP script for Android devices running Termux. Works with USB-OTG connected boards.

Based on the code snippets from Luis Montes.

Introduction

Johnny-Five is an outstanding library that allows the remote control of Arduino or other IoT boards using Node.js scripts running in virtually in any system.

Android mobile phones have all the perks you would want for your Arduino board (screen, real time clock, storage, LTE/GSM, sensors, WiFi, Bluetooth, Cameras, UPS, charging circuits, microphones, etc...). Combining the processing power of an old phone with the IO ports offered by the Arduino circuits is the ultimate ecological and cheap way to have the perfect IoT device.

This script allows Johnny-Five to run from a Termux terminal communicating with other Android apps or external devices by using the TCP protocol without root. The reason for the TCP protocol is that Termux still does not implement USB-OTG to Serial drivers, and the vanilla Johnny-Five would hang right out the box.

If you want to connect the board in the same device using the USB-OTG port you will just need a TCP bridge application. I added bellow some free and paid options.

Image

Requirements

Android apps

PC apps

Termux packages

  • nodejs-lts
  • python
  • clang
  • make
  • openssh (optional to operate the device from a PC)

Installation

  1. Install the Firmata sketch in your Arduino/IoT board. Detailed instructions can be found in the Johnny-Five platform pages.
  2. Install the Termux packages using the command pkg install followed by the name of each one of the packages.
  3. Download the index.js and package.json to a directory in your Termux file system or run: npm -i johnny-five-android-termux
  4. Run the command npm install from the same folder where the previous files were placed.
  5. Edit the index.js file and configure for your TCP-Serial Server host and port.
  6. Test the script running node index.js from the same directory.

Node-Red integration

Node-Red, the ultimate IoT interface can be run from Termux and the following tutorial in my web page explains how to make use of Johnny-Five library in this framework.

FAQ

  • What is the default baud rate for Firmata? The default value is 57600bps.

  • I only get the message "Connected to server" and nothing else Please check the baud rate of the server. It should be set for 57600bps.

  • Do I need to root my Android device in order to access the Arduino board using USB? No. Just use a USB-Serial to TCP bridge app and you are fine.

  • I can't connect to a TCP server broadcasting in my own WiFi network Please make sure that your Android is not running a VPN or a Firewall.

  • Running out of disk space in the Android device After the installation you can remove the python, clang and make packages.

Troubleshooting

  1. Install Node.js in your Laptop/Desktop and run exactly the same installation procedures above.
  2. Run the TCP server (like the COMbyTCP) in the same computer and try to connect between the board and the local installation of this script. If it does not work, you might have a problem with the Firmata installation in the Arduino board.
  3. If the connection works, keep the TCP server running in the computer and try to connect from the mobile device. If does not work you have a connectivity problem in the Android device.
You can’t perform that action at this time.