ZPMMaker
Posts: 26
Joined: Sun Aug 23, 2015 11:04 am
Location: Australia

Running two WiFi adapters on the one Pi

Thu Aug 10, 2017 3:23 am

Howdy,

I'm using a Raspberry Pi Zero Wireless. I need to connect to a camera (which uses an ad hoc wifi network) in order to send the camera commands, and then transfer images from the camera onto the RPi. I then need to connect to a second WiFi network in order to connect to the Internet (so that the image can be uploaded to a server).

I was planning on using the Zero W's internal WiFi adapter to connect to the camera (as it'll be close by) and a USB WiFi adapter with an external aerial to connect to the local WiFi for internet access (as the WiFi router for internet access will be much further away).

An alternative may be to use only the Pi's internal WiFi adapter, and somehow programmatically switch the connection from camera to internet wifi and vice versa as required.

Either way, I have no idea how to do either of these things.

I tried following some websites that explained how to alter the wpa_supplicant.conf or /etc/network/interfaces files, but I ended up just bricking the Pi completely (i.e. after rebooting, it would claim "no wireless interfaces found" - I resolved this by simply reinstalling Raspbian from the disk image).

Unfortunately, there is no other way of connecting to this camera - it's WiFi or not all. Which is a real pain.

So, could someone please explain, either:

A) How to use two WiFi adapters to connect to two separate WiFi networks simultaneously, and how to force a specific adapter to only connect to a specific network (and prevent it from connecting to other networks), or

B) How to programmatically switch one WiFi adapter between networks (preferably in Bash)?


I'd prefer option A, as that would mean the Pi would always be connected to the internet (the Pi and camera system are going to be installed in remote locations and the Pi will be headless, so it's important that it always has internet access so I can SSH into it using Remot3.it if something stuffs up).

Thanks in advance!
Dave

P.S.: I'm not using a Raspberry Pi camera module. This is a third-party camera.

coltreign
Posts: 2
Joined: Thu Aug 10, 2017 5:33 pm

Re: Running two WiFi adapters on the one Pi

Thu Aug 10, 2017 5:53 pm

I don't have experience with the specific application you're referring to, but I've connected to two networks simultaneously using a TP-Link TL-WN821N via USB in addition to the native wifi card or ethernet. You should be able to configure your connections manually via command line. Check out this link https://www.thepolyglotdeveloper.com/20 ... pberry-pi/. As far as programatically switching between networks, I'd consider looking into something like a python script to get that done effectively.

ZPMMaker
Posts: 26
Joined: Sun Aug 23, 2015 11:04 am
Location: Australia

Re: Running two WiFi adapters on the one Pi

Sat Aug 12, 2017 9:11 am

Thanks, but that link is for setting up connections to two separate WiFi networks in case the RPi is moved (e.g. a mobile set-up going from home WiFi to work WiFi). I need to know how to bind them to a specific adapter, and having both adapters connected to their respective WiFi networks, simultaneously.

User avatar
elkberry
Posts: 151
Joined: Wed Dec 28, 2016 9:21 pm

Re: Running two WiFi adapters on the one Pi

Sat Aug 12, 2017 1:36 pm

As you need to/can specify a wpa config file with each network interface, I would imagine that you can use different wpa configuration files for different interfaces, as the parameter to wpa-conf in /etc/network/interfaces. That should allow connecting your two wlan interfaces to different networks. However, I haven't tested that myself, it's just an idea that came to me when reading the question.
From ZX81 to Raspberry Pi, but wait ... where's the 7805 gone?

ZPMMaker
Posts: 26
Joined: Sun Aug 23, 2015 11:04 am
Location: Australia

Re: Running two WiFi adapters on the one Pi

Sun Aug 13, 2017 4:17 am

elkberry wrote:
Sat Aug 12, 2017 1:36 pm
you can use different wpa configuration files for different interfaces, as the parameter to wpa-conf in /etc/network/interfaces.
Yes, that's possible, but after rebooting, I find that both adapters only connect to my internet WiFi network, rather than connecting to the two different networks (i.e. I end up with two simultaneous connections to the Internet WiFi, and the camera WiFi is ignored). So I effectively need a way of saying "wlan0 can only connect to X network, and should never connect to any other network" and "wlan1 can only connect to Y network, and should never connect to any other network".

User avatar
elkberry
Posts: 151
Joined: Wed Dec 28, 2016 9:21 pm

Re: Running two WiFi adapters on the one Pi

Sun Aug 13, 2017 6:52 am

I'm under the impression that you did misunderstood me. I'm not talking about swapping wpa conf files, but using two simultaneously. At the same time, one for wlan0, another for wlan1. As in:

Code: Select all

iface wlan0 inet auto
  wpa-conf /etc/wpa_supplicant/wpa_supplicant_wlan0.conf
 
 iface wlan1 inet auto
  wpa-conf /etc/wpa_supplicant/wpa_supplicant_wlan1.conf
From ZX81 to Raspberry Pi, but wait ... where's the 7805 gone?

ZPMMaker
Posts: 26
Joined: Sun Aug 23, 2015 11:04 am
Location: Australia

Re: Running two WiFi adapters on the one Pi

Sun Aug 13, 2017 9:18 am

elkberry wrote:
Sun Aug 13, 2017 6:52 am
I'm under the impression that you did misunderstood me. I'm not talking about swapping wpa conf files, but using two simultaneously. At the same time, one for wlan0, another for wlan1. As in:

Code: Select all

iface wlan0 inet auto
  wpa-conf /etc/wpa_supplicant/wpa_supplicant_wlan0.conf
 
 iface wlan1 inet auto
  wpa-conf /etc/wpa_supplicant/wpa_supplicant_wlan1.conf
Yes, I had misunderstood. Thanks for clarifying!
I have just tested your idea out and it works perfectly!

Thank you very much for your help. :D

User avatar
elkberry
Posts: 151
Joined: Wed Dec 28, 2016 9:21 pm

Re: Running two WiFi adapters on the one Pi

Sun Aug 13, 2017 11:39 am

Glad to hear that it works. You're welcome!
From ZX81 to Raspberry Pi, but wait ... where's the 7805 gone?

Return to “Advanced users”

Who is online

Users browsing this forum: No registered users and 31 guests