• Dear Administrator,

    I hope that you are in good health.

    I am working on an application for transmitting a 500 Hz biosignal from an external signal acquisition device wirelessly to a computer or another remote device. For this design, I require a board with an in-built ADC along with a wireless transceiver (preferably Bluetooth for stable connection). While searching the internet, I stumbled upon the Espruino MDBT42Q module.

    I have some experience with Bluetooth 4.0 Low Energy using Red Bear Nano modules; however, as far as I remember, they could only provide 125 Hz using the Arduino IDE.

    My main requirements are as follows:

    1) Sample transmission and receive at at least 2 kHz to overcome the signal of 500 Hz at its highest frequency.
    2) A module compact in size which can be fitted in a rectangular space of 18 mm x 30 mm.
    3) Must have an ADC module to input analogue signals.

    To the best of my understanding, I found Espruino MDBT42Q which uses the Nordic Semiconductor nRF52832 the most appropriate to my application. I would be grateful if you can let me know if my understanding is correct. I would also be grateful if you could provide me with other options with improved features i.e. smaller size, higher resolution ADC, faster transmit/receive.

    I have an additional question regarding programming the Espruino MDBT420 board. I was reading the "Getting Started" page and I found out that the device can programmed wirelessly using a Web IDE provided we have a compatible in built Bluetooth module and Web Bluetooth. Have I understood that correctly?

    I would be grateful for any replies.

    Thank you.

    ZJ

  • Hi,

    Sample transmission and receive at at least 2 kHz

    You're correct in that you can only get a max packet rate of 125Hz. This is a limitation of Bluetooth (7.5ms connection interval). However you can send a bunch of of data within that packet, and with up to date firmware 2000 bytes/second should be pretty attainable.

    You should be able to use the Waveform class to sample data at 2kHz: https://www.espruino.com/Waveform

    A module compact in size which can be fitted in a rectangular space of 18 mm x 30 mm.

    The breakout board is about 18x28mm, but you could potentially use the module directly if you're able to design your own PCB

    I found out that the device can programmed wirelessly using a Web IDE provided we have a compatible in built Bluetooth module and Web Bluetooth. Have I understood that correctly?

    That's correct, yes.

    Hope that helps!

  • Thank you very much for your reply and it certainly helps!

    We are of course designing our own board which is why the dimensions are important.

    I am still getting around Bluetooth 5.0 and Java (I am more used to C). I found out that BLE 5.0 is capable of sending a max. of 244 bytes in a packet. I had been pondering on a pseudocode for a fast transmission of a 500 Hz biosignal. Suppose we receive the data from an ADC in INT or UNSIGNED INT format. In that case, I want to send 200 bytes (containing 100 sample values). These 100 values are sampled at 1 ms. These 100 samples (which would take roughly 0.1 s to record) would be placed in a TX buffer and would be sent to the Master device. I would be grateful if you could check my (rough and simple) pseudocodes below to see if my concepts are right.

    TX (Peripheral Side)

    START:
    Global Variable Buffer;

    setup()
    {
    BLE initialization // (incl. Peripheral setting, advertising)
    Establish connection with Master
    }

    Loop()
    {
    Buffer = Samples of ADC values using Waveform Class @ 1 kHz
    Transmit Buffer to Master // transmitting 200 bytes (100 samples) in 0.1 sec
    }

    END:

    RX (Master Side)

    START:

    Global Var flag; // flag for receiving new values in buffer
    Global Var Samples_ADC; //contains 100 received ADC values
    Global Var count = 0; // counter for Samples_ADC

    setup()
    {
    Initialize Serial
    Initialize Timer Interrupt
    BLE initialization // (incl. Master setting, Receive advertisements)
    Establish connection with Master // (Including min. and max. connection interval setting)

    }

    Loop1()
    {

    Buffer = Receive Values
    Samples_ADC = Parsed Buffer values // Contains transmitted values and parse

    Flag = 0;
    Timer Interrupt en = 1;
    while(Flag == 0); // wait until Flag is 1
    }

    Timer Interrupt ISR (called after 1 ms)
    {
    if (count == size(Samples_ADC)) --> count = 0, Flag = 1; //reinitialize count and flag
    Print(buffer(count)); // prints each value in buffer after 1 ms
    count++;

    }
    END:

    I have written down this rough C based pseudocode off the top of my head. I request you to kindly critique on it and comment if I have to worry about timing issues i.e data back log or loss etc.

    Please understand my lack of knowledge of BLE. I would be grateful for any replies.

    Thank you
    ZJ

  • Hi - it's worth noting that Java and JavaScript (what Espruino uses) are actually very different, despite the name - so be a bit careful!

    What device did you intend to use for the RX (Master Side)? Another MDBT42Q, or a phone/PC?

    Right now the standard builds of Espruino only handle a max 53 byte packet size (even though longer is supported by the spec), so worth bearing that in mind.

    Also, with Espruino you want to really handle data when an event happens, not in 'loop'. If you use 'loop' then you're just running the CPU constantly burning through your battery.

    The code required is simple enough it's worth just posting the whole thing rather than pseudocode. Something like this will probably work for the Espruino side:

    var analog_pin = D3; 
    NRF.setConnectionInterval(7.5); // force the highest speed mode
    var w = new Waveform(53,{doubleBuffer:true,bits:16})­;
    w.on("buffer", function(buf) {
      Bluetooth.print(buf);
    });
    w.startInput(analog_pin,1000,{repeat:tru­e});
    
  • Thank you very much for your reply.

    I should have mentioned the Master side in my previous message. Yes, at this point I intend to use an MDBT42Q at the Master side too and in order to check the result of the transmission, I wanted to print the result.

    I would be grateful for your feedback on the Master side (RX) pseudocode as well.

    I am grateful for your event based transmission comment in your previous message, and the code seems simple enough to modify and test.

    Additional question: Is the process of receiving and handling data different when using a phone/PC.

    I would be grateful for your response.

    ZJ

  • In the example code I gave I'm just using the standard 'UART' bluetooth mode, so on the RX side you'd just use this: http://www.espruino.com/BLE+UART#receivi­ng-evaluating

    NRF.requestDevice({ filters: [{ namePrefix: 'MDBT42Q' }] }).then(function(device) {
      return require("ble_uart").connect(device);
    }).then(function(uart) {
      uart.on('data', function(d) { 
        // do something with the data 
        // maybe: Serial1.write(d);
      });
    });
    

    On the PC side it's not that different, except you have to be able to access Bluetooth LE. Some code examples are at https://www.espruino.com/Interfacing#blu­etooth-le

    I ask because the PC has more resources and the data transfer rate may actually be faster between one MDBT42Q and a PC than it is between two MDBT42Q. You'd just have to do some testing and see if it was good enough for your requirements.

  • Thank you very much for your reply. My first plan is to communicate the data with the PC from the Espruino. I have ordered the MDBT42Q and keep you posted of my progress. I am still a novice using this device so please don't mind me asking a lot of question in the future.

    Thank you again.

    ZJ

  • Great, hope it goes well.

    No problem at all - that's what this forum is for!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Espruino MDBT42Q Breakout for 1kHz Signal Acquisition

Posted by Avatar for user129301 @user129301

Actions