4 ms·
Neat! How can I help you? I think our devkit's components will help you get started. Here is the main.cpp code for this ``` /* * @file streams-i2s-webserver_w
by akadeb 2y ago
Neat! How can I help you? I think our devkit's components will help you get started. Here is the main.cpp code for this
```
/*
* @file streams-i2s-webserver_wav.ino
*
* This sketch reads sound data from I2S. The result is provided as WAV stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann
* @copyright GPLv3
/
#include <WiFi.h>
#include "AudioTools.h"
const char ssid = "<stavros_ssid>";
const char *password = "stavros_pw";
AudioWAVServer server(ssid, password);
I2SStream i2sStream;
ConverterFillLeftAndRight<int16_t> filler(LeftIsEmpty); // fill both channels - or change to RightIsEmpty
void setup()
{
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
// // Connect to Wi-Fi
Serial.println("Connecting to WiFi...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(1000);
Serial.println("Connecting...");
}
Serial.println("Connected to WiFi");
// Print the IP address
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// start i2s input with default configuration
Serial.println("starting I2S...");
auto config = i2sStream.defaultConfig(RX_MODE);
// working well
config.i2s_format = I2S_STD_FORMAT;
config.sample_rate = 44100; // INMP441 supports up to 44.1kHz
config.channels = 1; // INMP441 is mono
config.bits_per_sample = 16; // INMP441 is a 24-bit ADC
config.pin_ws = 19; // Adjust these pins according to your wiring
config.pin_bck = 18;
config.pin_data = 21;
config.use_apll = true; // Try with APLL for better clock stability
i2sStream.begin(config);
Serial.println("I2S started");
// start data sink
server.begin(i2sStream, config, &filler);
}
// Arduino loop
void loop()
{
// Handle new connections
server.copy();
}
```
This code just listens to audio you record on a microphone (INMP441 MEMS microphone used here) and streams it to an endpoint of the microcontroller's IP address. If you would like more help on this give me a shout anytime. my email: akash at starmoon dot app
- stavros 2y agoThis is good, thanks! Now that I see this, I realize that I'd want wakeword detection as well, which is getting a bit far. I like what the Willow team did with their stack, unfortunately that project seems to have died. It was pretty ideal, otherwise...