Hello,
I'm looking at the best way to do enable my pi zero to connect to a new wifi in order to access to internet (without direct keyboard/screen/mouse linked to the pi).
I'm not sure of the method to make the wifi configuration as easy as possible so that the pi can easily connect to a new wifi (unknown).
I was thinking of doing a solution like this:
1. By default, pi is acting like an Access Point on a defined ssid
2. Software/admin connects to the wifi of the pi and registers the details of the new wifi (with internet access) (through a site, app..)
3. pi receives a request and executes a script to update the wifi configuration file with the new details
3. if wifi connection is OK then it stops to act as an access point and is now connected to internet
What do you think? Do you see any other solution? Is there already some implementation of that?
Thanks.
Re: Automating wifi configuration
Use ssh? Connect to a known network (maybe use your mobile phones mobile data to tether) and just install connect bot or something, set up a static ip (search Google on how to do that) and now you have the same ip so connectbot will work. For example, I have 192.168.1.77 so I can just leave it from the first connect instead of looking at ip addresses etc.
Raspberry pi 3 set up as desktop with raspbian.
I guess you can say I am not newbie with linux but I am not a master at it either.
I will always try to help you as much as I can because I know how hard it is to run into problems
I guess you can say I am not newbie with linux but I am not a master at it either.
I will always try to help you as much as I can because I know how hard it is to run into problems

