So far we've sort of built this template for the Pico to host a web page over either an existing network or with its own Wi-Fi access point. In this video, we'll start to add some more complex functionality to that page and reinforce the idea between serving a web page and handling the request on the Pico. We'll also look at how we can use large language models to help with this process to develop the code for it. If you don't already have the code we've been making, you can find the template on our course page and what we'll build in this video as well.
Let's start by sending more data to our web page. We've just been sending the state of a button, but let's read an actual sensor and put that data on the web page. We're going to use the inbuilt Pico's temperature sensor, which is actually ADC4. To start off, let's import ADC because we are going to need it and then set up an instance of our temperature sensor, which is ADC4. I'm going to paste in this function that takes the reading from the ADC and turns it into an actual temperature in Celsius.
Now that we've got the hardware set up and a way to read the temperature, there are two sections we need to focus on. The first is changing the web page to display the data we're reading or adding another button or element to take in an input. The second is changing the while true loop to handle new requests and update the data sent to the web page. We'll update the page to display the temperature by feeding it into our web page function. We'll also add an input element, a slider, to set a PWM on one of the Pico's pins.
We'll break down the request into two parts, the path, and the parameters, to handle different functionalities more efficiently. By using LLMS like ChatGPT, we can enhance our web page code and fix technical issues. This newfound knowledge opens up possibilities to create remote-controlled devices, monitor sensors wirelessly, or control household items through a web interface. Serving web pages adds functionality to projects, and the potential applications are vast. Additionally, exploring IoT platforms and protocols like MQTT can further expand the capabilities of the Pico.
Makers love reviews as much as you do, please follow this link to review the products you have purchased.