Testing the program

You can compile and upload this project program onto the ESP32 board. Open the serial tool to navigate to your ESP32. You should see the IP address of the ESP32 board here. If you don't see it, please reset your board. Figure 5-11 shows the IP address of my ESP32 board:

Figure 5-11: Program output shows the IP Address of the ESP32 board

For testing, we will use the Postman tool.

  1. You can set the HTTP POST request with the following header:
Content-Type: application/x-www-form-urlencoded
  1. Select the raw option for the request body in the Postman tool. Then, give a value of 1 to the body content, as shown in figure 5-12:

Figure 5-12: Sending HTTP requests using the Postman tool
  1. Click the Send button to execute the HTTP POST request. You can see the ESP32 program output on the serial application, as shown in figure 5-13. Your LED should light up after receiving a value of 1 from the Postman tool:

Figure 5-13: ESP32 program output when turning on the LED
  1. Now you can change the value request, so instead of 1, we input a value of 0 in the Postman tool (see step 2). After doing this, click Send. You should see that your LED turns off at this point. Figure 5-14 shows the program output from ESP32:

Figure 5-14: ESP32 program output when turning off the LED
  1. Finally, you can send any message, except the 1 and 0 values, via the Postman tool. You should see that the ESP32 program shows an unknown command message, as shown in figure 5-15:

Figure 5-15: ESP32 program output when HTTP requests are not 1 or 0

This is the end of the chapter. You can practice further by adding command requests with some sensor and actuator devices.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.216.36