Skip to content

IoT WiFi and AP controller with REST API for Raspberry Pi - Python, Flask, Docker

License

Notifications You must be signed in to change notification settings

Ryazbeck/ygwifi

Repository files navigation

ygwifi


Purpose

Controls managed wifi and AP hotspot separately with a simple API.

Quoting txwifi sums this project up:

This project is intended to aid in developing “configure wifi over wifi” solutions for IOT projects using the Raspberry Pi [Zero W]. The main use case for this project is to reproduce functionality common to devices like Nest or Echo, where the user turns on the device, connects to it and configures it for wifi.

Very similar to txwifi, but you can safely disable the hotspot without interrupting managed.

Tested on a Raspberry Pi Zero W with Hypriot


Why do I need a dongle?

Due to unexpected behavior with Pi Zero W onboard wifi chipset when using both the managed wifi and the ap hotspot. Examples:

  • The hotspot must be enabled before managed or the hotspot won't come up at all
  • The hotspot will drop momentarily when you bring up managed (interrupts captive portal)
  • If you want to disable the hotspot after connecting managed you must turn them both down and turn managed up again.

Not the most elegant solution, but it works. If you know how to fix the unexpected behavior with the onboard chipset please open an issue

It seems that to control dongles from inside a Docker container the drivers must be installed with dkms. I'm not sure why, but if you do please share.

You can find cheap dongles on Ebay and they may require some searching for the driver.

Here's some wifi dongle drivers:

If drivers need a Makefile in /usr/src/<kernel-ver>/arch/armv6l you can link it to the arm folder

You'll need to convert USB to micro if you're using a Zero, here's a few sources:

Or you can use this, which is great for development:


Examples

Enable hotspot:
curl http://localhost:5000/apup
Disable hotspot:
curl http://localhost:5000/apdown
Scan wifi:
curl http://localhost:5000/scan
Authenticate wifi:
curl http://localhost:5000/connect \
   -d '{"ssid":"network", "psk":"password"}' \
   -H "Content-Type: application/json"
Verify internet connection:
curl http://localhost:5000/connected

Run ygwifi

Interacting with either wifi chip from the host machine could interfere with the functionality of ygwifi.

For best results disable host wifi:

sudo systemctl mask wpa_supplicant.service
sudo mv /sbin/wpa_supplicant /sbin/no_wpa_supplicant
sudo pkill wpa_supplicant
sudo ifdown --force wlan0 wlan1

Run ygwifi:

docker run -d --name ygwifi ryazbeck/ygwifi:latest

About

IoT WiFi and AP controller with REST API for Raspberry Pi - Python, Flask, Docker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published