Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Arduino library to send key/value pairs from PC (Python) to Arduino
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples/echonumber
.gitignore
DataReceiver.h
README.markdown
Shared.h
data_sender.py

README.markdown

DataReceiver

Arduino library to provide simple sending of key/value pairs from a computer to the Arduino. (For example: I have a CPU usage value on my desktop computer, and want to use an Arduino to control some lights in response to that. This gets the number to from desktop to Arduino.)

To match DataReceiver (the Arduino side) is data_sender in Python. It depends on pySerial for serial communication.

Example

See examples/ for a quick introduction. Even more briefly:

Python:

sender = data_sender.Sender('/dev/usb.serialmodemfa141')
with sender:
    while True:
        ... # Generate a value.
        sender.Send(KEY=value)

        # Maybe handle responses from the Arduino.
        sender.ReadAndPrint()

Arduino:

#include <DataReceiver.h>
DataReceiver<1> receiver; // templated on # keys expected
void callback(size_t size, const char* value) {
    ... // do something with value
}
void setup() {
    receiver.setup(); // Serial.begin
    receiver.addKey("KEY", &callback);
    receiver.sendReady(); // once ready to take Serial input
}
void loop() {
    receiver.readAndUpdate(); // read Serial, call callbacks
}
Something went wrong with that request. Please try again.