Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By kolban
#32428 That looks great. Now we just need to merge that with an audio signal (maybe PWM) such that the audio frequency (or click rate) is a function of the signal strength. I'm real curious to see how this works out.
User avatar
By Barnabybear
#32439 Hi, RSSI returned in the code above should be a negative number between 100 & zero (zero being the strongest signal).
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.
User avatar
By derek bernsen
#32459 Wow that is just the formula needed! Thanks!

Here is the code so far, but it's throwing a ton of errors:

Code: Select all#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);

 } 
}
User avatar
By derek bernsen
#32474 Ok, so I think I've found a minimalistic way to generate the beeping, but the next question is how to edit the formula (rssi + 33)*-15 to give numbers between 255 and 0 as needed by analogWrite() .
Here's what I have so far:
Code: Select allanalogWrite(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...