I have got my program running. YEAH! Here is what I have discovered about config files. Even though a .py suffix indicates that the file is a program, the config file must be called config.py.
In a config file - simply, you have a number of terms. They are of the form 'name = value' as shown here: mqtt_server = b'192.168.4.1' mqtt_port = 1883 They can be done in more complicated ways using JSON and YAML, and subsetting them, but I am not into this for my program. When they are used in a program, they are called as config.name so - config.mqtt_server Terms in the config file cannot be used in function defs that you set up at the start of your program. It doesn't like them. So I had to put things like the wifi parameters in the initialization section of the program for the def initialize_wifi(wifi_ssid, wifi_password): This means that for a Micropython program you either have values in both the config file and the program itself, or dispense with the config file. I am not sure of the reason for the 'b' in the term. Does it mean read as binary? I hope that this helps someone. At least I have documented it for myself. Peter On 04/06/2026 18:00, Peter Merchant wrote:
Hi, Does anybody have any knowledge of using config files with Micropython and could give me a reference to learn more. My current error is in the line: def initialize_wifi(config.wifi_ssid, config.wifi_password): I am not sure that I can do this. Thanks, Peter M.
-- Next meeting: Online, Jitsi, Tuesday, 2026-07-07 20:00 Check to whom you are replying Meetings, mailing list, IRC, ... https://dorset.lug.org.uk New thread, don't hijack: mailto:[email protected]

