Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIO 29 used in example #2

Open
jimtal001 opened this issue Mar 27, 2024 · 9 comments
Open

GPIO 29 used in example #2

jimtal001 opened this issue Mar 27, 2024 · 9 comments

Comments

@jimtal001
Copy link

In your example you used GPIO29 for serial data (SD) connection to the INMP441 Mic. I am interested to know why you choose this particular pin since (from what I understand) it's not recommended since it is the VSYS pin.

@biemster
Copy link
Owner

On the rp2040-zero which I used for this, that pin was just in the right spot to solder it dead bug style (I also did not know it is the VSYS pin..)

@jimtal001
Copy link
Author

jimtal001 commented Mar 27, 2024 via email

@jimtal001
Copy link
Author

jimtal001 commented Mar 27, 2024

I have been testing your example code using an RP Pico W on a windows pc. I have changed the I2S pins to:
#define SCK 11 // clock pin
#define WS 12 // needs to be SCK +1
#define SD 13 // Serial Data Pin, used on different board
The code appears to run without issue however I am not sure about the output. As the data is passed to the terminal in VS Code and a log is generated. Next, I import this log file into Audacity as a raw file. Then it is necessary to set several import parameters: encoding, byte order, channels, sample rate. I've tried most of the settings but none result in any reasonable output (e.g. 32 bit,BE,1,16000). I have not changed the settings in your code, and I have tried several INMP441 Mics with same result.
Attached is a sample of the output with me counting and silent background. Any suggestions would be appreciated!
COM6_2024_03_27.11.12.03.309.txt

@biemster
Copy link
Owner

I'm not sure what VS Code is doing in the terminal, but you need to convert the hex in the log to bytes. I use xxd -r -p for that as you could read in the code, but some python like the following should work too:

#!/usr/bin/env python
audiobuf = bytearray()
with open('COM6_2024_03_27.11.12.03.309.txt') as f:
	for line in f:
		audiobuf += bytes.fromhex(line)

with open('counting.wav', 'wb') as f:
	f.write(audiobuf)

When I tried either xxd or the above code I did not get any audible sound though, although it seems that there is something happening through the noise.

@biemster
Copy link
Owner

It's been a while since I worked on this, and my tests are on a since then decommissioned machine.

@jimtal001
Copy link
Author

jimtal001 commented Mar 27, 2024 via email

@biemster
Copy link
Owner

I'm not sure what's the issue on your side. I've captured a small log from the serial port:
hijim.log

and when I convert that with the bit of python I wrote above I can play the resulting wav file using aplay jim.wav -r 16000 -c1 -fS32_BE just fine.

@jimtal001
Copy link
Author

jimtal001 commented Mar 27, 2024 via email

@jimtal001
Copy link
Author

jimtal001 commented Mar 29, 2024

I have resolved one issue. I changed SCK, WS and SD pins on the Pico W and recording improved significantly for the audio format of MONO format only (one I2S microphone connected). Perhaps I was getting interference on the pins from the WIFI module???

Next Issue: To play the audio clearly (recorded at 16K Hz) I have to set the wav file rate to 8K Hz.

  • Important Observation -
  • Recording 10 seconds of audio results in approximately 1/2 the expected number of samples, i.e. I expect to receive ~ 10*16000 samples but I end up with ~1/2 that number. Perhaps its serial related???

A log file is attached for ~10+ sec recording. The log file is of signed integer 32 samples.
Also, I've attached some python code (plot_raw.txt) which plots the audio and produces a wav file for this data. Maybe it would be useful?

Settings: Format=MONO (single I2S microphone connected), BPS=32, RATE=16000.

COM6_2024_03_29.07.20.59.705_mono_10sec.txt

plot_raw.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants