How can I specify the WiFi channel when using Raspberry Pi Pico was an access point? - wifi

I'm developing a device which needs to provide a WiFi connection to display some data on a web page. This will be in access point mode, not connected to an existing network. I want to select a specific WiFi channel to see if it helps with range during testing. When I try to set a channel number it is ignored, and apconfig('channel') always returns channel 6.
Test code:
import network #importing network
# Work as a web server and WiFi access point
ssid = 'RPI_PICO_AP' #Set access point name
password = 'somepassword' #Set your access point password
ap = network.WLAN(network.AP_IF)
ap.config(essid=ssid, password=password, channel=11)
ap.active(True)
ap.config(channel=11)
while ap.active() == False:
pass
print('Access point is available')
print(ap.ifconfig())
print('Channel: ', end='')
print(ap.config('channel'))
I expected that this would set the channel to 11 and display 11 in the last line.
Output:
Access point is available
('192.168.4.1', '255.255.255.0', '192.168.4.1', '75.75.75.75')
Channel: 6
As you can see, this version of the code tries to set the channel to 11 in two places. Either one alone gives the same result. The example shows channel 11, but I tried 1, 7, and others. The result is always 6.
My phone connects correctly on channel 6 and can interact with the Pico. I would just like to try avoiding some channel congestion on channel 6 to see what happens.
Background:
I am developing a device which will provide a local web server to access temperatures measured by the device and to change certain settings. It's basically a 4-channel programmable thermostat, but used for coral research. It will be used both in busy labs with lots of WiFi activity and in remote places with no internet access.
An Arduino Mega version without WiFi is already deployed in several labs, but we are up against memory limits there. I hope that the Pico W will let us add WiFi and also have enough memory to add some minor features to the device.

Related

How do wifi bulbs pair with the mobile

I have been working on making a commercial-equivalent smart WiFi bulb. I cannot understand how the bulb pairs with the app on smartphone and gains access to the Internet through my personal modem. The bulb cannot communicate through the personal WiFi before getting paired, as it doesn't have the credentials. I tried to experiment with my existing commercial bulb and while putting it in reset mode, noticed -
There wasn't any WiFi (that could be the bulb's AP) visible in the available networks list of my PC. Well, I don't know if it was a hidden network.
There wasn't any Bluetooth device visible in the list that could possibly be the bulb.
So I want to know how the bulb communicates with the app -
Does it act as AP (Access Point) and the app connects to it and gives it the credentials.
Else, does the bulb use any other type of communication to pair with the app.
Or, does it somehow just get to the smartphone and it all "mysteriously" works.
I would be happy if someone could explain the process to me. Also, the app scans for the available devices whenever I want to pair to a new device. Then, I can select the desired device and pair it. So, please also explain (if possible) how the scanning works.
No need to get to each technical detail, I just want to know the process. I will ask later if I need the tech details.

Is there a way to communicate with smartphone remotely via a sensor without using internet?

