Limit esp8266 AP broadcast range - esp8266

Turned esp8266 as an access point that will be connected by other mobile devices, want to connect only the mobile is very near(2-3 feet) to this access point, used the following code to limit the transmission power. But it is not working
WiFi.softAP(ssid);
WiFi.setOutputPower(-500);
Is there any other way for me to make it work?

you can not use -ve values or not more than +20.5 (max: +20.5dBm min: 0.0dBm)
try this
WiFi.setOutputPower(0.0);

Related

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

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.

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)

How to get the current connection wifi channel (frequency) in iOS?

I want to know how to get WIFI channel and frequency information in iOS.
It would be better not to get from the private APIs (because I need to submit it to the iTunes Store).
There's no way to do this using publicly available APIs, as of iOS 7. The OS algorithm controls networking and decides which channel to use based on congestion, interference, and other factors.
If you're okay with using private APIs, then you can use Stumbler, a library that exposes the data you're interested in: https://code.google.com/p/iphone-wireless/wiki/Stumbler
Warning: If you want to use private APIs, then you won't be able to distribute through the App Store (and you'll have all the other hazards that come with using Apple's private API: the banhammer, breakage at any time, et cetera).
As others noted there is no way to get wi-fi frequency on iOS using official APIs.
There is one work-around to determine whether user is connected to 2.4Ghz or 5Ghz range by actively running a wifi measurement. You can set a limit which will not be realistic on 2.4Ghz (e.g. typically speeds over 100 Mbit on wi-fi are not achievable on 2.4 Ghz).
To run wi-fi measurement its better to run true wi-fi speed measurement and not internet speed measurement as the latter can be slowed down by the ISP (and not the wi-fi).
Here is relevant Stackoverflow comment how to measure wi-fi speed - iOS Get Link Speed (Router Speed Test)
In either way you will not be able to determine actual wifi channel, only whether its 2.4 or 5Ghz. This can be further complicated in the future with 6Ghz ranges where it will not be that easy to split between 5 and 6 Ghz.

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)

How do I accurately target my user's current geolocation on desktop browsers?

The Geolocation API with its getCurrentPosition method works only using WIFI router information and IP addresses. In India where I am, there seems be NO correspondence between IP address and location.
Sometimes it shows I am in Pune - sometimes in Hyderabad - but I am in Mumbai. But When I use the same gMaps application with my mobile devices, it manages to accurately triangulate my position, which is fantastic.
But with the car pooling application I am building I need users to register and inputs their current location automatically using their laptops and desktop computers. How do I do this?
FYI: I am using chrome on Mac OSx
There are essentially four levels of accuracy for geolocation:
GPS, for devices with a GPS receiver
GSM, for mobile devices connected to the mobile phone network
WiFi, for devices within hearing distance of WiFi networks - NB the accuracy is only good if the area has been surveyed, either by the Google streetview vehicles, or by consumers crowdsourcing the information from devices with a real GPS receiver.
IP address - ISPs get allocated a number of blocks, and typically they assign these regionally. In parts of the world where IP ranges are scarce (i.e. not in North America), you can see where the telephone network will connect to different local hubs.
It sounds like it is the last case that you're seeing on your desktop only, which implies the WiFi networks near you haven't been surveyed with enough confidence for the geolocation to work.

Resources