ESP01 Communication with CASP
This example demonstrates how to establish WiFi communication from host PC to the target board connected with ESP01 WiFi module. We try to acquire analog data from the target board to the host PC through WiFi and plot the data on the host PC. We also try to control the on-board LED present on the target board from the host PC.
Target
Vega Aries v2.0 development board is used in this example. However, any CASP supported boards can be used.
Description
Connect the circuit as shown below. Connect any sensor to the ADC pin A0 of the target board for sensing. We use the on-board LED for controlling.

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 that is connected to the host PC, from the host operating system.
· Run CASP and load the ‘target_model’ project.
· 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.
· The ESP01 block WiFi is set to Access Point mode with SSID: esp01_ssid and SSID Password: 0000000000. User may need to connect the host PC WiFi to this network before continuing.
Following are the steps to run the native model on the native PC
· After successfully establishing WiFi connection with the target from your operating system, load the ‘native_model’ project and open the default workspace file.
· With the target board connected to the host PC, double click on ‘SimPanel IP’ block and change the ‘Remote IP/MAC Address’ to the device IP address if the ESP01 IP is configured to different IP address.

· Click on ‘Connect Device’ button and check the ‘Online Data’ check box. The program should now communicate with the target with cycle time less than 20msecs. Target board is now available as end point ‘EP0’ to the native model. Native model can use this end point to connect to respective IOs on the target.
· Click on ‘Save’ button to save the configuration and close the window.
· Run the model by clicking on the Run button. A simulation panel window should open and communicate with the board.
· Screen shot of the output simulation panel running on host PC is shown below.

References
Please go through our video tutorials, tutorial projects and CASP main documentation for getting started with CASP.