Time-series data to the Arduino

Hello, I need help. I want the Arduino code that allows me to receive time series data from the ganglion . Example of time series [0.001,0.002,0.003,9.999] What is the Arduino code that can receive this data? Thank you

Comments

  • wjcroftwjcroft Mount Shasta, CA

    Hi Abdo,

    I don't believe we've heard from anyone using Ganglion directly with Arduino. The reason is the decoding and decompression code needed is quite complex, and involves talking with the serial protocol of the BLED112 dongle.

    If it is possible for you to run instead on a Raspberry, other users have been able to make that work by plugging the BLED112 into the usb host port on the Raspberry. Then using the Brainflow libraries.

    https://brainflow.org/

    Brainflow requires C++ support on the host platform. I don't believe Arduino will allow this. Secondarily, most Arduino's lack a usb host port.

    Regards, William

  • wjcroftwjcroft Mount Shasta, CA

    OK, sorry, there is one other option. You can run the OpenBCI_GUI on your laptop, then use the Networking widget to output time series data on a serial port that the Arduino then reads.

    https://docs.openbci.com/docs/06Software/01-OpenBCISoftware/GUIWidgets#networking

  • AbdoAbdo Syria

    Thanks for your help, but I am working on an artificial hand project from the brain signals, and I need any transmission method to the Arduino. I transferred the muscle signal data, but this does not help me. I need any help to transmit the brain signals.

  • wjcroftwjcroft Mount Shasta, CA

    Did you read the previous comments? Did you try the GUI Networking Widget? Did you consider that possibly moving your project to Raspberry, will allow you to run standalone without the laptop?

  • AbdoAbdo Syria

    The muscle signaling protocol is 0.001,0.002,0.003,9.999 / n
    If you can send the muscle data via this attached code, I just need instructions that make me receive the time series code.

  • AbdoAbdo Syria
    edited April 19
    #define NUM_CHAN 4
    #define BAUD_RATE 115200 //Tested with 57600 and 115200
    
    const byte BufferSize = NUM_CHAN * 4;
    char Buffer[BufferSize+1];
    boolean newData = false;
    float emgData[NUM_CHAN];
    
    void setup() {
        Serial.begin(BAUD_RATE);
        pinMode(7, OUTPUT);
        pinMode(8, OUTPUT);
        pinMode(9, OUTPUT);
        pinMode(10, OUTPUT);
         digitalWrite(7, LOW);
        Serial.println("<Arduino is ready>");
    }
    
    void loop() {
        // Data Format 4CH
        // 0.999,0.001,0.002,0.003\n
        // Data Format 16CH
        // 0.999,0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,0.010,0.011,0.012,0.013,0.014,0.015\n
        receiveMoreThan64Chars();
        if (newData) {
          parseData(",", Buffer);
          showData();
          showBlink();
          newData = false;
        }
    }
    
    void receiveMoreThan64Chars() {
      if(Serial.available() > 0){
    
        // Clear Buffer content
        memset(Buffer, 0, BufferSize+1);
    
        while(Serial.available() > 0){
          // "readBytes" terminates if the determined length has been read, or it
          // times out. It fills "Buffer" with 1 to 96 bytes of data. To change the
          // timeout use: Serial.setTimeout() in setup(). Default timeout is 1000ms.
          Serial.readBytes(Buffer, BufferSize);
        }
    
        // Print out buffer contents
        //Serial.println(Buffer);
    
        // You can use Serial.peek() to check if more than 96 chars
        // were in the serial buffer and if Buffer has truncated data.
        // This should never happen because you know what the max length of
        // the incoming data is and you have adequately sized your input buffer.
        if(Serial.peek() != -1){
          Serial.println("96 byte Buffer Overflowed. ");
        }
        Buffer[BufferSize+1] = '\0'; //overwrite the \n char with \0 to terminate the string
        newData = true;
      }
    }
    
    void parseData(char* delimiter, char* str) {
        char* pch;
        pch = strtok (str,delimiter);
        int i = 0;
        while (pch != NULL) {
            emgData[i] = atof(pch);    
            pch = strtok (NULL, ",");
            i++;
        }   
    }
    
    void showData() {
      for(int i = 0; i < NUM_CHAN; i++) {
        Serial.println(emgData[i], 3);
      }
    }
    
    void showBlink() {
    
       if (emgData[0] > 0.100) {
        digitalWrite(7, HIGH);
      }
     if (emgData[1] > 0.100) {
        digitalWrite(8, HIGH);
      }
       if (emgData[2] > 0.100) {
        digitalWrite(9, HIGH);
      }
       if (emgData[3] > 0.100) {
        digitalWrite(10, HIGH);
      }
    }
    
  • wjcroftwjcroft Mount Shasta, CA

    I transferred the muscle signal data, but this does not help me. I need any help to transmit the brain signals.

    Overall, I'm confused about what you are asking for. But rereading the statement above, perhaps you are asking NOT about the Arduino code or Networking Widget setup -- but instead are confused about how to change the setup of the Ganglion board from EMG to EEG. This is covered in the doc below,

    https://docs.openbci.com/docs/01GettingStarted/02-Biosensing-Setups/EEGSetup#1-connect-your-electrodes-to-openbci

    In particular see the statement:

    On the Ganglion you have pins 1 through 4, corresponding to Ganglion's 4 channels available for data. Please note, the four switches on the Ganglion should be set to 'DOWN' for EEG. Explanation in detail: https://docs.openbci.com/docs/03Ganglion/GanglionSpecs#inverting-input-select-switches

Sign In or Register to comment.