Prototype 1: The Wi-Fi Beeper

 

The overarching theme of this project is the mix between digital and human features. Specifically, how the environment can have an impact on the individual in an invisible and untouchable way. 

Inspired by the Bluetooth Visualizer and the Ambient Machine, I want to create a sound machine that reacts to radio signals (Wi-Fi signals as the primary option to recieve signals). 

The goal for the first prototype is to test how to detect Wi-Fi and make sounds accordingly. This process is based on an ESP32 chip, and developed in Arduino IDE.

First, I explored how to detect Wi-Fi signals on an ESP32 board, using the Wi-Fi Scan example. 

In this example, the ESP32 board can get:

  • number of networks
  • SSID
  • RSSI (signal strength)
  • channel
  • encryption type

I am using RSSI (signal strength) in this prototype as the main input. The output is a simple buzzer that makes sound based on signal strength. I defined a couple of notes and their frequencies, and higher the signal strength, higher the pitch. The notes and pitch are defined as follows:

 

The code works as follows: the ESP32 loops through all the wifi signal that it detects, the buzzer will beep according to the signal strength. For example, if there are 3 wifi networks, signal strength are -80, -70, -60 respectively, then the buzzer will beep notes E, F, G.

The benefits of the ESP32 is portability. To demonstrate, I connected the ESP32 board to a power bank (thanks Prof de Bel for the power bank) and walked around the campus. I found that there are more wifis in the courtyard than actually inside the building (because the beeping sequence was longer). Here’s a video demo:

 

Overall, this simple prototype demonstrates that the basic idea works. Wi-Fi detection is feasible and easy to implement. However, in the next step, making pleasant sound is much harder. Music coding platform SuperCollider is very hard to manage. So I will try to use other ways (synthesizers) or adding effects to construct ambient sounds.

 

FULL CODE

#include “WiFi.h”
// Pin for buzzer
const int buzzerPin = 17;
// Notes
int noteC = 523;
int noteD = 587;
int noteE = 659;
int noteF = 698;
int noteG = 784;
int noteA = 880;
int noteB = 988;
void setup() {
// initialize buzzer pin
pinMode(buzzerPin, OUTPUT);
 
// initialize serial communication
Serial.begin(115200);
// initialize WiFi
WiFi.mode(WIFI_MODE_STA);
WiFi.disconnect();
delay(100);
 
Serial.println(“Setup done”);
}
void loop() {
// scan for nearby networks
Serial.println(“Scan start”);
int n = WiFi.scanNetworks();
Serial.println(“Scan done”);
if (n == 0) {
Serial.println(“No networks available”);
} else {
Serial.print(n);
Serial.println(” network(s) found”);
}
// loop through all networks found
for (int i = 0; i < n; ++i) {
// Print WiFi information
Serial.print(i + 1);
Serial.print(“: “);
Serial.print(WiFi.SSID(i));
Serial.print(” (“);
Serial.print(WiFi.RSSI(i));
Serial.print(” dBm)”);
Serial.println();
// Play a melody based on RSSI
playMelody(WiFi.RSSI(i));
}
delay(5000); // Wait 5 seconds before next scan
}
void playMelody(int rssi) {
int note;
if (rssi > -50) {
note = noteB;
} else if (rssi > -58) {
note = noteA;
} else if (rssi > -65) {
note = noteG;
} else if (rssi > -76) {
note = noteF;
} else if (rssi > -85) {
note = noteE;
} else if (rssi > -90) {
note = noteD;
}else {
note = noteC;
}
tone(buzzerPin, note, 200);
delay(300);
noTone(buzzerPin);
}

Leave a Reply

Your email address will not be published. Required fields are marked *