KVComm-Send
Send a SLIP package with a dictionary of key-value pairs over the serial port every 5 seconds.
- Boards:
- AVR, AVR USB, Nano Every, Nano 33, Due, Teensy 3.x, ESP8266, ESP32
- Upload this sketch to one Arduino.
- Upload the KVComm-Receive.ino sketch to a second Arduino.
- Connect the TX pin of this Arduino to the RX pin of the second Arduino.
- Open the Serial monitor of the second Arduino.
It should print the following:
abc: 1, 2, 3
password: qwerty123
analog 0: 777
seconds: 12.07
For boards where Serial
is not a hardware UART, use Serial1
as the stream for the SLIPStream.
Written by PieterP, 2020-02-08
https://github.com/tttapa/Arduino-KVComm
#include <boost/crc.hpp>
using CRC = boost::crc_optimal<16, 0x1021, 0xFFFF, 0, false, false>;
Serial,
CRC(),
nullptr,
CRC(),
};
void setup() {
Serial.begin(115200);
dict.
add(
"abc", {1, 2, 3});
dict.
add(
"password",
"qwerty123");
}
void loop() {
dict.
add(
"seconds", millis() / 1000.0);
delay(2000);
}
bool add(const char *key, const T *data, size_t count)
Add a key-value pair to the dictionary, or update the existing value with the same key.