When we disconnect the XRP from the USB cable to our computer, we lose the ability to communicate with it.
Most robot platforms include some way to wirelessly communicate with a computer, smartphone, remote control device, etc.
The XRP controller includes the Raspberry Pi Pico W microcontroller, which includes hardware support for Bluetooth and WiFi wireless connections.
Review:
Using the Web Server as a Dashboard
(Note that " live-updating" is not yet support in Blockly, but is possible with MicroPython)
You need to connect your smartphone or notebook and our XRP to the same WiFi network.
On your smartphone or notebook, connect to this WiFi network:
SSID: workshop
Password: arduino1
SSID: BTUgoo
Password: blowItUp
SSID: workshop
Password: arduino1
Create the program shown here →
Or download remote_control_hello_world.blocks to your notebook, then in the XRP Code Editor, File ... Upload to XRP
Run the program
You should see some like this in the Shell/console:
Starting DNS Server at 192.168.0.106
Open a web browser window on your smartphone or notebook and go to the IP address shown in the Shell (in this example, http://192.168.0.106)
Click on the right arrow (->) button to turn on the LED.
Click on the stop ([]) button to turn off the LED.
Modify this program and change the code for the web page buttons to do something else.
Ideas:
Move the servo up, move the servo down
Drive forward, stop, turn left, turn right
Convert the Blockly program to Python and control the LED on the Button and LED module
Your ideas?
Review Using the XRP Webserver
With this method, the XRP is the WiFi access point -- it does not connect to a WiFi router.
In the XRP Code Editor, create a new Python program with the following content, replacing <your_name> with your name.
(You won't actually be using "wifi_ssid" and "wifi"password" for this example.)
{
"wifi_ssid": "workshop",
"wifi_password": "arduino1",
"robot_id": "<your_name>",
"ap_ssid": "XRP {robot_id}",
"ap_password": "remote.xrp"
}
Save the file as "secrets.json" at the root folder level. (Note this is not a Python file and does not have the .py filename extension.)
In the XRP Code Editor, open the file XRPExamples ...webserver_example.py and run it.
Notice the following output:
Starting Access Point "XRP <your_name>"
Connect your laptop to the WiFi with the above name. The password is "remote.xrp" as you entered in the secrets.json file.
Note this output:
Starting DNS Server at 192.168.4.1
On your laptop, go to this IP address in your browser.
Control your XRP from a web page!
The XRP webserver code is in:
lib ... XRPLib ... webserver.py
Take a look at this code and consider how you can modify this to:
Change the .html layout (buttons, text, colors, etc.)
Add more controls as you'd like.
You might consider using this as the basis for a web-controlled XRP project!