examples/HexadecimalADC/README.md
This project showcases how to integrate binary data parsing, custom serial actions, timed execution, and checksum validation in a Serial Studio workflow using Arduino. It provides a complete example of how to build a robust, command-driven interface for sensor data acquisition, suitable for real-time plotting and FFT analysis.
The Arduino collects analog readings from six input channels (A0 to A5), processes the values, wraps them in a binary protocol frame with a CRC-16-CCITT checksum, and only sends data when explicitly commanded using a custom "poll-data" action. Serial Studio triggers this action either manually or via timer modes like auto-start or toggle-on-trigger.
Works with any Arduino board featuring analog input pins. No external components required—floating analog pins generate natural noise, ideal for FFT demonstrations.
HexadecimalADC.ino)This sketch configures the ADC, listens for serial commands like "poll-data", reads analog values, computes a CRC, and sends data over serial only when asked.
Frame Format:
0xC0 0xDEBaud Rate: 115200
Trigger via Serial Studio Actions:
poll-data: Read and transmit 1 data frameenable-pull-up: Enable pull-ups on A0–A5disable-pull-up: Set A0–A5 to normal input modeBinary (direct)0xC0 0xDECRC-16-CCITTYou can define custom actions in your .json project to send:
"poll-data" on button press or toggle"poll-data" automatically using timer/**
* Convert each byte (0–255) into a voltage between 0 and 5V.
*/
function parse(frame) {
let dataArray = [];
for (let i = 0; i < frame.length; ++i) {
let byte = frame[i];
dataArray.push(byte * 5.0 / 255);
}
return dataArray;
}
For help on the parser function, see the Serial Studio documentation.
"poll-data" action.poll-data is being sent.