<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to capture audio using PDM mic and send that data to central device using BLE in seeedstudio Axio nrf52840 sense with inbuilt BLE and tinyml functionality]]></title><description><![CDATA[<p dir="auto">I have been working on a project . In which I want to capture data using the PDM mic and trasmit it through the BLE available . I am new to hardware and these sensors so I am unable to make sense of the data I am reciving on the other side(central) that is my mobile device(iphone X) with BlueLight application. I am able to find a service and I am reciving some form of hex code,but I don't know how to convert it to wave files or don't know whether it's possible or not .</p>
<p dir="auto">If you guys have any idea or any resources that could help please do share.</p>
<p dir="auto">I am attaching my code below :</p>
<pre><code>#include &lt;ArduinoBLE.h&gt;
#include &lt;mic.h&gt; //  microphone library 

// Microphone Settings
#define DEBUG 1
#define SAMPLES 800

mic_config_t mic_config = {
  .channel_cnt = 1,
  .sampling_rate = 16000,
  .buf_size = 1600,
  .debug_pin = LED_BUILTIN
};

NRF52840_ADC_Class Mic(&amp;mic_config);
int16_t recording_buf[SAMPLES];
volatile static bool record_ready = false;

// Updated UUIDs
#define SERVICE_UUID "19B10000-E8F2-537E-4F6C-D104768A1214"
#define CHARACTERISTIC_UUID_AUDIO "19B10001-E8F2-537E-4F6C-D104768A1214"

// BLE Service and Characteristic
BLEService audioService(SERVICE_UUID);
// Corrected initialization with explicit value size and fixed length flag
BLECharacteristic audioDataCharacteristic(CHARACTERISTIC_UUID_AUDIO, BLERead | BLENotify | BLEWrite, sizeof(recording_buf), true);

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  Serial.println("Initializing microphone...");
  Mic.set_callback(audio_rec_callback);
  if (!Mic.begin()) {
    Serial.println("Mic initialization failed");
    while (1);
  }
  Serial.println("Mic initialized.");

  Serial.println("Initializing BLE...");
  if (!BLE.begin()) {
    Serial.println("Failed to start BLE!");
    while (1);
  }

  BLE.setLocalName("SCT Audio");
  BLE.setAdvertisedService(audioService);
  
  audioService.addCharacteristic(audioDataCharacteristic);
  BLE.addService(audioService);

  // Corrected writeValue call with explicit casting
  audioDataCharacteristic.writeValue((uint8_t)0);
  
  BLE.advertise();
  Serial.println("BLE Peripheral is now advertising");
}

void loop() {
  BLEDevice central = BLE.central();

  if (central) {
    Serial.println("Connected to central device");
    
    while (central.connected()) {
      if (record_ready) {
        // Plot the audio data in the Serial Plotter
        for (int i = 0; i &lt; SAMPLES; i++) {
          Serial.println(recording_buf[i]);
        }

        // Transmit the audio data
        audioDataCharacteristic.writeValue((uint8_t*)recording_buf, 2 * SAMPLES);
        Serial.println("Audio data transmitted over BLE");
        record_ready = false;
      }
    }

    Serial.println("Disconnected from central device");
  }
}

static void audio_rec_callback(uint16_t *buf, uint32_t buf_len) {
  static uint32_t idx = 0;
  
  for (uint32_t i = 0; i &lt; buf_len; i++) {
    recording_buf[idx++] = buf[i];
    if (idx &gt;= SAMPLES){ 
      idx = 0;
      record_ready = true;
      break;
    } 
  }
}

</code></pre>
]]></description><link>https://makergram.com/community/topic/433/how-to-capture-audio-using-pdm-mic-and-send-that-data-to-central-device-using-ble-in-seeedstudio-axio-nrf52840-sense-with-inbuilt-ble-and-tinyml-functionality</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Mar 2026 18:26:37 GMT</lastBuildDate><atom:link href="https://makergram.com/community/topic/433.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Feb 2024 08:48:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to capture audio using PDM mic and send that data to central device using BLE in seeedstudio Axio nrf52840 sense with inbuilt BLE and tinyml functionality on Sun, 25 Feb 2024 13:54:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://makergram.com/community/uid/3">@salmanfaris</a> No, I haven't made any progess on the matter</p>
]]></description><link>https://makergram.com/community/post/1204</link><guid isPermaLink="true">https://makergram.com/community/post/1204</guid><dc:creator><![CDATA[amalkrishnam3]]></dc:creator><pubDate>Sun, 25 Feb 2024 13:54:34 GMT</pubDate></item><item><title><![CDATA[Reply to How to capture audio using PDM mic and send that data to central device using BLE in seeedstudio Axio nrf52840 sense with inbuilt BLE and tinyml functionality on Thu, 22 Feb 2024 07:56:42 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="https://makergram.com/community/uid/1008">@amalkrishnam3</a>, Were you able to make any progress?</p>
]]></description><link>https://makergram.com/community/post/1201</link><guid isPermaLink="true">https://makergram.com/community/post/1201</guid><dc:creator><![CDATA[salmanfaris]]></dc:creator><pubDate>Thu, 22 Feb 2024 07:56:42 GMT</pubDate></item></channel></rss>