Wi-Fi Accesspoint¶
In order to access the OTCamera Raspberry Pi in field, we will let the Raspberry create it's own Wi-Fi. First, we'll need to install some packages:
sudo apt install hostapd dnsmasq dhcpcd -y
Now we'll need to configure all three of the newly installed packages. Let's start with hostap.
sudo nano /etc/default/hostapd
We need to modify line 13 to specify a valid hostapd.conf
. To do so, insert "/etc/hostapd/hostapd.conf"
right after DAEMON_CONF=
in line 13:
/etc/default/hostapd | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Now let's edit this hostapd.conf file to configure our access point:
/etc/hostapd/hostapd.conf | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
If you are planning to connect OTCamera to your own Wi-Fi (e.g. to transfer files in office or to get internet access to update etc.) you must use the same Wi-Fi channel as your office Wi-Fi network (since the Raspberry has just one antanna). You should edit your office Wi-Fi to always use the same channel to avoid automatic channel selection.
The name of the Wi-Fi is specified just after ssid=
and the password in line 3.
Depending on where you will use OTCamera you should set the according contry code in the last line (for us it's Germany --> DE).
Save and exit the file.
If you will connect to the OTCamera's Wi-Fi your device will need a valid ip address.
dhcpcd and dnsmasq will help us doing by adding some lines (12-14) to the end of /etc/dhcpcd.conf
:
/etc/dhcpcd.conf | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
If your office Wi-Fi uses the same address range you should use another one by, for example, using 51 instead of 50. But you need to remember that address to connect to your OTCamera later on.
Finally, let's configure dnsmasq's config (/etc/dnsmasq.conf
).
It's a quite long file with a lot of explaining comments.
We will backup this template and afterwards create a new, empty config:
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
sudo nano /etc/dnsmasq.conf
Now add the necessary config:
/etc/dnsmasq.conf | |
---|---|
1 2 3 4 5 6 7 |
|
If you chose a different ip address range in /etc/dhcpcd.conf
you'll need to adjust ip addresses here as well.
Puh, this was quite a lot configuration edit stuff... But we are almost ready :)
We don't want the services to start uncoordinated at bootup. So let's unmask hostapd first and then disable all three services to not start up at boot:
systemctl unmask hostapd.service
systemctl disable hostapd.service
systemctl disable dhcpcd.service
systemctl disable dnsmasq.service
We'll use a script instead to start up services. Make sure you are still inside the OTCamera directory.
sudo cp ./raspi-files/usr/local/bin/wifistart /usr/local/bin/wifistart
Last but not least, let's add this script to /etc/rc.local
to start it at boot.
/etc/rc.local | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Yeah, we're done! If you carfully followed this steps and we maintained this manual (...) the Raspberry should still connect to your Wi-Fi and will also create it's own Wi-Fi. It could take a minute or two, so don't worry to early. Let's try:
sudo reboot
All good? We hope so!