├── Installation Documents ├── Console logs for commands │ └── insatllation record file for MEMS microphone.docx ├── Raspberry Pi with MEMS (Part 2)- Adding volume control.pdf └── Raspberry Pi with MEMS Microphone.pdf ├── LICENSE ├── Python Example ├── README.md └── example.py └── README.md /Installation Documents/Console logs for commands/insatllation record file for MEMS microphone.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Infineon/GetStarted_IM69D130_With_RaspberryPi/c016990a994c73c3efbe1a58960a2cf74cace63f/Installation Documents/Console logs for commands/insatllation record file for MEMS microphone.docx -------------------------------------------------------------------------------- /Installation Documents/Raspberry Pi with MEMS (Part 2)- Adding volume control.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Infineon/GetStarted_IM69D130_With_RaspberryPi/c016990a994c73c3efbe1a58960a2cf74cace63f/Installation Documents/Raspberry Pi with MEMS (Part 2)- Adding volume control.pdf -------------------------------------------------------------------------------- /Installation Documents/Raspberry Pi with MEMS Microphone.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Infineon/GetStarted_IM69D130_With_RaspberryPi/c016990a994c73c3efbe1a58960a2cf74cace63f/Installation Documents/Raspberry Pi with MEMS Microphone.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Infineon Technologies AG 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Python Example/README.md: -------------------------------------------------------------------------------- 1 | # Example in Python to access IM69D130 using [PyAudio](https://people.csail.mit.edu/hubert/pyaudio/docs/) Library 2 | 3 | ``` 4 | Steps- 5 | ``` 6 | 7 | * Follow the document named "Raspberry Pi with MEMS Microphone" to interface Infineon MEMS Microphone with Raspberry pi. 8 | 9 | * Run the example file from the terminal. 10 | 11 | ``` 12 | Result- 13 | ``` 14 | 15 | #### Sound will be recorded for 10 seconds and will be saved as in .wav format file. 16 | #### As enabling the access in Python by using PyAudio multiple other function of the library can be used to work on the data generated by IM69D130. 17 | -------------------------------------------------------------------------------- /Python Example/example.py: -------------------------------------------------------------------------------- 1 | import pyaudio 2 | import wave 3 | 4 | FORMAT = pyaudio.paInt16 5 | CHANNELS = 2 6 | RATE = 44100 7 | CHUNK = 512 8 | RECORD_SECONDS = 5 9 | WAVE_OUTPUT_FILENAME = "recordedFile.wav" 10 | device_index = 2 11 | audio = pyaudio.PyAudio() 12 | 13 | 14 | 15 | stream = audio.open(format=FORMAT, channels=CHANNELS, 16 | rate=RATE, input=True,input_device_index = 5, 17 | frames_per_buffer=CHUNK) 18 | print ("recording started") 19 | Recordframes = [] 20 | 21 | for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)): 22 | data = stream.read(CHUNK) 23 | Recordframes.append(data) 24 | print ("recording stopped") 25 | 26 | stream.stop_stream() 27 | stream.close() 28 | audio.terminate() 29 | 30 | waveFile = wave.open(WAVE_OUTPUT_FILENAME, 'wb') 31 | waveFile.setnchannels(CHANNELS) 32 | waveFile.setsampwidth(audio.get_sample_size(FORMAT)) 33 | waveFile.setframerate(RATE) 34 | waveFile.writeframes(b''.join(Recordframes)) 35 | waveFile.close() 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Important 2 | 3 | **This tutorial is outdated. Please look [here](https://github.com/Infineon/i2s-microphone/wiki/Raspberry-Pi-Getting-Started) for the new tutorial.** 4 | 5 | # IM69D130 Stereo Microphone Shield2Go with Raspberry Pi 6 | 7 | ## Supported Platforms 8 | 9 | | Platform | Compatible | 10 | | --- |:---:| 11 | | Raspberry Pi 4 Mod. B | :x: | 12 | | Raspberry Pi 3 Mod. B+ | :heavy_check_mark: | 13 | | Raspberry Pi 3 Mod. B | :heavy_check_mark: | 14 | | Raspberry Pi 3 Mod. A+ | :heavy_check_mark: | 15 | | Raspberry Pi Zero | :heavy_check_mark: | | 16 | | Raspberry Pi Zero W(H) | :heavy_check_mark: | 17 | | Raspberry Pi 2 Mod. B v1.2 | :heavy_check_mark: | 18 | | Raspberry Pi 2 Mod. B | :heavy_check_mark: | 19 | | Raspberry Pi 1 Mod. B+ | :heavy_check_mark: | 20 | | Raspberry Pi 1 Mod. B | :x: | 21 | | Rapsberry Pi 1 Mod. A+ | :x: | 22 | | Raspberry Pi 1 Mod. A | :x: | 23 | 24 | ## Quick Start Guide 25 | 26 | ### Preparation of Raspberry Pi 27 | 28 | **You can **[skip](#software-setup)** this step, if you already have Raspbian installed on your compatible Raspberry Pi.** 29 | 30 | * Download Raspbian from [here](https://www.raspberrypi.org/downloads/raspbian/) 31 | * Unzip Raspbian and flash the image to an SD card. [Here](https://www.raspberrypi.org/documentation/installation/installing-images/) you find a step-by-step tutorial. 32 | 33 | #### Headless setup (optional) 34 | 35 | **You need network connection for headless operation.** 36 | 37 | ##### SSH server 38 | 39 | For using your Raspberry Pi without a monitor, you need to create an empty file named `ssh` on the boot partition of the SD card. 40 | 41 | 42 | ##### Automatic WiFi connection (optional, if you have an ethernet connection) 43 | Create a file `wpa_supplicant` according to [this](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md) guide. 44 | 45 | #### First login 46 | 47 | Now put the SD card in your compatible Raspberry Pi and power it up. 48 | 49 | Log in to your Raspberry Pi with the default credentials (user: *pi*, password: *raspberry*). Change the default password for security reasons. 50 | 51 | ``` 52 | passwd 53 | ``` 54 | 55 | ### Software setup 56 | 57 | #### Enable I2S (Inter-IC-Sound) on your Raspberry Pi 58 | 59 | Open the file `/boot/config.txt` for writing with any text editor of your choice. For simplicity we use *nano*, which is pre-installed on Raspbian: 60 | 61 | ``` 62 | sudo nano /boot/config.txt 63 | ``` 64 | 65 | Scroll down to this line: 66 | 67 | ``` 68 | #dtparam=i2s=on 69 | ``` 70 | 71 | and uncomment it (remove the # from the beginning of the line). 72 | 73 | Save your changes and close the file. 74 | 75 | Now open the file `/etc/modules`: 76 | 77 | ``` 78 | sudo nano /etc/modules 79 | ``` 80 | 81 | and add the following line to the end of the file: 82 | 83 | ``` 84 | snd-bcm2835 85 | ``` 86 | 87 | Save your changes and close the file. 88 | 89 | Now reboot your Raspberry Pi to apply the changes: 90 | 91 | ``` 92 | sudo reboot 93 | ``` 94 | 95 | Let's do an intermediate check, if everything worked so far: 96 | 97 | ``` 98 | lsmod | grep snd_soc_bcm2835_i2s 99 | ``` 100 | 101 | **If the output of this command is not empty, all went well so far!** 102 | 103 | If you encounter any problems up to this step, please be sure that you use the newest version of Raspbian on a [supported hardware platform](#supported-platforms). In case it still doesn't work, please consider trying the steps on a fresh Raspbian installation. If you still encounter problems, please feel free to open an [issue](https://github.com/Infineon/GetStarted_IM69D130_With_RaspberryPi/issues). 104 | 105 | #### Install I2S module 106 | 107 | **Please inform yourself about the tool** [rpi-update](https://github.com/Hexxeh/rpi-update) **and the side effects it might have before executing the following commands.** 108 | 109 | **If you have any important data on your Raspberry Pi, we recommend to do make a backup before continuing.** 110 | 111 | **Please make sure that your Raspberry Pi has a working Internet connection.** 112 | 113 | We now need to install the tool `rpi-update`: 114 | 115 | ``` 116 | sudo apt-get update 117 | sudo apt-get install rpi-update 118 | sudo rpi-update 119 | ``` 120 | 121 | After about one minute the following prompt appears: 122 | 123 | ``` 124 | Would you like to proceed? (y/N) 125 | ``` 126 | 127 | Press *y* to continue the process. Make sure to inform yourself about the potential risks **before** you proceed. 128 | 129 | The subsequent updating process takes about 4 minutes. 130 | 131 | After the process has finished, please reboot your Raspberry Pi to activate the new firmware: 132 | 133 | ``` 134 | sudo reboot 135 | ``` 136 | 137 | Now install these dependencies for subsequent compliation of a kernel with the I2S module: 138 | 139 | ``` 140 | sudo apt-get install git bc libncurses5-dev bison flex libssl-dev 141 | ``` 142 | 143 | Now we come to the biggest step: Downloading and compling the kernel source - Let's go! 144 | 145 | ``` 146 | sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source 147 | sudo chmod +x /usr/bin/rpi-source 148 | /usr/bin/rpi-source -q --tag-update 149 | rpi-source --skip-gcc 150 | ``` 151 | 152 | **The last command will take about 10 minutes on a Raspberry Pi 3 Mod. B+, so it's time to grab a coffee :)** 153 | 154 | If the following prompt appears (after about 7 minutes), please hit *Enter* to accept the default response: 155 | 156 | ``` 157 | Code coverage for fuzzing (KCOV) [N/y/?] (NEW) 158 | ``` 159 | 160 | #### Compile I2S module 161 | 162 | Compile the I2S module: 163 | 164 | ``` 165 | sudo mount -t debugfs debugs /sys/kernel/debug 166 | ``` 167 | 168 | **Don't worry if it says: `mount: /sys/kernel/debug: debugs already mounted or mount point busy.` That's ok.** 169 | 170 | Now download the [I2S module](https://github.com/PaulCreaser/rpi-i2s-audio) for the Raspberry Pi, written by [Paul Creaser](https://github.com/PaulCreaser): 171 | 172 | ``` 173 | git clone https://github.com/PaulCreaser/rpi-i2s-audio 174 | ``` 175 | 176 | Load the I2C module statically: 177 | 178 | ``` 179 | cd rpi-i2s-audio 180 | make -C /lib/modules/$(uname -r)/build M=$(pwd) modules 181 | sudo insmod my-loader.ko 182 | ``` 183 | 184 | Now let's check if everything worked so far. Use this command to verify if the module has been loaded correctly: 185 | 186 | ``` 187 | lsmod | grep my_loader 188 | ``` 189 | 190 | Now let's use `dmesg` to read out the latest messages of the Kernel Ring Buffer: 191 | 192 | ``` 193 | dmesg | tail 194 | ``` 195 | 196 | Everything worked so far if you see a line like: 197 | 198 | ``` 199 | [X.XXXXXX] asoc-simple-card asoc-simple-card.0: snd-soc-dummy-dai <-> 3f203000.i2s mapping ok 200 | ``` 201 | 202 | In order to enable autostart for the I2S modules, the following commands have to be executed: 203 | 204 | ``` 205 | sudo cp my_loader.ko /lib/modules/$(uname -r) 206 | echo 'my_loader' | sudo tee --append /etc/modules > /dev/null 207 | sudo depmod -a 208 | sudo modprobe my_loader 209 | ``` 210 | 211 | Now it's time for the hardware part before you can test your new setup! 212 | 213 | Before you start working on the hardware connections, shutdown your Raspberry Pi: 214 | ``` 215 | sudo poweroff 216 | ``` 217 | 218 | and unplug the power cable. 219 | 220 | ### Hardware setup 221 | 222 | * Connect the IM69D130 Microphone Shield2Go to your Raspberry Pi 223 | 224 | Pin connection: 225 | 226 | | Microphone Shield2Go | Raspberry Pi | 227 | | :---: |:---:| 228 | | 3.3V | 3V3 | 229 | | GND | GND | 230 | | DATA | BCM 20 | 231 | | BCLK | BCM 18 | 232 | | CLK | BCM 19 | 233 | 234 | * Power up your Raspberry Pi 235 | 236 | 237 | ### Recording Audio 238 | 239 | List available input devices with: 240 | 241 | ``` 242 | arecord -l 243 | ``` 244 | 245 | You should see a *snd_rpi_simple_card*. 246 | 247 | You can record a wav file with this command: 248 | 249 | ``` 250 | arecord -D plughw:1 -c2 -r 48000 -f S32_LE -t wav -V stereo test.wav 251 | ``` 252 | 253 | By default, the sound level of the recording is very low, but so is the noise, hence you can easily amplify the output file e.g. using [sox](http://sox.sourceforge.net/): 254 | 255 | ``` 256 | sudo apt-get install sox 257 | sox test.wav test_norm.wav --norm=0 trim 10 258 | ``` 259 | 260 | `--norm=0` normalizes the output file to 0 dB and `trim 10` cuts the first 10 seconds of the audio file. This is recommended if you get a clipping peak in the beginning of the recording, because otherwise the normalization does not work correctly. 261 | 262 | To sum this up; for recording a sequence of 10 seconds, normalizing it and playing it back you can use the following command: 263 | 264 | ``` 265 | arecord -D plughw:1 -c2 -r 48000 -f S32_LE -t wav -V stereo --duration 20 test.wav && sox test.wav test_norm.wav --norm=0 trim 10 && aplay test_norm.wav 266 | ``` 267 | --------------------------------------------------------------------------------