Preparing the computer:
To enable the port for the user to be able to connect through it to the PICO.
sudo usermod -a -G dialout peterm
Next to Download the files for MQTT communication as Per:
https://randomnerdtutorials.com/raspberry-pi-pico-w-mqtt-micropython
Download and configure the files for Network configuration
https://randomnerdtutorials.com/raspberry-pi-pico-w-wi-fi-micropython/
Use the bit about Connecting your Pico board to your Wi-Fi network in writing the software.
Reading inputs:
https://randomnerdtutorials.com/raspberry-pi-pico-outputs-inputs-micropython/
pins 1,2,4,5,9 for inputs pin 1 is GPIO 0, etc.‘button = Pin(21, Pin.IN, Pin.PULL_UP)’ has pull up resistor.
I2C LCD display
https://randomnerdtutorials.com/raspberry-pi-pico-i2c-lcd-display-micropython/
pins 6 SDA GPIO 4
pin 7 SCL GPIO 5
Pin 8 gnd
Ran the I2C test program from randomnerd tutorials start and got this:
I2C SCANNER
i2c devices found: 1
I2C hexadecimal address: 0x27
MicroPython v1.28.0 on 2026-04-06; Raspberry Pi Pico 2 W with RP2350
Type "help()" for more information.
Hint: Change the file name to main.py and reboot the PICO
The Hello World program worked too, though only on two lines.
I will put that into my 1C version and test it again.
Have tested moving text program too.
---------------------
Building the System
---------------------
There are four parts.
1. Driving the display -- Done
2. Input of keypresses via GPIO
3. Wifi link to car
4. MQTT communications.
In this order I think.
So next step is to wire up the switches. All must have pullups so key goes to ground.
Built switches into controller, and it all worked. That’s part B done
Part C: From Randomnerd tutorials set up WiFi.
It connected but assigned a random IP address rather than the one set in the program.
Have set specified IP address. It works.
Now to figure out how to send MQTT data – Part D
Have added appropriate lines from MQTT sample I think.
Error as it cannot find ‘client’
It now seems that when it sends it wants 3 parts to send and I only have two.
When I broke the data into two parts it still didn’t work.
I am looking at what other references suggest for MQTT:
https://www.hivemq.com/blog/iot-reading-sensor-data-raspberry-pi-pico-w-micropython-mqtt-node-red/
2026-6-3
According to Subscriber I am subscribing to topic “rc-car”
In Publisher I have set topic to ‘Move’ or ‘turn’ and I get the error:
"Connection successful!
IP address: 192.168.4.4
Error connecting to MQTT: [Errno 104] ECONNRESET
Traceback (most recent call last):
File "<stdin>", line 132, in <module>
File "<stdin>", line 112, in connect_mqtt
File "umqtt/simple.py", line 73, in connect
File "ssl.py", line 1, in wrap_socket
File "ssl.py", line 1, in wrap_socket
OSError: [Errno 104] ECONNRESET"
I don’t know whether this is an error sending, with the Broker, or with the Subscriber.
Try correcting the Topic by creating in the publisher a variable called p_topic
Same error.
The thing that calls line 112 is:
client = MQTTClient(client_id=MQTT_CLIENT_ID,
server=MQTT_SERVER,
port=MQTT_PORT,
# user=MQTT_USER,
# password=MQTT_PASSWORD,
keepalive=MQTT_KEEPALIVE,
ssl=MQTT_SSL,
ssl_params=MQTT_SSL_PARAMS
)
Which breaks down to:
client = MQTTClient(client_id= rc-car-11,
server=192.168.4.1,
port=1883,
# user=MQTT_USER, [commented out]
# password=MQTT_PASSWORD, [commented out]
keepalive=7200,
ssl= True,
ssl_params='server_hostname': 'raspberrypi'
)
file contains a few items and they are duplicated throughout the program, so I tried changing the
program to just call them there, and that didn’t work: Invalid sysntax on one statement, so now I am
looking into the use of config files in micropython:
https://forums.raspberrypi.com/viewtopic.php?t=340983
https://stackoverflow.com/questions/5055042/whats-the-best-practice-using-a-settings
config-file-in-python – This refers to YAML and JSON and complicated data storage.
https://www.youtube.com/watch?v=g599FlcKgxA
2026-6-6 Lets learn about Micropython
https://www.mclibre.org/descargar/docs/revistas/hackspace-books/hackspace-get-started
-with-micropython-on-pico-01-202101.pdf Pretty good, if simple, for hardware connectivity and
data file stuff. Downloaded.
https://www.raspberrypi.com/documentation/microcontrollers/micropython.html
Look at Wiki and Forums later. From Wiki to ‘discussions’
Https://docs.micropython.org/en/latest/library/rp2.html - Not useful for current problem
AND ABOUT CONFIG FILES:
https://stackoverflow.com/questions/5055042/whats-the-best-practice-using-a-
settingsconfig-file-in-python too complex – discusses YAML and other complicated means.
https://docs.python.org/3/library/configparser.html configparser part of a program.
Took wifi stuff out of config file and put in program. It now connects, but doesn’t like
name ‘Topic’ – not defined.
Used p_topic – it worked for forward.
Check out all other motions.
Used for all. All work well, bit slow to respond. Need better off switch.
Fixed intermittent display, rotated socket on pin to Vsys on board for a better connection.
Have added state flag for turns so that turn button alternates on and off.
---------------------------------------------------------




