CASP supports exchanging data between micro-controllers using LoRa communication. This example project demonstrates data communication between host PC and Arduino board via two LoRa HC-12 modules. We try to acquire analog data from the target board to the host PC through HC-12 wireless communication 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.
Pre-Requisites
- Arduino Leonardo or any three micro-controller boards supported by CASP with serial interface.
- HC-12 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/12_lora_hc12’. 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 target board for sensing. We use the on-board LED at pin-13 and PWM at pin-3 for controlling.

CASP Model for Target 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 ‘hc12_target’ project. Open the workspace file ‘hc12_target’.
- 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 HC-12 block parameters.
- For Arduino Leonardo ‘Serial1’ is selected in the HC-12 block as the serial interface for communicating with the module. Choose suitable serial 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 Host Computer

- Run another instance of CASP and load the ‘hc12_native’ project. Open the workspace file ‘hc12_native’.
- From HC-12 block parameters enter the serial port to which the FTDI module is connected to the PC.
- Click on Run button to build and run the model. Both devices should now communicate through HC-12 wireless communication.
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.