Skip to main content

Low-effort serial communication, e.g. for talking to devices that use the Arduino-IDE Keyhole library

Project description

This module provides the Keyhole class, which allows easy line-by-line text communication over a serial port. It is particularly useful for implementing the computer’s side of the interaction when talking to a microcontroller that has been programmed using the Arduino- IDE Keyhole library. In that case, exposed sketch variables can be accessed as attributes of a Keyhole instance in Python.

The Arduino side:

#include "Keyhole.h"
Keyhole k;

void setup()
{
    Serial.begin(9600);
}
void loop()
{
    static float foo = 1.23;
    static String bar = "hello";

    // insert main sketch logic here (use foo and bar to do whatever is so important)

    if(k.begin()) // expose the variables
    {
        k.variable("foo", foo);
        k.variable("bar", bar);
        k.end();
    }
}

The Python side:

from keyhole import Keyhole

# k = Keyhole('COM4')                 # windows example
k = Keyhole('/dev/cu.usbmodem[0-9]*') # macos example (globbing is OK if the match is unique)

print( k.bar ) # queries an exposed sketch variable
k.foo = 4.56   # assigns to an exposed sketch variable and makes the .variable() call return true

print( k() )  # get all exposed variables

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keyhole_comm-1.12.0-py2.py3-none-any.whl (8.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file keyhole_comm-1.12.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for keyhole_comm-1.12.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b17248a7a5266f67d627eb85a7c1240acdaff9345cb4ee32839b32d79a61fa5f
MD5 1a6f1880ab7441c27f938e1dd6eadcc6
BLAKE2b-256 a8f1b7ca6fdb8b69bc4c15c2c13bc6794f7a23345658d5784c69721edcdf5887

See more details on using hashes here.

Supported by

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