motioneye-project / motioneyeos

A Video Surveillance OS For Single-board Computers
Other
7.85k stars 897 forks source link

Button on GPIO to turn ON/OFF wifi (for Access Point conf) #2946

Open BirdiPiduino opened 1 year ago

BirdiPiduino commented 1 year ago

Preliminary Docs

I confirm that I have read the CONTRIBUTING guide before opening this issue.

I confirm that I have read the FAQ before opening this issue.

motionEyeOS Version

I am running motionEyeOS version: 20200606.

Board Model

I am using the following board/model: Raspberry Pi Zero W But for some tests, I use a Raspberry Pi 3 for the ethernet and usb ports (keyboard and network)

Network Connection

My motionEyeOS unit is not connected to the network but it use is own Access Point IP adress : 192.168.42.1

Peripherals

Button on GPIO Led indicator on GPIO

RTC DS1307 (because of isolated situation in Access Point)

Improvement needed

In a configuration using the Access Point, make it possible to turn ON or OFF the WiFi. This function will be very useful for use in an isolated situation (no power -> use batteries, no network). It will offer more autonomy because it decrease the need of energy.

It is then possible to use an external button on the GPIO to activate the WiFi and a led on the GPIO to indicate that the WiFi is active. WiFi should turn on at boot. Turn OFF the WiFi can be automatically with a timer. Re-turn ON the wifi or re-init the timer can be done by pressing the button.

I wrote the script (attached) for manage the button and the led, but it miss the commands for the WiFi. What would be the command lines to enable/disable WiFi ?

It will better if it avoid to reboot when the wifi turn on or turn off.

Example of the utility of this issue : With motionEyeOs, I built a standalone camera-trap to study wilds birds at nest. It use batteries, USB storage, Wifi Access Point and Real Time Clock for date/time because it's in an isolated situation. There is a success. And now, i try to decrease the consumption of energy. That is what, stop the wifi when I don't use it, could be a way. I actually need the Wifi just 5 min every 4 days to check every things.

To test the script attached, copy it in /data/etc/ simulation_WiFi_button.zip

To use the complete config use it : motioneye-config.tar.gz SSID : Button_Wifi_AP || Pass : WIFI2022 IP adress : 192.168.42.1 Hostname : Button_Wifi || user admin || no password Raspberry Pi Zero W

20221007_095455

starbasessd commented 1 year ago

If you are waiting for me to come up with something, you are going to be waiting quite a while, sorry. You've gone a long way to create your own solution, and I appreciate your efforts. Thank you.