Hacker News new | ask | show | jobs
by albeec13 3188 days ago
I've had a hard time finding resources on getting a Raspberry Pi Zero W to operate simultaneously as and AP and WiFi client. I pooled together whatever resources I found that failed me, but got part of the way there, and figured out the rest on my own. I figured it would be a good thing to share, since there appear to be a lot of people asking how to do it, and not a lot of solutions out there.
1 comments

Great work. Would you provide more details about the requirements that led you to running Wifi as AP and a Client?
Thank you. To be totally honest, I don't have a plan fully fleshed out, but the gist of it is this. I'd like to use a few RPi Zero W's as part of a home automation setup, primarily for either monitoring temperature/motion or for remote switching of lights/powered devices using relays.

One way to allow those devices to communicate with each other is via a central server (which I already have available), but it would also be nice to allow devices to communicate directly to each other in an ad-hoc manner. For example, Amazon dash buttons can be used to run arbitrary scripts from a router using dnsmasq when they connect to their configured access point. With the Raspberry Pi running an AP and dnsmasq, the dash button can directly connect without having to go through the server first. However, having the RPi also connected to the WiFi allows for it to access the internet (say to upload logs of activity, or register it's services to a central IoT server on the LAN or WAN) without requiring me to have to script in tasks to bring the WiFi interface up and down to switch between AP/client modes. This would also mean it would always be available remotely.

One of the downsides of the RPi Zero W is that it doesn't have a wired ethernet interface, so having both a WiFi AP and Client mode running at the same time allows it to have LAN/WAN access, while still being able to directly connect with other devices. The added benefit is that since both interfaces are wireless, it can go almost anywhere within range of WiFi, without cable restrictions.

Finally, having the ability to route traffic through the RPi would mean they could potentially be set up in a daisy-chain manner to extend the range of available WiFi access.