Reputation: 73
I have a next code in in my Arduino nano:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
void setup()
{
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Native USB only
}
// 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:
#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);
printf("I got c line: %s \n", c);
}
else
{
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 simultanous use of two serbials?
Upvotes: 0
Views: 1848
Reputation: 26
Try setting a baud rate for the Nano on the Blue Pill-it doesn't look like you ever set one in your script. You may also need to include Software Serial like you do on your Nano-the Blue Pill may not have the library it needs otherwise to communicate.
Note, I haven't worked with a Blue Pill before so I'm not sure of how similar or different it is from the Nano.
Upvotes: 0