Introduction
If you have used LinkIt One or read documentation, you'll discover that serial port is not the only option for debugging your projects. I have created a simple LinkIt One library and a Python Server terminal for sending and receiving your debugging information over your home wifi network. Use the library, plug LiPo battery into LinkIt and start receiving debug messages through WiFi. Feel free to hack and modify the Library to suit your needs if you feel you dont need serial port for debugging. Since the terminal server is written in python its cross platform thus you can run it on any computer with ease or without modification. e.g if you are developing a GPS Application and you've got a poor signal inside your house, you can program LinkIt and place it outside and view your GPS information.
Set up
Arduino Sketch SetUp
include the preprocessor needed and the LTerminal library. To use the LTerminal Library you need to put the LTerminal folder in your Arduino Libraries folder.
//includes required
#include
#include
//include LTerminal library
#include
set your wifi and terminal server credentials accordingly
//defines: user credentials
#define WIFI_AP "your_AP" //wifi AP
#define WIFI_PASSWORD "password" //wifi Password
#define WIFI_AUTH LWIFI_WPA// choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP.
#define SERVER "192.168.1.101" //set server i.p address
#define PORT 2215 //port
in the setup function, start with LTerminal.begin(WIFI_AP, WIFI_AUTH, WIFI_PASSWORD, SERVER, PORT)
and then begin printing your data to terminal using the Print Class Methods e.g. write, printf, print and println.
Note: To send data to server always make sure to put a blank println() at the end your print/write statements i.e. LTerminal.println()
Terminal Setup
Setting up the Terminal is easy
- In the downloaded library folder, confirm you have the terminal python file,
LTerminal.py
- To start the terminal, in windows, open the command shell and type
python folder_location/LTerminal.py
e.gpython D:/libraries/LTerminal/LTerminal.py
. same applies to linux OS terminal shell. In both cases make sure you are opening the file using Python 3. If you are using Python 2.7 no worries, just rename all instances of socketserver to SocketServer - If you cant successfully open the terminal, thats is, the terminal identifies wrong i.p address, then specify your host i.p as an argument in the command shell e.g
python folder_location/LTerminal.py 192.168.1.101
What's More
- Unfortunately you can only send to the server and not back to LinkIt One but implementation is easier since LinkIt wifi Client suports reading responses and the Terminal/Server side is implemented using python socketserver module capable of creating a powerful server.
- A Graphical Interface is much better than command shell, if you can do it then hack the LTerminal.py else wait for update.
Muchiri
Comments