• InteractivitySolved
  • How do I make Bela receive serial communication from arduino within pure data?

giuliomoro I followed your steps, but i don't think that i succeeded. Arduino is running the example 'AnalogInOutSerial' at 115200 rate I connected it to the USB in of the BeagleBone and build your pd example with the render.cpp, but it doesn't print anything. I'm getting a successful build with this error : Error from tcgetattr: Input/output error. Any pieces of advice?

Did you change /dev/ttyS4 in the patch for the path of the usb serial device you are using?

    giuliomoro how can i find it? im a bit confused of how can i access bela's terminal without ssh.

    Just type ls /dev/tty{USB,ACM}* in the console at the bottom of the IDE. That should display most USB connected UART devices
    PS: if you want to connect to the board via SSH instead, use ssh root@bela.local

    a year later

    Hello! I stumbled upon this thread because I try to do something similar. I got it to run the way you described with the above pd sketch and render.cpp. I am sending a series of floats as text, separated by space and ending with a newline character. It works somehow but also it seems there are numbers getting lost on the way. I am sending ten numbers (changed the unpack and pack accordingly) but I get sometimes 5, sometimes 7, sometimes ten and also they seem to get mixed up. I tried to reduce the frequency in which the Arduino sends but even at once per second it happens. Any ideas why? Thanks in advance!

    I also tried to send the numbers as bytes (I mapped it to 0-255 so one byte per number because it doesn't really matter whether I get the actual values for me) and changed "newline" to "none" but then I got only zeroes ...

    I have made some improvements to the SERIAL features in the past months and I just pushed a simpler but better documented example (PureData/serial). So make sure you get the latest dev branch of Bela on your board and that you remove any .cpp file from your Pd project, then try again and come back if you still have trouble.

    Among the new features, you can now set bytes as the type and receive individual bytes as a value between 0 and 255.

      5 days later
      3 months later

      giuliomoro Hi! I'm trying to make sense of Serial reading into PureData, and I can find " a simpler but better documented example (PureData/serial)". I've got the lastest dev branch of Bela on my board. Any advise?

      I'm trying to send data from arduino to PureData running on Bela, i'm running the PD patch that is shared upper, and printing the values. Even though they look good on Arduino Serial Monitor, In Bela its strange, I'm not receiving every values, and it's changing variables order. I was trying to look for the example that you wrote about.
      Sorry if this is a simple question that i'm not getting, and thank you!

      😃

      giuliomoro , hmmm i'm still trying to make sense of "running the latest dev branch". I know i've updated Bela recently.

      Ok, just got to the instructions on hwo to update to experimental release, and i'm updating to the dev branch right now!

      This is was what i got on my version info:

      This is after updating to dev branch:

      And there is it! Thank you!

      Unfortunately i'm getting inconsistent readings more than 5 variables.. Until 5 variables, i get the values print on Bela console right. With 6 variables values start jumping in a strange way. 🙁

      On the Arduino:

      Serial.print(gY, 0);
      Serial.print(" ");
      Serial.print(gZ, 0);
      Serial.print(" ");
      Serial.print(val_bme_temp, 0);
      Serial.print(" ");
      Serial.print(val_bme_alti, 0);
      Serial.print(" ");
      Serial.print(val_bme_humi, 0);
      Serial.print(" ");
      Serial.println(val_peso, 0);

      Thank you again ;_;

        4 days later

        Hey, I cant send more that 4 variable values, any suggestion? Thank you!

        sergio_coutinho With 6 variables values start jumping in a strange way.

        Can you say more about this? I am wondering if what's happening is that the data is received and passed to Pd just fine and the issue is only with the printing

          giuliomoro hey,

          Arduino:

          Serial.print(aX, 0);
            Serial.print(" ");
            Serial.print(aY, 2);
            Serial.print(" ");
            Serial.print(aZ, 2);
            Serial.print(" ");
            Serial.print(aSqrt, 2);
            Serial.print(" ");
            Serial.print(gX, 0);
            Serial.print(" ");
            Serial.print(gY, 0);
            Serial.print(" ");
            Serial.print(gZ, 0);
            Serial.print(" ");
            Serial.print(val_bme_temp, 0);
            Serial.print(" ");
            Serial.print(val_bme_press, 0);
            Serial.print(" ");
            Serial.print(val_bme_alti, 0);
            Serial.print(" ");
            Serial.print(val_bme_humi, 0);
            Serial.print(" ");
            Serial.print(val_peso, 0);
            Serial.print("\n");
            delay(200);

          and in Bela PureData, i've tried multiple prints, but the ones that should work:

          Inconsistent readings, at least printing:

          nothing shows on the last unpacked float, and the first ones are inconsistent (like the console printed values)

          Thank you for your help again!

          ok thanks that's available for everyone on the dev branch now. If you update your board to that, you will no longer need the cpp file in the project and the update will apply across all projects.

            2 months later

            What if I don't want to connect via the USB cable, but instead via the Arduino Tx and Rx pins? Could I connect those pins (with a logic level shifter?) to the Bela somehow and have at least one-way serial communication from the Arduino to PD on the Bela? Which pins would I use in the Bela? And how would I define the serial port in PD?