ESP8266 WiFi signal strength - wifi

how to use AT+CWLAP in esp8266 to get wifi signal strength? I want to get the signal strength which is displayed on the serial monitor and use it in my code in arduino IDE!

After sending the AT+CWLAP command, ESP8266 will answer with a list of all available AP's detected.
The format of the response will be like:
+CWLAP:<ecn>,<ssid>,<rssi>,<mac>,<freq offset,<freq calibration>
where:
<ecn>: indicates the security level, from 0 (OPEN) to 4 (Maximum security level)
<ssid>: it's the ssid of the AP
<rssi>: it's the signal strength, which is indicated in decibel format (e.g. -70)
<mac>: it's the MAC address
<ch>: channel
<freq offset>: ut's the frequency offset of AP,unit:KHz.
<freq calibration>: it's the calibration for frequency offset
So, the <rssi> parameter is what you are interested in.
Maybe, depending on the firmware version of your ESP8266, it's possible that AT+CWLAP command returns a different number of parameters, omitting, for example, the last four.

Related

How can i tell if a peripheral is connected to GPIO?

I want to be able to detect when a peripheral sensor is NOT connected to my Raspberry Pi 3.
For example, if I have a GPIO passive infrared sensor.
I can get all the GPIO ports like this:
PeripheralManagerService manager = new PeripheralManagerService();
List<String> portList = manager.getGpioList();
if (portList.isEmpty()) {
Log.i(TAG, "No GPIO port available on this device.");
} else {
Log.i(TAG, "List of available ports: " + portList);
}
Then I can connect to a port like this:
try {
Gpio pir = new PeripheralManagerService().openGpio("BCM4")
} catch (IOException e) {
// not thrown in the case of an empty pin
}
However even if the pin is empty I can still connect to it (which technically makes sense, as gpio is just binary on or off). There doesn't seem to be any api, and I can't legitimately think of logically how you can differentiate between a pin that has a peripheral sensor connected and one that is "empty".
Therefore at the moment, there is no way for me to assert programmatically that my sensors and circuit is setup correctly.
Any one have any ideas? Is it even possible from a electronics point of view?
Reference docs:
https://developer.android.com/things/sdk/pio/gpio.html
There are lots of ways to do "presence detection" electrically, but nothing that you will find intrinsically in the SoC. You wouldn’t normally ask a GPIO pin if something is attached—it would have no way to tell you that.
Extra GPIO pins are often used to detect if a peripheral is attached to a connector. The plug for some sensor could include a “detect” line that is shorted to ground and pulls the GPIO low when the sensor is attached, for example. USB and SDIO do something similar with some dedicated circuitry in the interface.
You could also build more elaborate detection circuits using things like current sensing, but they would inevitably have to put out a binary signal that you capture through a dedicated GPIO.
This is easier to achieve for serial peripherals, since you can usually send a basic command and verify that you get a response.
Detection using solely the input line can be tough. First, you'd want to narrow the scope of the problem. Treat as not-present the condition of a sensor not being connected, the sensor being connected but not responding, or the sensor responding in an uncharacteristic manner.
So, if it is a digital sensor, then communicating with the sensor may be enough to tell if it is present or not (especially if checksums or parity bits are involved).
Some analog sensors also have specific specs on how it behaves when triggered. You can utilize deviation from those specs to determine if the sensor is not present.
If you have a digital sensor w/o any error checking on it's output, where you clock out data (so all 0s or all 1s is valid) or it's just a binary 1 or 0 for output, then you'd need external help. Same for most analog sensors.
This external help would be something where you put the system in a known controlled state, press a button, and it then checks the sensors for output within a specific range. To be absolutely sure, you'd want at least two different states, to ensure your digital or analog inputs didn't happen to be stuck at the correct state for your test.
Just about any other method would be external to the system. Using additional IO to "detect" a sensor could help increase confidence the sensor is there, but you could get false positives where all you've learned is that "something" is there - not necessarily the sensor you expect.

Check the battery status with NodeMCU?

