This project implements a Push-to-Talk (PTT) walkie-talkie system using LoRa communication on a LilyGO T-Echo board with an NRF52840 microcontroller. The project is designed to work with an e-paper display (e.g., GxEPD2 1.54" display) and supports different operating modes, including PTT, text message display (TXT), raw data display (RAW), and a test mode (TST).
- LoRa Communication: Enables long-range, low-power communication between devices using the SX1262 LoRa module.
- PTT Mode: Allows voice communication using a push-to-talk mechanism, with audio encoding/decoding using Codec2.
- TXT Mode: Displays text messages received over LoRa.
- RAW Mode: Displays raw data packets received over LoRa without filtering.
- Test Mode: Sends periodic test messages to verify communication.
- E-Paper Display: Displays current mode, messages, and other relevant information on an e-paper display.
- Power-Off Function: Hold the action button for 5 seconds to power off the device.
- Double-Click Action Button: Quickly adjust the spreading factor (SPF) using the double-click action button.
- Battery Support: Includes monitoring and display of battery status.
- Non-Blocking Send & Receive: Improved performance through non-blocking packet transmission and reception.
- Packet Counter Synchronization: Keeps track of the number of packets sent and received, improving communication reliability.
- Microcontroller: LilyGO T-Echo with NRF52840
- LoRa Module: SX1262
- E-Paper Display: GxEPD2 1.54" e-paper display or similar
- Buttons: Two buttons for mode switching and PTT action
- Audio Components: Microphone and speaker (for voice communication)
- OTG Cable: For connecting the microcontroller to an Android device (if using an Android development environment)
- Battery: For mobile operation, with support for battery status monitoring
- Arduino IDE (or Arduino Studio on Android)
- Adafruit nRF52 Board Package
- Required Libraries:
- AceButton
- Adafruit_BME280_Library
- Adafruit_BusIO
- Adafruit_EPD
- Adafruit_GFX_Library
- Adafruit_Sensor
- Adafruit_Unified_Sensor
- Button2
- Codec2
- GxEPD
- GxEPD2
- MCCI_LoRaWAN_LMIC_library
- MPU9250
- PCF8563_Library
- RadioLib
- SdFat_-_Adafruit_Fork
- SerialFlash
- SoftSPI
- SoftSPIB
- TinyGPSPlus
-
Download and Install Arduino IDE:
- Download the latest version of the Arduino IDE from the official website.
-
Configure Board Manager:
- Open Arduino IDE, then navigate to
File > Preferences
. - In the "Additional Boards Manager URLs" field, add the following URL:
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
- Click "OK" to save the preferences.
- Open Arduino IDE, then navigate to
-
Install the Adafruit nRF52 Board Package:
- Go to
Tools > Board > Boards Manager
. - Search for "Adafruit nRF52" and click "Install" next to "Adafruit nRF52 by Adafruit".
- After installation, select
Nordic nRF52840 (PCA10056)
from the board list.
- Go to
-
Copy Required Libraries:
- Copy all the folders from the
libraries
directory in this project to your Arduino libraries directory:C:\Users\<YourName>\Documents\Arduino\libraries
- The required libraries include:
- AceButton
- Adafruit_BME280_Library
- Adafruit_BusIO
- Adafruit_EPD
- Adafruit_GFX_Library
- Adafruit_Sensor
- Adafruit_Unified_Sensor
- Button2
- Codec2
- GxEPD
- GxEPD2
- MCCI_LoRaWAN_LMIC_library
- MPU9250
- PCF8563_Library
- RadioLib
- SdFat_-_Adafruit_Fork
- SerialFlash
- SoftSPI
- SoftSPIB
- TinyGPSPlus
- SPI.h (usually pre-installed with Arduino IDE)
- Wire.h (usually pre-installed with Arduino IDE)
- Copy all the folders from the
-
Connect the T-Echo Board:
- Connect your T-Echo board to your computer via USB.
- In the Arduino IDE, go to
Tools > Port
and select the port corresponding to your board.
-
Upload the Code:
- Open the project sketch in Arduino IDE.
- Click the upload button to compile and upload the code to your T-Echo board.
-
Install VSCode and Python:
- Download and install Visual Studio Code (VSCode) and Python.
-
Install PlatformIO:
- Open VSCode and go to the Extensions view by clicking on the square icon on the left sidebar.
- Search for "PlatformIO IDE" and install the extension.
-
Open the Project:
- Open the T-Echo project folder in VSCode by going to
File > Open Folder
.
- Open the T-Echo project folder in VSCode by going to
-
Compile and Upload:
- On the PlatformIO home page, click the checkmark (√) in the lower left corner to compile the project.
- Click the arrow (→) to upload the firmware to the T-Echo board.
-
DFU Mode (for USB Upload):
- If you are uploading firmware via USB (
upload_protocol = nrfutil
), double-click the reset button on the T-Echo to enter DFU mode before uploading.
- If you are uploading firmware via USB (
- Library Files: Ensure that the files in the
libraries
directory are correctly placed in your Arduino libraries directory, as they include crucial dependencies. - Pin Compatibility: The T-Echo pin assignments may not be directly compatible with the official SDK. Pay special attention to pin definitions if using the nRF5-SDK.
- Bootloader: The T-Echo comes with the Adafruit_nRF52_Arduino bootloader pre-installed. Programming the board with the nRF5-SDK will overwrite this bootloader.
- NFC Functionality: NFC is not supported in the Adafruit_nRF52_Arduino environment; use the nRF5-SDK if NFC functionality is required.
- Flash Memory: The T-Echo may use either the MX25R1635FZUIL0 or ZD25WQ16B flash memory chip. Be aware of the differences when programming.
- Burning a New Bootloader: If you need to restore the bootloader, refer to the official documentation on burning a new bootloader.
The main entry point of the program. Initializes all peripherals and handles the main loop, switching between modes.
Manages the e-paper display, including rendering icons and text. Handles mode-specific display updates.
Configures and controls the LoRa communication module, including setting power and current limits.
Handles audio capture and playback using the NRF52840's I2S interface, with Codec2 encoding/decoding.
Manages user settings, including mode switching and configuration adjustments. Refactored to store settings in a DeviceSettings
struct.
Implements the core logic for the different operational modes (PTT, TXT, TST, RAW). Refactored to use an array of strings for mode management. This includes handling button events for mode switching, managing audio transmission in PTT mode, sending test messages, and processing received LoRa packets. The functions also update the display to reflect the current mode and channel.
This project is licensed under the MIT License - see the LICENSE file for details.
- Adafruit for providing robust hardware and software libraries for the NRF52840.
- RadioLib for comprehensive LoRa communication support.
- Codec2 for the open-source audio codec.
- LilyGO for the T-Echo hardware platform.
If you encounter any issues:
- Ensure all libraries are correctly installed and up to date.
- Verify wiring connections, particularly for SPI and I2S peripherals.
- Check the serial monitor for debugging messages during setup and operation.
- Consult the documentation for the respective libraries and hardware modules.
- DFU Mode: If the board does not appear to respond when trying to upload new firmware, double-click the reset button to enter DFU mode and try uploading again.
For further assistance, feel free to open an issue in the repository or contact the project maintainers.
- NFC Functionality: The NFC feature is not supported when using the Adafruit_nRF52_Arduino environment. To use NFC, you must switch to using the nRF5-SDK. Be aware that doing so will overwrite the pre-installed bootloader on your T-Echo.
- Flash Memory Variants: The T-Echo board may come with either the MX25R1635FZUIL0 or ZD25WQ16B flash memory chip. Ensure you account for the specific chip variant in your code if flash memory is used.
- Using nRF5-SDK: If you intend to use the nRF5-SDK, remember to check the pin configurations and manage the bootloader accordingly. Instructions for burning a new bootloader can be found in the official T-Echo documentation.
- T-Echo Official Documentation: Visit the T-Echo GitHub repository for detailed hardware documentation and additional resources.
- Adafruit nRF52 Libraries: The Adafruit GitHub repository contains the official libraries and tools for working with the nRF52 series.
- Codec2 Documentation: Learn more about the Codec2 audio codec used in this project.
Contributions are welcome! If you find a bug or want to add a new feature, feel free to open an issue or submit a pull request. Please ensure your code adheres to the project's coding standards.
This project is licensed under the MIT License - see the LICENSE file for details.