r/ArduinoProjects • u/TastyCollege9639 • 10d ago
Showcased Project Got my ESP-NOW / UDP multi-KB packet recovery library merged into the Arduino Library Manager (NLTP)
Hey everyone, wanted to share a library project I finished up and finally got merged into the official Arduino IDE Library Manager this week (search "NLTP" in Manage Libraries).
The whole thing started because I was sending 4 KB to 16 KB sensor batches between an ESP32 dev board and an old NodeMCU ESP8266 across a noisy 2.4 GHz floor. Raw ESP-NOW v1 maxes out at 250 bytes per frame, so a 10 KB log turns into 40+ packets. Whenever Wi-Fi interference knocked out two or three packets, the whole transfer was toast. Switching to Wi-Fi TCP fixed the corruption, but every random RF fade caused TCP retransmit backoff to freeze everything for several seconds, including urgent stop commands.
So I wrote NLTP in plain C99 with static arrays (no malloc or heap fragmentation, no floats). Before slicing a buffer into 250-byte ESP-NOW frames, it compresses repetitive JSON/CSV text with a small LZ4 pass, encrypts each frame with ChaCha20-Poly1305 after an X25519 handshake, and tacks on extra parity shards using GF(28) Cauchy erasure coding. As long as any k shards make it across the air, the receiver rebuilds the missing packets on the fly without asking for a retransmit. There is also a separate 1-packet reflex message type so urgent commands bypass the bulk transfer queue.
For small boards like the ESP8266, defining NLTP_TX_ONLY before including the header drops the peer struct down to 4,760 bytes of RAM (full bidirectional mode is 22,872 bytes). I also wrote a matching Python package (pynltp) so a Raspberry Pi or laptop gateway can decode the radio packets and forward them straight to MQTT or disk.
Repo with 7 example .ino sketches and the bench test scripts is here (MIT licensed):
https://github.com/indian-aman/NLTP-Arduino
If anyone tries it on RP2040 W, STM32 + Wi-Fi, or long-range ESP-NOW LR mode, I would love to hear how it behaves on your setup.
