Interface Arduino Bonsai

1,765 views
Skip to first unread message

marcelo....@neuro.fchampalimaud.org

unread,
Jul 4, 2016, 2:04:56 PM7/4/16
to Bonsai Users

Hi to all, 

I have been using bonsai, but now I am adding some Arduino-based stuff (that I am new at) that I want to align with the rest of behaviour (cameras).

My simple question is: I am trying to read in Bonsai the same thing i have in the Serial Monitor of Arduino (in my case a series of 0s and 1s, that corresponds to the TTL sign I'm receiving in Arduino).
I've been using the DigitalInput in Bonsai and it does not get nothing. I've set up the baudrate to 57600 and still nothing. .

Could it have to do with my arduino code?
// the setup routine runs once when you press reset:
void setup() {
  Serial.begin(57600);
}

// the loop routine runs over and over again forever:
void loop() {
  int sensorValue = digitalRead(2);
  Serial.println(sensorValue);
}

Or with the port configuration in Bonsai?

Thanks for your precious help
(This is my beautiful signal)


goncaloclopes

unread,
Jul 4, 2016, 11:03:21 PM7/4/16
to Bonsai Users
Hi Marcelo and welcome to the forums!

In order to use the DigitalInput node in Bonsai, you need to install Firmata on your microcontroller. If you just want to read from the serial port directly, you have to use the SerialStringRead node.
You can read more about both options in this previous forum post.

Hope this helps.

marcelo....@neuro.fchampalimaud.org

unread,
Jul 5, 2016, 1:15:30 PM7/5/16
to Bonsai Users
Hey Gonçalo,
Thanks for your fast reply.

I've tried to install Firmata, and use the DigitalInput and nothing. The SerialStringRead node also is not allowing me to obtain nothing there.
I can't read the serial out in Bonsai (but I can read it both on Python and on the arduino serial monitor).
(To overcome any code-related problem I've used the Arduino sketch of someone in the lab that has been able to read things from arduino, just in case...)

Any suggestion?
Thanks, 
Marcelo

goncaloclopes

unread,
Jul 6, 2016, 9:33:52 AM7/6/16
to Bonsai Users
Hi Marcelo,

The most common problem is a mismatch in baud rates between client and host. They need to be exactly the same numbers for communication to work. You can check and change which one Bonsai is using by clicking on the "Manage Ports" button in the property grid, where you choose the serial port:


In the following dialog, you can add serial port configurations or change existing ones. Please note that the default BaudRate for Firmata nodes is different than the default BaudRate for generic SerialPort nodes. The reason is that the serial port doesn't know anything about Arduino or Firmata, so it doesn't assume anything about required bandwidth (i.e. it assumes you need little).

If you do verify that you have matching baud rates and still communication is not happening with both Arduino and Firmata nodes, please provide as detailed a description of your setup and computer as possible (operating system version, Arduino model, etc). Also please indicate the status of Arduino blinking LEDs. When opening and exchanging serial port data, the Arduino LEDs will blink characteristically. I would need to know what the status of these LEDs are.

You also mention that someone in your lab was able to read data from the Arduino. What is the difference from their setup to yours?

Hope this helps.

Auto Generated Inline Image 1

marcelo....@neuro.fchampalimaud.org

unread,
Jul 6, 2016, 10:48:49 AM7/6/16
to Bonsai Users
It was exactly that think of not finding the "Manage Ports" button!

Sorry for the trouble and thank you Gonçalo (and Bruno Cruz also!)
Reply all
Reply to author
Forward
0 new messages