Skip to main content

Use your Arduino board with Python.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

nanpy-firmware-0.9.3.tar.gz (43.2 kB view details)

Uploaded Source

nanpy-0.9.3.tar.gz (33.0 kB view details)

Uploaded Source

File details

Details for the file nanpy-firmware-0.9.3.tar.gz.

File metadata

File hashes

Hashes for nanpy-firmware-0.9.3.tar.gz
Algorithm Hash digest
SHA256 f59b5e0f0c851137abd480e6b41ce1728b1d166c005c6f0c0cb51858daa11713
MD5 1434bcb8fbec856c55b3964880475ccd
BLAKE2b-256 ac55688dcfec9d7bd0f6a328d02a91e4e052925f90ea4690a4f3075a5e46fc40

See more details on using hashes here.

File details

Details for the file nanpy-0.9.3.tar.gz.

File metadata

  • Download URL: nanpy-0.9.3.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nanpy-0.9.3.tar.gz
Algorithm Hash digest
SHA256 8c5e8a2af216ba4caeed886e1339b522eb31174aa1b8827f1d766df42d4b4387
MD5 60c14dcc34407c53fe92cba420266a86
BLAKE2b-256 2c324dd0f07c726d7c86f66355af8ce95b278b6259aca4722cd9be86c06d2387

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page