Simple API with web interface using AJAX and direct HTTP commands to allow remote control of any Arduino or other serial device via a Raspberry Pi.
pip3 install cherrypy
pip3 install pyserial
git clone https://github.com/rmccartney856/pyapi
cd PATH//pyapi
sudo python3 install.py
sudo reboot
- Clone Repository to any directory on your Raspberry Pi.
- Install utility as described above.
- Navigate to
http://PI_IP_ADDRESS:8080
orhttp://pyapi.local:8080
.
- Clone Repository to any directory.
- Install Anaconda and import the enviroment
enviroments/pyapi.yml
. - Run
main.py
in the newly imported enviroment. - Navigate to
http://PI_IP_ADDRESS:8080
orhttp://pyapi.local:8080
.
- Send data to the arduino as follows
http://PI_IP_ADDRESS:8080/send?command=ARDUINO_COMMAND_HERE
- Clear log files on server device
http://PI_IP_ADDRESS:8080/clearLogs
- Acquire Receive log
http://PI_IP_ADDRESS:8080/public/receiveLog.csv
- Acquire Transmit log
http://PI_IP_ADDRESS:8080/public/transmitLog.csv
- Connect or Reconnect Serial
http://PI_IP_ADDRESS:8080/connect
- Get latest serial monitor data in table form
http://PI_IP_ADDRESS:8080/serialMonitor
- Get latest serial monitor line as string
http://PI_IP_ADDRESS:8080/getLine
- Use
glob
to detect and connect to devices automatically. - Responsive web design.
- Clean table display in webpage.
- Add the use of
settings.json
for easier configuration.
Note: The serial port is automatically connected when using the send?command=ARDUINO_COMMAND_HERE
function. The connect command is best used to manage disconnect errors.
The web interface displayed in Google Chrome on a Windows 10 desktop is given as follows;