



Time.sleep() is very dangerous when used with eel fortunately we have been given an alternative. When clicked, this will call the getTime() function in python and then return the value back to JavaScript on the line let value = await eel.getTime()(). When running server.py, a chrome app window will appear with a button saying "Click to get time". expose ( my_javascript_function ) function my_javascript_function ( a, b ) Click to get time If not, press CTRL + C, then CTRL+D to restart the code.Eel.

You should see the temperature data scroll across the screen. Open Beagle Term and connect to your Raspberry Pi Pico. Save the project to code.py on your CIRCUITPY drive.ġ4. Use the print function along with the text format to insert the temperature data into the gap. Create an object, text and in there store a string which will print “The temperature is Celsius”. Store the current temperature in a variable called temp. Create an object, dht to connect the code to the DHT22 sensor connected to GP15 on the Raspberry Pi Pico. Import three modules to enable our code to access the GPIO (board), use the temperature sensor(adafruit_dht) and to control the speed of the loop (time). Open code.py on your Raspberry Pi Pico using the Caret text editor. CircuitPython will automatically run the code each time we save. This gives us a second to read the Hello World message. It is a simple means that we can use to confirm that we have control of and communication with a device. This is a classic example of testing code. Do not mix tabs and spaces as Python will throw an error. Note that the code is indented by one TAB keypress or four spaces. Use a print function to print “Hello World”. Create a while True loop to continually run the code within. We will use this to control the speed at which our code loops. This drive is your Raspberry Pi Pico running CircuitPython.Ĥ. Click on File > Open and select code.py found on your CIRCUITPY drive.
