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.