Configuration for AudioLoRa.
LoRa is a long-range, low-power radio technology designed for occasional telemetry (a few bytes every so often), not for continuous audio. LoRa's PHY settings trade range/robustness for throughput: spreading_factor ranges from 6 (fastest, shortest range) to 12 (slowest, longest range), and signal_bandwidth from 7.8 kHz (slowest, longest range) to 500 kHz (fastest, shortest range). The defaults below (spreading_factor = 6, signal_bandwidth = 500 kHz) pick LoRa's fastest, shortest-range end of that scale, since audio needs throughput far more than a typical LoRa telemetry use case does. If you want LoRa's usual long range/robustness instead and don't care about audio, override these back towards 12 / 7.8 kHz – but expect only tens of bits per second at that end, which cannot carry audio at all.
Even at these fast defaults, usable throughput is still only on the order of tens of kbps – nowhere near typical PCM bitrates (8 kHz/8-bit mono alone is 64 kbps) – so audio only becomes practical once reduced to a very low sample rate, 8-bit and/or mono, and ideally compressed before it reaches this stream. Treat this as a fit for short clips or intermittent bursts, not a continuous/live stream; several regions additionally impose legal duty-cycle limits on the ISM bands LoRa uses (e.g. roughly 1% airtime in the EU 868 MHz band) that a sustained stream would likely violate.
Codec recommendation: encode speech with Codec2 (Codec2Encoder / Codec2Decoder in AudioTools/AudioCodecs/CodecCodec2.h) before writing to this stream, and decode it back out after reading. Codec2 was designed for exactly this situation – squeezing intelligible speech over narrowband radio links (it's the codec behind ham radio digital voice modes like FreeDV) – and offers modes from 3200 bit/s down to as low as 450 bit/s. At its 700 bit/s mode, a single ~200 byte LoRa packet carries over 2 seconds of speech, compared to a fraction of a second of raw 8-bit PCM; that's the difference between this being usable for short voice messages and not being usable at all. See the full codec list at https://github.com/pschatzmann/arduino-audio-tools/wiki/Encoding-and-Decoding-of-Audio for alternatives if Codec2 doesn't fit your case (e.g. GSM 06.10 at ~13 kbps if you have more throughput headroom and want wider codec compatibility with other systems).
Heltec LoRa 32 pins (as used by pin_ss/pin_rst/pin_dio0 below): NSS: 8, SCK: 9, MOSI: 10, MISO: 11, RST: 12, BUSY: 13, DIO1: 14
- Author
- Phil Schatzmann
- Copyright
- GPLv3