CASP supports exchanging data between micro-controllers using LoRa communication. This example project demonstrates data communication between Arduino and Vega Aries boards via two LoRa Ra-02 SX1278 modules. We try to acquire analog data from the target board to the host PC wireless and plot the data on the host PC. We also try to control the on-board LED and PWM present on the target board from the host PC. Since the Ra-02 module supports only SPI communication, an intermediate micro-controller is required between host PC and Ra-02 module at the host PC end.
Pre-Requisites
- Aries Vega v3.0 development board is used as the remote micro-controller board connected to Ra-02 module.
- Arduino Nano is used as the intermediate micro-controller between the host PC and the second Ra-02 module. These micro-controller boards can be replaced with any other micro-controller board supported by CASP and can be used in similar manner.
- Ra-02 SX1278 modules – 2 No.
- CASP software is installed along with CASP Python Libraries (optional).
- Arduino BSP is installed.
- The project files are located at CASP installed directory ‘CASP/support/examples/communication/14_lora_sx127x’. These are also available for download at this link.
Connection Diagram
Connect the circuit as shown below. Connect any sensor to the ADC pin A0 and A1 of the Vega Aries board for sensing. We use the on-board LED at pin GPIO22 and PWM0 for controlling. Data from the host PC is transferred to Arduino Nano through serial communication and from Arduino Nano to Vega Aries through the wireless communication.

CASP Model for Vega Aries Board

- Connect the target to the host PC via a USB cable.
- Note the serial port number to which the board is connected to the host PC, from the host operating system.
- Run CASP and load the ‘sx127x_target_vega’ project. Open the workspace file ‘sx127x_target_vega.wsp’ from CASP main window.
- All blocks are pre-configured for proper functioning. However, user may change the configuration of any block as required. By default data encryption is disabled user may enable the same in the SX127x block parameters.
- For Aries Vega, SPI1 is selected for SPI communication. Choose suitable SPI interface if other micro-controller targets are used.
- Open Home->Simulation->Setup Simulation Parameters menu item. Under TargetHW->General tabs set ‘Target Programmer Port’ parameter to the serial port to which the board is connected.
- Build the model and program the board by clicking on Run button.
CASP Model for Arduino Nano Board

- Connect the target to the host PC via a USB cable.
- Note the serial port number to which the board is connected to the host PC, from the host operating system.
- Run another instance of CASP and load the ‘sx127x_target_nano’ project. Open the workspace file ‘sx127x_target_nano.wsp’ from CASP main window.
- All blocks are pre-configured for proper functioning. However, user may change the configuration of any block as required. By default data encryption is disabled user may enable the same in the SX127x block parameters.
- Open Home->Simulation->Setup Simulation Parameters menu item. Under TargetHW->General tabs set ‘Target Programmer Port’ parameter to the serial port to which the board is connected.
- Build the model and program the board by clicking on Run button.
CASP Model for Host Computer

- Run another instance of CASP and load the ‘sx127x_native’ project. Open the workspace file ‘sx127x_native.wsp’.
- From ‘Serial’ block parameters enter the serial port to which the Arduino Nano is connected to the PC.
- · Click on Run button to build and run the model.
Debugging
Serial debugging can be enabled by selecting ‘Local & Remote‘ option from Setup Simulation->Build->Code Debug and re-building the project. The output can be viewed in ‘Serial Monitor’ window from CASP main window.
