Serial comunication beetwen Arduino and STM32 F401RE with Arduino ide

Post here first, or if you can't find a relevant section!
Post Reply
andreealombardo
Posts: 2
Joined: Tue Nov 23, 2021 8:16 pm

Serial comunication beetwen Arduino and STM32 F401RE with Arduino ide

Post by andreealombardo »

How can I pass through the serial ports an arduino number to the STM32 F401RE? Using the Arduino IDE? For now I have done this:
(i should do all this using just the arduino ide)

Code Arduino (TX)


int valueTX=5;

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print(valueTX);
}

Code STM32 F401RE (RX)

int valueRX;

void setup() {
Serial.begin(9600);
}

void loop() {
if(Serial.available()){
valueRX=Serial.read();
Serial.print(valueRX);
}
}

But the STM32 F401RE does not print 5, but -1, I do not understand why
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Serial comunication beetwen Arduino and STM32 F401RE with Arduino ide

Post by ag123 »

you'd need to explain what board you are using and which core you are using
viewtopic.php?f=2&t=3
viewtopic.php?f=2&t=301
andreealombardo
Posts: 2
Joined: Tue Nov 23, 2021 8:16 pm

Re: Serial comunication beetwen Arduino and STM32 F401RE with Arduino ide

Post by andreealombardo »

I'm using STM32F401RE, with core Arm Cortex-M4
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Serial comunication beetwen Arduino and STM32 F401RE with Arduino ide

Post by ag123 »

There are a few ways to move forward, you can present the schematics of the board (or a link). Nobody knows what is on your board to guess what is the problem. In addition you need to state the core you are using and if you are using usb (CDC) serial.
or you can choose your board from the list
https://github.com/stm32duino/Arduino_Core_STM32
note that install instructions for the stm32duino core is found here
https://github.com/stm32duino/wiki/wiki
ozcar
Posts: 143
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 5

Re: Serial comunication beetwen Arduino and STM32 F401RE with Arduino ide

Post by ozcar »

How have you wired things up? You seem to expect the Serial.read() on the F401 to read what came from the Arduino, but that Serial.print on the F401 will print the result so that you can see what was received.

Besides that, the Serial.print(valueTX) on the Arduino will convert valueTX to a character string, but the Serial.read() on the F401 will not convert back to int. Edit: at least I don't think so - I seem to remember having to use Serial.parseInt() to do that, but that was not using Stm32duino.
Post Reply

Return to “General discussion”