Communication

Keyhole

A lightweight library for serial-port interaction: send commands and get/set sketch variables via a JSON- and Python-compatible text interface.

In one line, and usually with less than a microsecond of overhead, keyhole.variable("foo", foo); provides serial-port access to an integer, floating-point or String variable in your sketch. Set its value by sending foo=123\n - the variable() method will return true to let the sketch know when you do this. Query it by sending foo\n . Query all exposed variables at once by sending ?\n , or choose to have them auto-report themselves periodically. Responses are in easy-to-parse JSON format and can be turned into Python dicts with one call to ast.literal_eval(), but there's a plotter-compatibility mode too. For the computer's side of the interaction, a complementary Python module is included in the project repository (or available separately as keyhole-comm on PyPI).

Go to repository

This library is compatible with all architectures so you should be able to use it on all the Arduino boards.