Skip to main content

Nanpy

Use your Arduino board with Python. http://pypi.python.org/pypi/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.

from nanpy import ArduinoApi

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

from nanpy import ArduinoApi
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 https://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-2016 Andrea Stagi stagi.andrea@gmail.com

Metadata

Release files for nanpy 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for nanpy 0.9.6
File Size Uploaded
nanpy-firmware-0.9.6.tar.gz 44.5 kB Details
nanpy-0.9.6.tar.gz 33.8 kB Details

Release files / nanpy-firmware-0.9.6.tar.gz

Download URL nanpy-firmware-0.9.6.tar.gz
Size 44.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a2acd2931d0fa2f5469720f5b45d213da6277e101190743208e4d7beeefeee77
BLAKE2b-256 checksum
How to use checksums
fd9ad088fe79d0a6857c19517ccf46621fcb7741d76c3b16900b306f2ad324f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / nanpy-0.9.6.tar.gz

Download URL nanpy-0.9.6.tar.gz
Size 33.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8b57525ece2fbbc7f2e456ad4ae70cc98fc81b996009469c26ce42ee055a1884
BLAKE2b-256 checksum
How to use checksums
adc49d81917ac0165e9541cd82490bda749599f5dd97a215b892e1b0267650c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.9.6 This release

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9

2 release files

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page