Trouble with Timing STM32F411RE with hc05 and android app

Here is my app so far! Will post the MIT app file soon.

Really frustrated with this thing now!! So close yet so far away! Three major issues!

One the uart1 I’m using to communicate to the hc05 is not allowing me to have interrupt on rx receiving transmissions? If I jump a wire from rx to tx (loop back) the interrupt works fine, so it should be coded correctly.

Anyway then I have to use blocking functions in polling mode to read the data from the hc05 which doesn’t help with timing issues!!

And two I am transmitting tx data from the stm32 to the hc05 then to my app. Rpm, steps, delay, and motor running flag.

This takes a lot of processing attempting to send as a CSV string. And using sprintf causes a pretty decent lag.

And thirdly the problem with the app is that mit app inventor doesn’t have and function to have an interrupt when the tx data from the stm32 is available. So I am using a procedure called anytime a button is pressed then using a clock to set a delay then read the the incoming message, this never works even with delay as little as 100ms or as big as 9 seconds!

I also just tried to read the tx data in a clock function set at 300 ms intervals and it sorta worked but then the motor doesn’t stay running nor does the gif in the app stay running! In fact the gif has a major pause everytime the timer is up.

One solution could be to store steps, delay, rpm in the app, so the app is master Then only send the updated values to the hc05 and then the stm32, so just one way communication

I could also use dma for uart and my own sprintf to cut the time down

My GitHub

Try a search for hc05 on the community, or widen your search with arduino


Thanks I understand I posted a mess! I cleaned it up and it is working quite well! My main issue was that I was not getting the last message. I fixed this by getting all available bytes, then subtracting the string length I am sending from the STM32, this discards those olde messages. Then I read the next line with -1 checking for '/r'. I also changed baud rate to 115200, and cleaned up the stm32 code a bit. I will post my latest .aia file GitHub shortly.

My latest issue is sending a initialization message to let the stm32 know to start broadcasting data, and to start checking received data. It should be '14\r\n' but I struggle to get the first or second bytes. I also have to send it multiple times, and send a dummy message. It is working like this but what a mess. Why is the first message so hard to get out? I am getting 21 now at the stm32 and just made a change from 14 to 21 for now on the stm32. Anyway I took a screen shot of the block for this part.

I also cannot get the Click on motor to start/stop to show up it is in horizontAlarrangement4.

Motor_Control_Jamie_BTM_2 .aia is the latest file on my GitHub

And here is my video showing how it works now:
STM3F411RE with android MIT app inventor HC05 Bluetooth part 2