CASP supports exchanging data between micro-controller and host computer with very low latency Ethernet or WiFi communication. Data received from the micro-controller can then be used in CASP models on host computer or can be visualized with the help of CASP GUI widgets such as plotters, dials, 2D/3D graphs.

This example project demonstrates how to establish WiFi communication between Arduino Leonard (with ESP01 connected) and the host (native) computer using CASP. 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.

Pre-Requisites

  • Arduino Leonardo (any Arduino board supported by CASP can be used)
  • ESP01 WiFi module
  • 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/7_esp01’. These are also available for download at this link.

Connection Diagram

Following are the steps to properly program the target board

  • Connect the target board (Arduino Leonardo) 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, run CASP and load the ‘native_model’ project. Open the ‘native.wsp’ workspace file and double click on the ‘SimPanel IP’ block and set Remote IP address shown in below figure
  • Run the model by clicking on the Run button. A simulation panel window should start and communicate with the target board.
  • Screen shot of the output simulation panel running on host PC is shown below.