Chris Dzombak

sharing preview • dzombak.com

Reliable WiFi for the Bambu X1C 3D printer

How to set up a Raspberry Pi WiFi access point that the Bambu X1C can stay connected to.

Reliable WiFi for the Bambu X1C 3D printer

The Bambu X1C is a great 3D printer, but it struggles to maintain a WiFi connection in many common environments (an Eero mesh network, for example). You can find numerous complaints and discussions with a quick Web search; I’m not going to link them here.

I ran into this with my printer, and the solution I landed on was using a Raspberry Pi to provide a WiFi network just for the printer, with a specialized combination of settings that seem to improve the printer’s connection stability.

I don’t know exactly what it is about my Eero WiFi network that the Bambu printer can’t deal with, and I didn’t do any scientific one-variable-at-a-time experimentation on this project to narrow it down. I just went through a few iterations of WiFi settings on the Pi, scrolling through the hostapd configuration documentation each time and tweaking anything that felt likely to help.

Additional requirements for this project:

The rest of this post is brief and assumes some familiarity with networking and Linux.

Set up and enable hostapd

sudo apt install hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapd

Setting up the bridge network interface

These bridge network setup steps are confirmed to work on Raspberry Pi OS bullseye, which was the latest version in Sept. 2023 when I started this project.

To set up the bridge network interface, I referred to the official Raspberry Pi configuration documentation. That documentation has since been removed.

Bridge network setup steps might have changed in newer versions of Raspberry Pi OS. The hostapd configuration below should still work as-is.

Full disclosure: I originally planned to just link to the official Raspberry Pi documentation from this post, but since this section has since disappeared from the official docs I have copied this section more-or-less verbatim from the Internet Archive's capture of that documentation as it appeared on Sept. 11, 2023.

Add a bridge network device named br0 by creating the file /etc/systemd/network/bridge-br0.netdev, with the contents below:

[NetDev]
Name=br0
Kind=bridge

To bridge the Ethernet network with the wireless network, first add the built-in Ethernet interface (eth0) as a bridge member. Create /etc/systemd/network/br0-member-eth0.network with the following contents:

[Match]
Name=eth0

[Network]
Bridge=br0

hostapd will add the wireless interface wlan0 to the bridge when the service starts; there is no need to create a file for that interface. This behavior is particular to wireless LAN interfaces.

Now enable the systemd-networkd service to create and populate the bridge when your Raspberry Pi boots:

sudo systemctl enable systemd-networkd

Configure dhcpd to get an address for br0

Network interfaces that are members of a bridge device are never assigned an IP address. The bridge device itself needs an IP address, so that you can reach your Raspberry Pi on the network.

dhcpcd, the Pi’s DHCP client, automatically requests an IP address for every active interface. We need to block it from doing that for eth0 and wlan0, so dhcpcd will configure only br0 via DHCP.

Edit /etc/dhcpcd.conf and add the following line near the very beginning of the file (above the first interface xxxy line, if any):

denyinterfaces wlan0 eth0

At the end of the file, add the following:

interface br0

Ensure WiFi is enabled

In the Raspberry Pi OS, 5 GHz wireless networking is disabled until a WiFi country code has been configured by the user, usually as part of the initial installation process.

To ensure WiFi is not blocked on your Pi, run:

sudo rfkill unblock wlan

This setting will be automatically restored at boot time. We will define an appropriate country code in the access point software configuration, next.

Set up hostapd to provide the WiFi network

Create/edit /etc/hostapd/hostapd.conf by running sudo nano /etc/hostapd/hostapd.conf.

Mine reads like this (with SSID and WPA password changed, of course):

country_code=US
interface=wlan0
bridge=br0
ssid=MyPrinterWifi

channel=7
hw_mode=g
ieee80211n=1
ht_capab=[HT40- HT40+]
wmm_enabled=1
uapsd_advertisement_enabled=0

ap_max_inactivity=3600
disassoc_low_ack=0
max_listen_interval=65535
ap_isolate=0
max_num_sta=2007

macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=MyPrinterWifiPassw0rd
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Note the lines interface=wlan0 and bridge=br0: these direct hostapd to add the wlan0 interface as a bridge member to br0 when the access point starts, completing the bridge between Ethernet and wireless.

Note the line country_code=US: it configures the Pi to use the correct wireless frequencies in the United States. See Wikipedia for a list of two-letter ISO 3166-1 country codes.

Tell the X1C to forget your previous WiFi network(s), and connect it exclusively to this new network (MyPrinterWifi in this example).

Conclusions

This combination of settings seems to allow the Bambu X1C to maintain a stable network connection. As noted, I don’t know exactly which parts of it are truly critical. YMMV.

References