I use an ESP8266 dev board from NodeMCU with Lua. I power my chip with two AA batteries, which gives me 3V. See this:
https://www.hackster.io/noelportugal/ifttt-smart-button-e11841
How do I check the battery status using NodeMCU?
With a recent firmware you can use adc.readvdd33(). That should be enough for your case
I read somewhere that adc.readvdd33() was deprecated? Effectively it is for many of the ESP8266 modules available, the docs say, "If the ESP8266 has been configured to use the ADC for sampling the external pin, this function will always return 65535". So that means that any ESP8266 that has an ADC pin (like ESP8266-07 or -12, etc.) has this shunted in firmware.
But by adding a couple of resistors to make a voltage divider, you can still use the ADC pin for this.
[![schematics][1]][1]
[1]: http://i.stack.imgur.com/FEILF.png
Those resistor values will allow it to read 0-12V, as a value between 0-1024. (The voltage at the ADC pin must be less than 1V.)
val = adc.read(0)
Addendum: Adding this to your circuit incurs a power draw of approx. 0.01 milliamps, small but more than nothing. Multiply the values by 1000 to reduce it to infinitesimal. Or use 18 megaohm for r1 and 2 megaohm for r2, which divides the voltage by 10, and (wild guess) drains less current than most if not all batteries will attenuate when disconnected.

Does a router have only one BSSID?

In other words, can a router have more than one BSSID (for example, implementing two different versions of the 802.11 protocol)?
And if so, are the RSSIs from the BSSIDs of a specific router exactly the same?
Yes ,you can have multiple BSSID on single router (or card) by making
Multile VAP(virtual access point)
But , the RSSI should always be same for all new VAPs as RSSI depend on
Tx Power (output power) ,thus can set one output power per chip (router).
you can change output power (RSSI) for different VAPs (BSSID) if it have more
than one Wlan Chip inside .

how to transmit signal with data rate (3.84 Mbps) using USRP1?

I want to send signal with data rate (3.84 M) using USRP1, but when I transmit the signal it tells me some thing like this in the terminal :
WARNING
Target data rate: 3840000 bps
Actual data rate: 4000000 bps
but I'm trying to implement TX working with the UMTS air interface and I don't want this error in the data rate,
anyone can help?????
Your sample rate is dependent on the master clock rate you are using with your USRP. Your USRP1 has a master clock rate of 64 MHz, and you can only sample at integer decimations of that value, by default, which is why you cannot sample at 3.84 MSps.
UHD is auto-correcting your requested sample rate to a rate that is supported by your USRP, for you. This is actually desirable behavior.
You have two options:
Replace the clock on the USRP1 that will divide down to the rate you want.
Use a rational re-sampler. GNURadio provides this block for you, if you want to use it.
I would suggest using a rational resampler before attempting a hardware mod, which may permanently destroy your USRP if you do it incorrectly.

wpa_supplicant / wpa_cli not able to detect wrong key of access point

I am developing a handheld device based on IMX233 running embedded linux and is using Unifi CSR6026 for connecting to the WiFi networks. I have got the basic WiFi connectivity running using the wpa_supplicant and wpa_cli utilities. But i'm not able to detect when the user has entered a wrong key for the access point. The 'wpa_cli status' shows 'wpa_state=COMPLETED' and the iwconfig also returns the correct ESSID and MAC address of the access point as currently connected. Is there any other way to find out whether the user has entered a wrong key or not ??
root#freescale ~$ wpa_cli status
Selected interface 'eth0'
bssid=00:24:01:6a:3f:26
ssid=FirstFloorBGN
id=1
pairwise_cipher=WEP-40
group_cipher=WEP-40
key_mgmt=NONE
wpa_state=COMPLETED
root#freescale ~$ iwconfig
lo no wireless extensionsunifi1: unifi_giwencode: Surprise, do not have a
valid key index (0)
.
eth0 IEEE 802.11-b/g ESSID:"FirstFloorBGN"
Mode:Managed Frequency:2.422 GHz Access Point: 00:24:01:6A:3F:26
Bit Rate=24 Mb/s
RTS thr=0 B Fragment thr:off
Encryption key:off
Power Management period:500ms mode:All packets received
Link Quality=25/40 Signal level=-47 dBm Noise level=-72 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
With WEP, there is no explicit key exchange, so there is no place in which a decryption error could be noticed. Your options are
switch to WPA
monitor the wireless statistics for decryption errors.
Note that the latter need not be an indication that the access point is using a different key.

Resources