LoRa Communication with EByte E32 wireless module using CASP
This example project demonstrates how to establish communication between host PC and a remote micro-controller using two Ebyte E32 wireless serial communication modules at both ends for LoRa wireless data transmission. 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.
Target
Arduino Leonardo is used for this project. However, any micro-controller board supported by CASP can be used in similar manner.
Description
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. Please note that the M0, M1 pins of the E32 module connected to the host PC shall be connected to GND manually to set the module in normal operating mode.

Following are the steps to properly program the 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 ‘e32_target’ project. Open the workspace file ‘e32_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 the EByte E32 block parameters.
· By default E32 module configuration is enabled in the EByte E32 block. This option configures the module with parameter such as module address, serial baud rate, air baud rate, RF channel and RF power output before switching over to normal mode (i.e. data transfer mode). These parameters can be modified as desired from the block parameters. Once the program is executed, these parameters are configured and stored in module’s non-volatile memory, as such module configuration can be disabled during further builds if no more configuration changes are required.
· For Arduino Leonardo ‘Serial1’ is selected in the EBtye E32 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 Hardware 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.
Following are the steps to run the native model on the native PC
· Run another instance of CASP and load the ‘e32_native’ project. Open the workspace file ‘e32_native’.
· From EByte E32 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.
· By default E32 module configuration is enabled in the EByte E32 block for configuring module parameter such as module address, serial baud rate, air baud rate, RF channel and RF power output. These parameters can be modified as desired from the block parameters. During first run keep this option enabled and open the switch SW0 (in above connection diagram). Run the program and wait for 2 minutes for the program to execute and configure the E32 module. Once done these parameters are stored in module’s non-volatile memory, as such module configuration can be disabled during further builds if no configuration changes are required. Also, ensure that switch SW0 is closed to bring the module to normal operating mode (i.e. data transfer mode).
Target and Native models are shown below

Screen shot of the output simulation panel running on host PC is shown below.

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.
References
Please go through our video tutorials, tutorial projects and CASP main documentation for getting started with CASP.