I would like to install Processing4 on the Arduino Uno Q to pass/receive data with the MCU via UART. As far as I understand the bridge library transfers data between CPU and MCU via uart and spi but only with the python installed on the SBC . At this point the question is whether the SBC has any UART/SPI interface that is exposed outside the bridge library and can be used to communicate with the MCU?
The UnoQ uses UART for its bridge.
There is a SPI interface available and quite frankly you could disable the bridge and take over the UART connection as well..
good luck.. ~q
@qubits-us Do you know where can I find details about how do it?
The Uno Q STM32 has two UARTs. One (Serial1) is used for the RouterBridge. The
other UART (Serial) is connected to the board Tx(1) and Rx(0) pins. To use the other
UART, connect GND, 0, 1 to a USB UART cable. Be sure the cable uses 3.3V logic
levels. Plug the USB end of the cable to the USB hub connected to the Uno Q.
This means the Uno Q must be running in SBC mode.
Alternatively, the RouterBridge supports TCP and UDP sockets. No need for the
USB UART cable. No need to run in SBC mode.
A regular Linux app can communicate with a sketch running on the STM32 using
TCP. The Uno Q User Manual includes an example of a sketch accessing a time
server using TCP.
The Arduino RouterBridge github repo has more examples.
Not sure I'll be of much more use as I do not know Processing at all..
and Yes, good point, you are also suppose to be able to use the bridge from Linux as well, I have not attempted as of yet..
I did do a SPI Logger in c..
Lot's of info on the board..
~q
Hi @bob63. I like the simplicity of the solution offered by @customcontroller in post #4. However, in case you are still interested in direct communication between the Linux machine and the sketch program over the board's internal UART interface, I'll provide instructions you can follow for a simple demonstration of doing that:
A. Disable arduino-router Service
As @qubits-us already stated, the UART interface is normally controlled by the "bridge" system. On the Linux machine of the UNO Q, this is handled by a tool named arduino-router. This tool runs in the background on the UNO Q's Linux machine as a service.
Only one process can have control over a serial port at a time. If you attempted to access it from Processing while the arduino-router service had control over it, that attempt would fail with an error something like "Device or resource busy".
For this reason, it would be necessary to first stop the arduino-router service if you wanted to use the UART interface in another manner than the standard Arduino bridge system.
Attempting to start an Arduino App will fail if the arduino-router service is not running. Likewise, you will not be able to use the Arduino_RouterBridge library's capabilities (i.e., Bridge and Monitor) in your sketches when it is not running.
- Open a shell terminal on the UNO Q's Linux Machine.
A convenient way to accomplish this is to start Arduino App Lab, connect it to your UNO Q board, then click the >_ button ("Connect to the board's shell") near the bottom left corner of the Arduino App Lab window. - Type the following command in the terminal:
sudo systemctl stop arduino-router - Press the Enter key.
- A prompt will now appear:
Type the password you set up for the[sudo] password for arduino:arduinoLinux user account. - Press the Enter key.
B. Upload Sketch Program
You are now prepared to communicate directly via UART directly from the Linux machine, but that won't accomplish anything if the program running on the microcontroller doesn't do anything with it. I'll provide a simple Arduino sketch that will blink the red LED on the UNO Q when it receives data via the UART:
- Start Arduino IDE.
- Select File > New Sketch from the Arduino IDE menus.
A new sketch will open in an Arduino IDE window. - Replace the default code in the new sketch with the following code:
int ledState; void setup() { pinMode(LED_BUILTIN, OUTPUT); Serial1.begin(115200); // The UART on the Linux machine is configured at 115200 baud by default. } void loop() { if (Serial1.available() > 0) { Serial1.read(); // Clear a byte of the received data from the buffer. // Toggle LED to indicate data was received. if (ledState == LOW) { ledState = HIGH; } else { ledState = LOW; } digitalWrite(LED_BUILTIN, ledState); delay(50); // Ensure visibility of toggle if multiple bytes are received in succession. } } - Select Tools > Board > Arduino UNO Q Board from the Arduino IDE menus.
- Select Tools > Flash mode > Flash from the Arduino IDE menus.
โ If you select the alternative "RAM" option, sketch uploads will fail while thearduino-routerservice is stopped. - Select Tools > Startup mode > Immediate from the Arduino IDE menus.
- Select the port of the UNO Q board from Arduino IDE's Tools > Port menu.
- Select Sketch > Upload from the Arduino IDE menus.
- Wait for the sketch upload to finish successfully.
C. Communicate over UART
-
Open the shell terminal on the UNO Q's Linux machine.
-
Type the following command in the terminal:
echo "hello" > /dev/ttyHS0echo "hello" > /dev/ttyHS1 -
Watch the LEDs that are marked "STM" on the UNO Q board.
-
Press the Enter key.
You should now see the red LED flash several times quickly.
There is some related discussion you might find interesting here:
@customcontroller ans @ptillisch , thank you both for the useful suggestions.
Asap I'll try to apply both way and I'll provide feed back .
tks.
@ptillisch I'm trying your example but I have this error when I try to send data from Linux
arduino@Robi:/$ sudo systemctl stop arduino-router
[sudo] password for arduino:
arduino@Robi:/$ echo "hello" > /dev/ttyHS0
bash: /dev/ttyHS0: Permission denied
arduino@Robi:/$ sudo echo "hello" > /dev/ttyHS0
bash: /dev/ttyHS0: Permission denied
arduino@Robi:/$type or paste code here
Where I'm wrong?
@ptillisch I've solved , the interface is ttyHS1 and not ttyHS0 .