Summary
Run python code on a smartphone to see LED turn on.
Motivation
- Wirelessly run python programs that control Arduino
- Control android without rooting
- Access sensors available in smartphone i.e. camera, GPS
Usage
Follow Setup
instructions then run the following on python ssh terminal to control LED.
1
2
tn.write('1'.encode('ascii')) # on
tn.write('0'.encode('ascii')) # off
Requirements
Hardware
- Android phone (tested on 7.0 and 8.1)
- Arduino UNO
- LED
- USB Cable Type A/B
- OTG cable USB to micro-USB
Software
- Arduino IDE
- Termux (F-Droid version)
- Server Bridge X
Setup
All code is available on github
- On the PC, install Arduino IDE.
- Connect Arduino UNO to PC using USB Cable Type A/B.
Upload sketch.ino to your Ardunio board using the Upload button in the Arduino IDE.
- On the android smartphone, install Server Bridge X and Termux via F-Droid marketplace.
- Open Android app Server Bridge X.
- Attach OTG cable USB to micro-USB to Arduino. Press ‘ok’ when asked to Allow the app ServerBridgeX to access the USB device.
Press play in Server Bridge X.
- Open Android app Termux.
- Connect smartphone to same network as PC.
- On Termux, install SSH tools and python via commands in
script.sh
. On the PC command line, access the smartphone terminal using SSH.
- On PC command line, run Python.
- On Python, run
send.py
commands. LED should turn on/off based on the command sent (1 or 0).