Skip to content

Arduino library to send key/value pairs from PC (Python) to Arduino

Notifications You must be signed in to change notification settings

markfickett/DataReceiver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

Arduino library to send key/value pairs from PC (Python) to Arduino

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published