skip to navigation
skip to content

Not Logged In

nanpy 0.9.3

Use your Arduino board with Python.

Use your Arduino board with Python. https://github.com/nanpy/

Overview

Nanpy is a library that use your Arduino as a slave, controlled by a master device where you run your scripts, such as a PC, a Raspberry Pi etc.

The main purpose of Nanpy is making programmers’ life easier, providing them a powerful library to create prototypes faster and make Arduino programming a game for kids.

a = ArduinoApi()
a.pinMode(13, a.OUTPUT)
a.digitalWrite(13, a.HIGH)

I know, there are a lot of projects able to do that, but hey, Nanpy can do more!

Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want.

We support OneWire, Lcd, Stepper, Servo, DallasTemperature and many more… Let’s try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and show your first “Hello world”!

from nanpy import Lcd

lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2])
lcd.printString('Hello World!')

really straightforward now, isn’t it? :)

Serial communication

Nanpy autodetects the serial port for you, anyway you can manually specify another serial port:

from nanpy import SerialManager
connection = SerialManager(device='/dev/ttyACM1')

and use it with your objects

a = ArduinoApi(connection=connection)
a.pinMode(13, a.OUTPUT)
a.digitalWrite(13, a.HIGH)

You can specify how many SerialManager objects you want and control more than one Arduino board within the same script.

How to build and install

First of all, you need to build the firmware and upload it on your Arduino, to do that clone the nanpy-firmware repository on Github or download it from PyPi.

git clone git@github.com:nanpy/nanpy-firmware.git
cd nanpy-firmware
./configure.sh

You can now edit Nanpy/cfg.h generated file to configure your Nanpy firmware, selecting the features you want to include and the baud rate.

To build and install Nanpy firmware, copy Nanpy directory under your “sketchbook” directory, start your Arduino IDE, open Sketchbook -> Nanpy and click on “Upload”.

To install Nanpy Python library on your master device just type:

pip install nanpy

How to contribute

Nanpy still needs a lot of work. You can contribute with patches (bugfixing, improvements, adding support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at stagi.andrea@gmail.com

Do you want to support us with a coffee? We need a lot of caffeine to code all night long! if you like this project and you want to support us, please donate using Paypal

License

This software is released under MIT License. Copyright (c) 2012-2015 Andrea Stagi stagi.andrea@gmail.com

 
File Type Py Version Uploaded on Size
nanpy-0.9.3.tar.gz (md5) Source 2015-02-21 32KB
nanpy-firmware-0.9.3.tar.gz (md5) Source 2015-02-21 42KB
  • Downloads (All Versions):
  • 56 downloads in the last day
  • 410 downloads in the last week
  • 823 downloads in the last month
  • Author: Andrea Stagi
  • Maintainer: Andrea Stagi
  • Home Page: https://github.com/nanpy/nanpy
  • Bug Tracker: https://github.com/nanpy/nanpy/issues
  • Download URL: https://github.com/nanpy/nanpy/tags
  • Keywords: arduino library prototype raspberry servo lcd temperature electronics diy
  • License:
    MIT License
    
    Copyright (c) 2012-2014 Andrea Stagi <stagi.andrea@gmail.com>
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
  • Categories
  • Package Index Owner: astagi
  • DOAP record: nanpy-0.9.3.xml