Skip to content

pigetArduino/utest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version française / French version

UTest : Make USB Devices with Arduino

UTestpython app
Demo : https://www.youtube.com/watch?v=jTq_U3kP7iU

Utest is a base to make python application to control arduinos on Windows.
This application turn on/off the internal led on an arduino nano (clone)
A python module manages the arduino
The application can be saved as an executable to be easily share.

Usage

How to install drivers : https://www.youtube.com/watch?v=m3CsftsfiQU

Features

  • Easy to understand and modify code
  • Serial port autodetection
  • Auto reconnection even if the serial port change
  • You don't need to manage detection and serial communication.
  • Control multiples arduinos

Issues

The application might not work on Windows 7 due to missing .dll
This shouldn't happen if your computer is up to date

Create your own application

This application use tkinter (which is included in python) to manage the gui
Documentation : http://www.tkdocs.com/tutorial/index.html

Prerequisites

  • Download python 3 : https://www.python.org/downloads/

  • During the installation, tick Add Python 3.5 to PATH
    Python Path

  • Open a command prompt (Windows Key + cmd) and install pyserial

pip install pyserial

Start the application

  • Open a command prompt (Windows key + cmd)
  • Go to the source code (apps/utest/)
  • Type:
python utest.py

Compile

You can compile the application to share it as an .exe file
However, You need to install pyinstaller

pip install pyinstaller

Then you can compile it using the script compile.bat or

pyinstaller --onefile --noconsole utest.py 

If you wan't to display debug messages

pyinstaller --onefile utest.py 

How to use the library : USB.py

In order to manage the arduino the easiest way possible, everything is handle by the module usb.py
Check the source code (in apps/utest and /utest) for more information

Windows

The module only has two commands

Manage arduino serial communication

from lib import USB
device_name = "CH340" #Device name in Windows
device_type = "UTest" #Device type (in the arduino sketch)
device_return_string = "OK" #Answer when a response is correct
device_baudrate = 115200 #Baudrate
usb = USB.Device(device_name,device_type,device_return_string,device_baudrate)

Send a string to the arduino

usb.write("ON")

Arduino

Define device type

const String usb_name = "UTest";

Usage

void loop() {
  serialManager(); //This function manages serial

  //If string received
     if (readString.length() > 0) {
      serialCheck(); //Check arduino type

      //Insert actions list here
      if (readString == "ON"){
        digitalWrite(13,1);
      }
      if (readString == "OFF"){
        digitalWrite(13,0);
      }
      
    }

  //Clear serial buffer
  readString = "";
}

Licences

Software by Rémi Sarrailh (madnerd.org) Licence: MIT

About

Transform arduino into usb devices using python and serial communication

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages