Giter VIP home page Giter VIP logo

py-arduino's Introduction

py-arduino

py-arduino is a Python tool/library to communicate with Arduino through USB (serial port), plus a web application on top of it.

The low level tool is simple to use and extend, only requires pyserial. Many scripts are included to let you quickly start using it (see py_arduino.cli.*).

The web application allows read and write to pins from a web page, easily implement background tasks, manages the concurrent access to the Arduino (from the web interface, background tasks, cron, command line, etc.), and more... It uses Django, PyRO and uWSGI.

The project has some testing utilities, and an emulator, to allow make some test without actually having an Arduino connected.

Other characteristics

  • Python methods named around Arduino's methods
  • Handles connections timeouts
  • Can recover after timeouts and connection's troubles - see: validateConnection()
  • Easy to extend
  • Easy to debug (with --arduino-debug, which dumps all the data transmitted to/from Arduino)
  • Growing documentation

Implemented methods

The basic methods of Arduino are implemented. The following actions can be done from Python:

  • pinMode()
  • digitalRead()
  • digitalWrite()
  • analogRead()
  • analogWrite()
  • millis(), micro()
  • delay(), delayMicroseconds()`
  • shiftOut()

There are other extra methods:

  • ping() to check communication with Arduino
  • getFreeMemory() returns free Arduino memory
  • autoconnect() to automatically connect to any available serial port
  • validateConnection() to recover after communications problems
  • watchInterrupt(), getInterruptMark() to work with interrupts (Prototype/Work In Progress)
  • enableDebug(), disableDebug(), enableDebugToLcd() to show debug messages
  • getAvrCpuType(), getArduinoTypeStruct() to get information about the Arduino
  • streamingAnalogRead(), streamingDigitalRead() eficientlly receive much values (Prototype/Work In Progress)

And support for:

  • lcdMessage(), lcdWrite(), lcdClear() show messages on LCDs, based on the Hitachi HD44780 (or a compatible) chipset
  • dht11_read() read temperature and humidity with DHT11 sensor
  • ds18x20_read() read temperature with DS18x20 sensor

Quick installation instructions (low level tool/library)

Quick instructions (see full install instructions and other documentation here)

$ git clone https://github.com/hgdeoro/py-arduino.git
$ cd py-arduino
$ virtualenv -p python2.7 virtualenv
$ . virtualenv/bin/activate
$ pip install -r requirements.txt

Then upload the sketch from sketches/py_arduino, and test:

$ python -m py_arduino.cli.ping /dev/ttyACM0

Installation (web application)

To install the web application, follow the steps on Installation (low level tool/library), and then:

$ pip install -r requirements-web.txt
$ python -m py_arduino_web.dj.manage syncdb --noinput --migrate

(that will create a Sqlite3 database at ~/py_arduino.sqlite).

To launch the web server, run:

$ ./bin/run_uwsgi.sh

connect your Arduino, go to http://localhost:8080/, insert the serial device (something like /dev/ttyACM0) and clic 'Connect'.

To use the Django Admin (to modify pin labels, etc.), you'll need to create an user:

$ python -m py_arduino_web.dj.manage createsuperuser

TODOs

  • Add INPUT_PULLUP to pinMode()
  • Add missing basic functions: tone(), analogReference()
  • Add support to use analog pins as digital pins
  • Better streaming support
  • Multi-read (read multiple pins in a single operation)
  • Finish support for interrupt
  • Make hardware-specific functionality optional (LCD, DHT11, etc.)

License y copyright

py-arduino - Access your Arduino from Python
Copyright (C) 2011-2013 - Horacio Guillermo de Oro <[email protected]>

py-arduino is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2.

py-arduino is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License version 2 for more details.

py-arduino's People

Contributors

hgdeoro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.