I want to STM32f103c (Blue pill) board to communicate with esp8266-12E and neo 6m GPS modules with blue pill. And i have used this module before with arduino uno and mega and get wanted results. but when i used blue pill to communicate with esp8266-12E, it is not working through Serial1, Serial2, Serial3 (i have checked one by one). So i have made simple code which can check output of Serial2(or any one of the three).
as below,
char a;
void setup() {
Serial.begin(115200);
Serial2.begin(115200);
//our setup code here, to run once:
}
void loop() {
if(Serial2.available()>0)
{
a=Serial2.read(); // will check Serial2 recevied data
}
Serial2.write("HII"); // will send to other serial monitor(in different pc)
Serial.println(a);
delay(1000);
// put your main code here, to run repeatedly:
}
A quick search of the forum will give you quite a few versions of this – I had similar issues but solved them quickly by reading recent threads.
If using the STM core: viewtopic.php?f=3&t=4200
If using the LibMaple core (a.k.a. Roger’s Core) serial works out of the box.
If using the Generic Core you’re on your own, not a clue – I tried it first, realised the project isnt active and dropped it.
My advice if using Arduino for STM32 is to read the basics here before doing anything else:
viewtopic.php?f=2&t=3111 “*** PLEASE READ THIS FIRST ****”
viewtopic.php?f=55&t=2465 “What STM32 board should you buy”
http://wiki.stm32duino.com/index.php?title=API “API”
viewtopic.php?f=55&t=2471 “FAQ’s and links”
Probably this might help:
https://danieleff.github.io/STM32GENERIC/uart/
I did a GPS project with MM here.
I connected a Bluepill to a Raspberry Pi here. (same concept as ESP8266/ESP32)
Ray
/*
BlinkNcount_BP3 by m. ray burnette
Turns on an LED on for one second, then off for one second, repeatedly.
Counts and displays the count on the attached serial monitor
Example is for Blue Pill, outputs on all 3 serial ports
*/
int n = 0;
void setup() {
// initialize the digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
// Initialize virtual COM over USB on bluepill
Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART
Serial1.begin(9600);
Serial2.begin(9600);
// wait for serial monitor to be connected.
while (!Serial)
{
digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN)); // Turn the LED from off to on, or on to off
delay(100); // fast blink
}
Serial.println("Blink LED & count Demo");
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // set the LED on
delay(500); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // set the LED off
// Serial.print("Loop #: ");
n++;
Serial.print("Serial: ") ; Serial.println(n);
Serial1.print("Serial1: ") ; Serial1.println(n);
Serial2.print("Serial2: ") ; Serial2.println(n);
delay(500); // wait
}
This means that
Serial == USART1, and SERIAL2 == USART3.
Take this into consideration when choosing the pins to connect the serial interface.
Serial & USB Serial
Serial USB is enabled for all F103 boards when uploading using the bootloader, it is also available when uploading by ST-Link (SWD) In these cases:
Serial.print(“Hello world”); will print via Serial USB (CDC).
Serial1 prints to hardware USART 1
Serial2 prints to hardware USART 2
etc
When uploading via “Serial” (external USB to Serial adaptor connected to PA9 and PA10 (USART1) on the STM32):
Serial.print(“Hello world”); will print to hardware USART1 (the one the code was uploaded using)
Serial1 prints to hardware USART 2
etc
Note. Some boards, e.g. Nucleo F103RB have special serial mapping, because these boards need to have hardware modification to make Serial usable.
The Serial <-> USART mapping is defined in file “variants/<board_name>/board.cpp”.
ALL MEMBERS:
This is the 3rd time I or someone else has answered nearly identical “serial” questions in the past few days. I’m am annoyed because a forum/Google search will quickly return the information. When using Google against the site, use <terms> site:stm32duino.com
So, start searching. It’s actually easier to just block user access to the forum for 24 hours for members that abuse the site by flooding it with already-answered dialog.
Ray
It worked for me.
[pareidolialjebus – Mon Oct 08, 2018 5:06 am] –
.. Generic Core ….,- I tried it first, realised the project isnt active and dropped it.
BTW.: That’s not correct. The Huaweixx branch is probably the branch where the most development takes place.
But … for some reason it does not work on my computer ….
[ChrisMicro – Mon Oct 08, 2018 5:06 pm] –[pareidolialjebus – Mon Oct 08, 2018 5:06 am] –
.. Generic Core ….,- I tried it first, realised the project isnt active and dropped it.BTW.: That’s not correct. The Huaweixx branch is probably the branch where the most development takes place.
But … for some reason it does not work on my computer ….
Good to know – I took my info from here: viewtopic.php?f=2&t=3111
“3. An alternative generic core: *OUTDATED not under development anymore * edited: 23.08.2013
https://github.com/danieleff/STM32GENERIC“
[pareidolialjebus – Mon Oct 08, 2018 9:30 pm] –[ChrisMicro – Mon Oct 08, 2018 5:06 pm] –[pareidolialjebus – Mon Oct 08, 2018 5:06 am] –
.. Generic Core ….,- I tried it first, realised the project isnt active and dropped it.BTW.: That’s not correct. The Huaweixx branch is probably the branch where the most development takes place.
But … for some reason it does not work on my computer ….
Good to know – I took my info from here: viewtopic.php?f=2&t=3111
The item #3 is correct… going off and finding some non-member, similar core on github does not mean that it is a substitute for Daniel’s core – a core which is basically a wrapper around HAL. Now that STM has a nicely evolved Official Core, there really are only two (2) actively supported cores from this forum viewpoint – deviate if you will, but you will be in self-supported waters.
Ray



