Moderator: igrr
If you do convert the number to posative then multiply by 10.
RSSI x -10. This will give you a posative number between 1000 & zero.
Use this as time period gap between beeps.
GPIO output on for 100ms (fixed length beep)
GPIO output off for RSSI x -10 (variable length pause)
The beeps will get closer together the stronger the signal.
In reality the strongest signal is likley to be around -33dB, so you might want to play with the maths to get a continious tone, something like. (RSSI + 33) x -15 to give you a gap from 1000ms to zero.
Here is the code so far, but it's throwing a ton of errors:
#include <Arduino.h>
#include <ESP8266WiFi.h>
const char* SSID = "AITHINKER10229209";
const int buzzerPin = 2;
// Return RSSI or 0 if target SSID not found
int32_t getRSSI(const char* SSID) {
byte available_networks = WiFi.scanNetworks();
for (int network = 0; network < available_networks; network++) {
if (WiFi.SSID(network).startsWith(SSID) != 0) {
return WiFi.RSSI(network);
}
}
return 0;
}
void setup() {
Serial.begin(9600);
pinMode(2,OUTPUT);
digitalWrite(2, LOW);
}
void loop() {
unsigned long before = millis();
int32_t rssi = getRSSI(SSID);
unsigned long after = millis();
Serial.print("Signal strength: ");
Serial.print(rssi);
Serial.println("dBm");
Serial.print("Took ");
Serial.print(after - before);
Serial.println("ms");
delay(1000);
for 100ms {
digitalWrite(buzzerPin, HIGH);
for (int formula = (rssi + 33)*-15) {
digitalWrite(buzzerPin, LOW);
}
}
Here's what I have so far:
analogWrite(2, 128);
//instead of 128 (duty cycle), the number resulting from the RSSI calculation needs to be used. This number must be between 255 and 0.
And of course the other code is still throwing errors for me...