Page 1 of 1

Serial comunication beetwen Arduino and STM32 F401RE with Arduino ide

Posted: Tue Nov 23, 2021 8:23 pm
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

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

Posted: Tue Nov 23, 2021 8:48 pm
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

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

Posted: Wed Nov 24, 2021 8:19 am
by andreealombardo
I'm using STM32F401RE, with core Arm Cortex-M4

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

Posted: Wed Nov 24, 2021 8:25 am
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

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

Posted: Wed Nov 24, 2021 9:40 am
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.