STM32 + FreeRTOS + Blynk

Hello guys,

Do you have the port for STM32 + FreeRTOS?

I have several projects for realtime tracking (Fleet management, GNSS trackers ans so on) and I am looking for some solution to get data visualization - try different from current telematic server solution.

I have played already with Blynk for Arduino UNO + ESP (never used all these before) - for several hours made the mobile app and HW design (breadboard based) + sketch for several sensors and actuators (PIR, MIC, Reed, Temperature + Humidity, Motion (LIS3DH) and Light, RGB LED). It works good, but not stable - need some improvement in HW and FW as well. 89% of Code 63% of RAM are used. Also EEPROM was added to save SSID, Pass and Token.
Still thinking how to add SW or HW Serial to make configuration - no way to make it in realtime - Blynk is being disconnected all time due to SWSerial is waiting for incoming stream (It seems needs to make some workaround for making device setting via USB-FTDI). Another issue - adding BlynkTimer - even with empty body - the same reconnecting issue, it seems it is related with ATMega328 performance.

Anyway, It is funny enough and I would like to try it for STM based projects. I did not investigate the Blynk lib itself yet.
As plan - put Blynk to separate task or two to keep proper communication.

From HW perspective it is:
STM32F1 / STM32F2 / STM32L1 + GSM/3G/NB-IOT and WiFi modules.

Regards,
Alexander A.

HW + iPhone App.

Arduino/ESP mergers do work, but take some hardware connection design effort, proper use of timing and good coding to balance out… Try running on dedicated ESP8266 dev boards… no SW HW serial issues there.

Hi Gunner,

thanks for reply.

I am new in Arduino - it was just for fun.

SW / HW Serial - I meant something different - how can I communicate with Arduino via USB - FTDI (from PC for example, to make some settings) by HW or SW Serial during Blynk runs (The second Serial ( in my current case SW) is connected to ESP)?

Putting Serial.read() or Serial.available() calls make Blynk reconnect all time.

One way to make configuration from PC I see now, just make it in setup() or once in loop() - just wait for sometime (10 - 15 sec) after power up or USB connection done(in battery power case). If no data from PC - just nove to regular case and forget about serial input at all.

Any ideas are welcome.

Regadrs,
Alexander A.

I am not quite sure I follow… but here is a guess:

When combining an Arduino UNO and an ESP, the usual way is via Software Serial (becasue the Hardware UART is for programming and Serial Monitor)… slow and not very reliable… and you CANNOT use anything else on that SW Serial port or it will cause disconnections.

Even when using the Serial Monitor on the HW Serial (UART) port, you cannot block the background Blynk/Sever link with a “waiting for input” command; You will need to code (Serial.read() or Serial.available() ) commands accordingly in order to keep Blynk connected.

I have Arduino and ESP connected by SW UART. The speed is 9600 - it seems stable.
Blynk Serial is OFF - no logging from Blynk.
Serial Monitor and HW UART work fine for some logging out and for programming of cause.
But, how can I get the input string from that UART?
I totally understand that loop() should not be blocked with any delays, but as I see read() and available() calls are waiting the symbol from the UART for some time… and this is the reconnect issue rootcause.

But, the question - how to get the second UART working the same time with Blynk?

I can exlplain why I need it - if consider some consumer product case: you have got the device from the box and you need to configure it (WiFi + Token) - I see just one way for end user - to use PC (some another case exists, but I would like to consider USB / PC case).

Or am I wrong? and some another approach exists?

Regadrs,
Alexander A.

Any consumer prospect would never use an Arduino/ESP combo, or serial monitor for that matter. Look into (search) WiFi provisioning on this forum for that solution with standalone ESP devices.

Exactly… but as a case…

as I understand - no solution to get the second UART working together with Blynk - correct?

the part of sketch: if(0)//Serial.peek() != -1) - commented to get Blynk working

void loop()
{
  char serial_byte;
  
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
  
//  timer.run(); // Initiates BlynkTimer

  if(0)//Serial.peek() != -1) 
  {
    while(Serial.peek() != -1) 
    {
      serial_byte = Serial.read();

      serial_buf[serial_buf_idx] = serial_byte;

      if(serial_byte == '\n' || serial_byte == '\r')
      {
        serial_buf[serial_buf_idx] = 0;
        serial_buf_idx = 0;

        // Parse the string
      }
      else
      {
        serial_buf_idx++;
        if(serial_buf_idx >= SERIAL_BUF_SIZE)
        {
          serial_buf_idx = 0;
        }
      }
    }
  }
}

as another simple case (instead of PC) with the second UART - connect GPS to get location. :slight_smile:

Oh, it can be done… but exactly how to manage the timing and limit the blocking… not something I have experimented with much lately, and I tend to forget how to code specifics without repetition.

Agree.

but it seems that regular way, using Arduino libs it is impossible.

WiFi provisioning - correct, it is the second way I though. But needs to bring some money to get this feature working in Blynk environment. :slight_smile:

Thanks,
Alexander A.

If you want a published product, yes… but I believe there are ways for using something similar in the free development level.

I have to admit I don’t know how to myself yet, but keep looking for WifiManager by @tzapulica

Gunner,

Thank you.

Regards,
Alexander A.

Hi,
Are there any libraries that support STM32?I want to use STM32 and HC05 ,but i can not find libraries for STM32.

@TonyL you can use STM32 with Blynk on Arduino or MBED platform. Or you can take our C++ library and adapt it to your needs