Closed hazee007 closed 5 years ago
check this out: https://github.com/espressif/esp-idf/tree/master/examples/peripherals/i2s_adc_dac you can not copy/paste it to arduino as is though. Some rework is required. You can see how I2S is set to use ADC for input and DAC for output and how data is saved. Good luck :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This stale issue has been automatically closed. Thank you for your contributions.
Hello guys have been trying to get a voice recorded from eps32 using its ADC for quite some while now, no success so far. i just found a code that look simple but using an I2S for doing the recording. I dont want to use i2s for my due to cost and sound quality dont realy matter right now.
Here is the code `#include
include
include "Wav.h"
include "I2S.h"
const int record_time = 10; // second const char filename[] = "/sound.wav";
const int headerSize = 44; const int waveDataSize = record_time * 88000; const int numCommunicationData = 8000; const int numPartWavData = numCommunicationData/4; byte header[headerSize]; char communicationData[numCommunicationData]; char partWavData[numPartWavData]; File file;
void setup() { Serial.begin(115200); if (!SD.begin()) Serial.println("SD begin failed"); CreateWavHeader(header, waveDataSize); SD.remove(filename); file = SD.open(filename, FILE_WRITE); if (!file) return; file.write(header, headerSize); I2S_Init(I2S_MODE_RX, I2S_BITS_PER_SAMPLE_32BIT); for (int j = 0; j < waveDataSize/numPartWavData; ++j) { I2S_Read(communicationData, numCommunicationData); for (int i = 0; i < numCommunicationData/8; ++i) { partWavData[2i] = communicationData[8i + 2]; partWavData[2i + 1] = communicationData[8i + 3]; } file.write((const byte*)partWavData, numPartWavData); } file.close(); Serial.println("finish"); }
void loop() { }` i got it from https://github.com/MhageGH/esp32_SoundRecorder/blob/master/esp32_I2S_recorder/esp32_I2S_recorder.ino
So my question is if i can change the I2S part in the code since its called twice in the whole code. and replace it with an ADC function. this one I2S_Init(I2S_MODE_RX, I2S_BITS_PER_SAMPLE_32BIT); and this I2S_Read(communicationData, numCommunicationData); i know i can try change this to analogRead but dont know what to do for the other one. any help is welcome. Thank you.