Re: Automating wifi configuration
Thanks for your feedback.
I'm not sure how this is solving my issue, as the question is about how to connect to a known network..
Maybe better summarized:
1) I know a wifi connection (ssid/pass)
2) I don't want to connect to the pi directly (so I don't want to use keyboard, mouse, screen on the pi)
3) It is a pi zero with wifi adapter (so no ethernet)
=> Is there a way to set up the wifi of the pi with another computer, app, .. ? connect with usb on the pi? setup the pi as access point to be able to connect to it from another computer?
I'm not sure how this is solving my issue, as the question is about how to connect to a known network..
Maybe better summarized:
1) I know a wifi connection (ssid/pass)
2) I don't want to connect to the pi directly (so I don't want to use keyboard, mouse, screen on the pi)
3) It is a pi zero with wifi adapter (so no ethernet)
=> Is there a way to set up the wifi of the pi with another computer, app, .. ? connect with usb on the pi? setup the pi as access point to be able to connect to it from another computer?
- davidcoton
- Posts: 5834
- Joined: Mon Sep 01, 2014 2:37 pm
- Location: Cambridge, UK
- Contact: Website
Re: Automating wifi configuration
You are correct, a static IP is not helpful and can cause further problems unless the address is reserved on any network you might use.hertohe wrote:I'm not sure how this is solving my issue, as the question is about how to connect to a known network..
If you can edit the correct file on the SDCard, you can set the network up. Doing that requires a system that can read/write the SDCard and has a screen and keyboard. So, you can:hertohe wrote:=> Is there a way to set up the wifi of the pi with another computer, app, .. ? connect with usb on the pi? setup the pi as access point to be able to connect to it from another computer?
1) Connect a keyboard and screen to the Pi0 just for initial setuip
2) Use a card reader on another Linux system
3) Use Ethernet to connect via ssh -- but not on a Pi0
There is meant to be a way to put the network details on a file in /boot (which can be accessed with a cardreader on a Win PC), but AFAIK there are still problems with that method (aka, it doesn't work).
For the details of what to change, see this topic.
Location: 345th cell on the right of the 210th row of L2 cache
Re: Automating wifi configuration
Use your phone as a wifi hotspot.
As long as the Pi knows your SSID and password, it will connect to the phone.
Then you can use Juice SSH , or another app to edit wpa_supplicant.conf on the Pi, append the credentials of the network you are visiting.
Turn off the phone hotspot, the Pi will connect to the new network (hopefully!).
As long as the Pi knows your SSID and password, it will connect to the phone.
Then you can use Juice SSH , or another app to edit wpa_supplicant.conf on the Pi, append the credentials of the network you are visiting.
Turn off the phone hotspot, the Pi will connect to the new network (hopefully!).
- HawaiianPi
- Posts: 6212
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: Automating wifi configuration
There is a file called wpa_supplicant.conf that contains the WiFi network info. If you set that file up in advance, you can boot the Pi headless and it will connect, then you can SSH in using the Pi's hostname.
The full path the file is:Which is located on a Linux ext4 partition on the Raspbian SD card.
Unfortunately, neither Windows or Mac OS can read/write ext4 natively. You could use another Raspberry Pi, or any computer running Linux. Most Linux distributions have a "Live" version that can run off of a USB flash drive without making any permanent changes to the host computer.
If you are using the full version of Raspbian Jessie you can copy the wpa_supplicant.conf file to the /boot partition (the only partition visible to Windows) and it will be moved to the correct location when Raspbian boots (does not work with Jessie-Lite).
/etc/wpa_supplicant/wpa_supplicant.conf should look like this:The Pi should automatically connect to any network you add to this file.
Hope that's what you were looking for.
The full path the file is:
Code: Select all
/etc/wpa_supplicant/wpa_supplicant.conf
Unfortunately, neither Windows or Mac OS can read/write ext4 natively. You could use another Raspberry Pi, or any computer running Linux. Most Linux distributions have a "Live" version that can run off of a USB flash drive without making any permanent changes to the host computer.
If you are using the full version of Raspbian Jessie you can copy the wpa_supplicant.conf file to the /boot partition (the only partition visible to Windows) and it will be moved to the correct location when Raspbian boots (does not work with Jessie-Lite).
/etc/wpa_supplicant/wpa_supplicant.conf should look like this:
Code: Select all
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="network1-service-set-identifier"
psk="network1-WPA-security-key"
key_mgmt=WPA-PSK
}
network={
ssid="network2-service-set-identifier"
psk="network2-WPA-security-key"
key_mgmt=WPA-PSK
}
Hope that's what you were looking for.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?
lots of pop-ups...and where is that annoying music coming from?
Re: Automating wifi configuration
Hey,
thanks for your replies. I know about that file wpa_supplicant.conf, but my idea was to avoid having to use it directly.
I want to offer the pi as an IoT device to people.. so I want to allow the "clients" to easily configure their IoT device for the internet...
And having to configure a file on sd card is not really user friendely :p
Any other idea?
Thanks.
thanks for your replies. I know about that file wpa_supplicant.conf, but my idea was to avoid having to use it directly.
I want to offer the pi as an IoT device to people.. so I want to allow the "clients" to easily configure their IoT device for the internet...
And having to configure a file on sd card is not really user friendely :p
Any other idea?
Thanks.
Re: Automating wifi configuration
How about this then?
Write a script which runs when the Pi is booted.
It looks for a USB flash drive with a file on it called "wifi.txt"
If the file contains a single line containing an SSID and a password,
and it can see an access point matching the SSID,
then
Either add or edit the relevant stanza in /etc/wpa_supplicant/wpa_supplicant.conf
Delete the file from the USB stick
Reboot.
fi
Write a script which runs when the Pi is booted.
It looks for a USB flash drive with a file on it called "wifi.txt"
If the file contains a single line containing an SSID and a password,
and it can see an access point matching the SSID,
then
Either add or edit the relevant stanza in /etc/wpa_supplicant/wpa_supplicant.conf
Delete the file from the USB stick
Reboot.
fi
Re: Automating wifi configuration
Yep, that's not a bad idea indeed!
Is there a way to connect pi to another windows/mac computer and to modify files inside it? It's pi zero..
Kind regards,
Henry
Is there a way to connect pi to another windows/mac computer and to modify files inside it? It's pi zero..
Kind regards,
Henry
Re: Automating wifi configuration
Not sure why you'd need this to be done? You didn't want that as a requirement before (using SSH).hertohe wrote: Is there a way to connect pi to another windows/mac computer and to modify files inside it? It's pi zero..
You can setup the the SD image before handing over the Pi - make sure it has a uDev rule that mounts a USB drive
automatically, looks for a specific config file, loads the SSID/pwd combination, restarts wifi, and dismounts the USB drive
I've written up a process something similar that describes the uDev rule and running a script to load config file.
You could modify it for WiFi setup
edit: it's on the CodeReview site at stackoverflow
http://codereview.stackexchange.com/que ... tomounting
Re: Automating wifi configuration
Your original idea is exactly what I'm looking for. Have you worked out a way to implement it in the meantime?
TIA, Beat
TIA, Beat
-
- Posts: 2
- Joined: Sun Feb 17, 2019 3:22 pm
Re: Automating wifi configuration
Also Note: Raspberry Pi Zero WH does not support 5G wireless networks, so if you try that it just won't work.
Full tutorial of setting this up is here: https://www.youtube.com/watch?v=3VO4vGlQ1pg
Full tutorial of setting this up is here: https://www.youtube.com/watch?v=3VO4vGlQ1pg