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
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!
If you're comfortable with Python (actually MicroPython, of course...) you can use the WiFI and Bluetooth capabailties of the Raspberry Pi Pico to create all sorts of remote control and communication projects.
If you know Python and html, you might want to use this example to build a project with the user interface of your design.
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.
To send messages between two XRP robots, you use the built-in Bluetooth Low Energy (BLE) capabilities of their onboard Raspberry Pi Pico W. By writing standard MicroPython scripts that utilize the bluetooth library along with XRPLib, one robot can act as the Central (transmitter) to send instructions to another robot acting as the Peripheral (receiver).
You can user for favorite AI tool to help you explore all this.