I want to detect and send/recieve data from a smartphone in some vicinity without using internet.
I've always thought it would be fun to do this with audio. Most modern ways of modulating a signal (like OFDM) will sound like a white noise hiss over audio, and you should be able to get a few KB/s in a normal room environment if the phones are close to each other.
It also has the benefit that the user can always tell when it's transmitting.
Multiple methods are possible.
You could use a private (isolated) local area network that is not connected to the internet. Either ethernet cabled or over WiFi.
Airdrop might not require an internet connection (a WAN connected access point).
Bluetooth BLE communication doesn't require an internet connection. You could use an ESP32 or Raspberry Pi to read sensor data and have a mobile device connect over BLE to the ESP32 or Pi (or another mobile device).
You could use audio. Play FSK tones or Morse Code on one device and receive and decode the audio modulations on another device. (I've tried both of these methods successfully.) Or you could use a speech synthesizer on one device and a voice transcription app on another.
You could use light. Flash the flashlight (or LED) on one device, and receive and decode the light pulse sequences using the video camera another device. (There may be apps in the App store that can do this.) Or display a bar code or QR code on one device and use the camera on another to decode the data in the bar code or QR code.
You could use MIDI. Bluetooth MIDI over BLE from device to device. Or with MIDI cables, using a bunch of Lightning to USB and USB to Midi adapters.
You might be able to use vibrations from the Taptic engine on one device, and detect the vibration sequences using the motion sensor API on another device.
With many Android devices, you can connect a USB to serial port dongle, and use a long RS232 serial cable between devices.
With an iPhone, you could use a Lightning to Ethernet adapter, plus a fiber optic media converter, and send signals over several kilometers of (private) fiber optic cabling. etc.
You might want to use the IR sensor on your phone by using an IR sensor library. (Search it on a search engine). If the does not have that, you can use a QR code generator library (Search it on a search engine) to transfer your data.
You could use a raspberry pi (for example) to take readings from your sensor and store them. Make it run a webserver and create its own wifi network (not connected to the www) where you can access a webpage that displays the readings. Or you can set it up so that the Pi logs into the wifi hotspot from your phone whenever available and then uploads the data or sends it in an email or whatever.
You can use an internet module, for example the FONA 800 or 808 by Adafruit to let your Pi talk with the internet, via a SIM card from hologram.io for example. The Pi can talk to the FONA in Python. But to be honest that doens't really answer your question with the proximity thing - but if I were you I would drop that and do the following:
Read the data from the sensor and save it to a csv file on the Pi
Once every hour (or whatever), connect to the internet via FONA/hologram.io SIM
Insert the data from the previous hour to a remote mysql database
Use PHP or something to display the data from the database nicely and access via your phone
That way, you can have as many sensors as you want and access all from your phone. As I said the proximity thing is not relevant for me, it's easier imho to go through cellular (+ I wouldnt know how to do it over lets say bluetooth)

Wifi diagnostic tool

I am working on a room which contains 6 wifi IP cameras. There are also the same wifi IP cameras in other close rooms. This cameras have their own wifi access point. I can't manage anything on this wifi network.
I have a raspberry Model 3 in this room. I tried to set up a wifi access point on this raspberry.
I can't connect to this access point, but if in unplug everything and go to try far away from this rooms, everything works great.
So i am wondering if the raspberry is not disturbed by this big wifi traffic.
What should i do ?
Here is an extract of my /etc/hostapd/hostapd.conf
Do you see something i can change in order to make it work ?
interface=wlan0
driver=nl80211
ssid=XXXX
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_passphrase=XXXXXXX
rsn_pairwise=CCMP
Thanks
Try changing the channel=6 to channel=1 in your config file. This should help if the wifi cameras are using channel 6 as well.
https://www.lifewire.com/best-wifi-channels-for-your-network-818278
If you have an Android phone handy you could try installing a WiFi Analyzer app, e.g. this one or else you may be able to use iw on the Raspberry PI to do a local scan:
iw dev wlan0 scan
Either/both of the above should show you which channels are being used within range. Then, as Gilbert says you could change the config to use a less congested channel.
I use a modification of the above command to give me a count of access points against each channel:
iw dev wlan0 scan | grep 'primary channel' | sort | uniq -c

Internet access between WiFi-IoT in Access Point mode with mobile phone connected

I did a lot of brain-storming about this, and couldn't reach a solution.
I am posting this as i can get some ideas.
I have developed a WiFi-IoT based device with sensor, which shows up in AP mode. A mobile phone connects to this AP and then the device starts sending sensor data to the mobile phone. A mobile application plots and displays this data.
Now, i want to send this data from mobile to internet. Connecting my mobile to another AP with internet is not an option, as i don't want to break the continuous data transmission.
Using internet of data provider is one option, but that brings constraint of have mobile data.
What other options do i have to send my data from mobile to internet ??
Edit:-
I worked on the suggestions, and came to this point:-
1) WiFi-IoT device (in station mode) and mobile phone connect to same Internet-enabled WiFi access point. WiFi-IoT device has the IP address of the mobile phone for current network, and sends data to a TCP port (eg. 9801) of this IP address. The application in mobile phone reads the data from the port no. 9801 and stores it and hosts it on the internet.
This works fine.
2)WiFi-IoT device comes up in Access Point mode, and the mobile phone connects to this Access Point. Now there is one-to-one connection between WiFi-IoT device and mobile phone.
My question is, in the second scenario, without breaking this one-to-one connection, is there way to host data to internet:-
1) without using mobile internet provided by mobile data service provider ?
2) without using a second mobile phone ?
I may be wrong, but i am just asking this to make be sure whether my requirement can be achieved or not !!
I don't think you can connect to two APs at the same time.
Maybe use Bluetooth as device to phone link?
Or have the device connect directly to internet after some config done in AP mode and then send a copy of the data to your phone app (either via WAN or locally to the private IP your phone gets from the Internet gateway AP)?
--Edit--
Let me explain about the second one:
What I mean is basically have your IoT device directly connect to Internet and send data to a server (your phone has also to be connected to Internet). Then make the server send a data copy back to your phone. It's two step process: 1) while the IoT device is in AP mode, use your phone to login and configure which Internet-connected AP it should be connected to. This serves as UI for your IoT device. 2) start sending data.
Or a bit ugly, just let the IoT device talk to your phone in the same WiFi network via private IP.
I brought up this way because you mentioned anyway your device has to send data to Internet(I assume it's a server) and have phone talk to a known location server is more portable and scalable once you have more than one IoT device.
--Further Edit--
I don't think there is a way to do what you described. At least from my experience:
1) on the link layer, the wireless NIC has to be able to connect to two APs at the same time. This is not a feature currently available.
2) on the network layer, there has to be two IP address attached to the same NIC, which I don't think is available in current OS for wireless NICs. Though there is a way to do this for Ethernet card, I.e. via Aliasing.

Access 30-Pin connector with code

I am trying to set one pin of the old iPhone 30-Pin Connect from low to high so the best would be from 0V to 3,3V. Is that possible with a simple PodBreakout board like this?
https://www.sparkfun.com/products/8295
If not can you send a constant voltage out of the iPhones audio jack (This could be a good method too, cause now apple used its 9-Pin Lightning Connector).
I already searched the web, some say you have to jailbreak your iDevice, some say you need an authentication Chip, and some say it works flawlessly without an authentication chip, but I cant find any help online.
Thanks
You can't "send a constant voltage" out of the audio jack. There is a series capacitor there that filters out DC and very low frequency signal components.
To get proper help on this you can apply for the MFi program. I think it's free for educational purposes. It's under 100$ for sure. There is an NDA involved.
If you want to avoid the MFi you can always use BLE to communicate with periphery.
Or try to implement software FSK (or DTMF) modem on one side and a hardware one on the other side (using the audio lines).
Since it seems you simply want so see a binary (on/off) signal - you could generate a fixed pitch tone in the app (2kHz for example) and use a narrow-band filter on the hardware side (audio-jack connection).
Or maybe (to make sure your app is present on the other side a 2kHz tone would mean 0 and a 4kHz tone could stand for 1.
The authentication chip (and an MFi license)) you are talking about is needed when you try to communicate with the iOs device:
via BT (excluding BLE)
via USB (30 pin connector or lighting connector)
via UART (30 pin connector or lighting connector)

Resources