STM32F103C8T6 and Arduino nano serial communication

Post here first, or if you can't find a relevant section!
Post Reply
blauau1
Posts: 2
Joined: Wed Feb 26, 2020 3:56 pm

STM32F103C8T6 and Arduino nano serial communication

Post by blauau1 »

Hello!
I have a next code in in my Arduino nano:

Code: Select all

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
}
void loop() // run over and over
{
  mySerial.write("Software serial from Arduino Nano\n");
  delay(500);
}

If i connect the D2 and D3 to my TTL, i can read the message at 9600 baud, but if i connect the Tx->Rx and Rx->Tx to my STM32F103C8T6 (Blue pill) with a next code:

Code: Select all

#include "stm32f103c8t6.h"
#include "mbed.h"
#include "USBSerial.h"
#include "Crypto.h"

int main() {
    Serial pc(PA_2, PA_3);
    Serial nano(PA_9, PA_10);
while(1) 
    {
     //AES data here

     if(nano.readable()) 
        {
            printf("Nano is here!\n");
            char c[128];
            nano.gets(c, 4);
            pc.printf("I got c line: %s \n", c);
        }
        else
        {
            pc.printf("Nano is unreadable\n");
        }
        wait_ms(1000);
    }
}

On the PA_2, PA_3 is an USB TTL, that send some encrypted data to one PC. The PA_9 and PA10 are connected to Arduino Nano, and i wish to read the data from Nano on the BluePill with this UART, but i always receive that a Nano in unreadable. Have try to change the Tx-Rx wires, but nothing. Why will not work a simultaneous use of two serials?
The pc.printf function works like a charm, i can read it on my PC, but the STM32 can't receive the data from the Nano.
I use the mbed online ide tool to compile for STM32 and the standard arduino IDE for work with a arduino.
by Juraj » Wed Feb 26, 2020 5:22 pm
sorry, but this forum is about STM32 dev boards used as Arduino. you use mbed
Go to full post

User avatar
Juraj
Posts: 28
Joined: Fri Jan 03, 2020 7:47 pm
Answers: 1
Location: Slovakia
Contact:

Re: STM32F103C8T6 and Arduino nano serial communication

Post by Juraj »

sorry, but this forum is about STM32 dev boards used as Arduino. you use mbed

Post Reply

Return to “General discussion”