[SOLVED] Getting TinyShield (BlueNRG-MS chipset) to work with Blynk

Evening acca,

Do you mind posting your code that you managed to get the BT shield working correctly? -> Using the app and being able to send commands and receive sensors readouts.

I am also having difficulties in implementing the older libraries from the Nordic edition that is everywhere on the net for the ST chip/module. My aim is to simply toggle the digital output pins, using a serial-based app.

Thank you in advance.

Kind regards,

@AndreBroekman You didn’t mention details on all of the hardware you are using.

Have you checked out Blynk’s Sketch builder (Links at the upper right of this page), using the various supported BT/BLE modules?


Hi Gunner,

Thank you for your reply! I actually just stumbled upon the whole Blynk environment yesterday, that is definitely a viable alternative as you suggest.

My hardware setup:
A TinyDuino stack consisting of:
Processor board
USB Programmer
Proto board where I plan to connect my digital IC switch
And lastly, the item this post is about, the Bluetooth LE shield (https://tinycircuits.com/collections/communication/products/bluetooth-low-energy-tinyshield)

This TinyShield is based around the BlueNRG-MS chipset by STMicroelectronics, which comes in the SPBTLE-RF module. The TinyShield also includes power supply and level shifters on the board, so you can run your TinyDuino from 3.0V – 5V. - website description.

I started out using the UART pass through example sketch provided on TinyCircuit’s BT shield’s info page. Works like a charm, passing information from an App (tried nRF UART v2.0 as recommended, Bluefruit LE, BLE Scanner and nRF Toolkit, all without any issues (on Android)). I can see the on board LED flashing when information is passed through.

The second alternative I tried was to create a peripheral device using: https://github.com/sandeepmistry/arduino-BLEPeripheral
Takes up more space but you don’t need any other 3rd party application to actually write the necessary behaviors. I tinkered with this but I cannot even get the BT module to broadcast anything / boot up.

My aim is to simply send a single character or short string, parse that information, and then toggle the digital output pins. I also had a look at TinyCircuit’s smart watch code, on how they check the first character of the received string, and perform a function, e.g., if string[0] == “t” -> update time. This approach, which is based on the older Nordic chip, doesn’t seem to translate for the new chip if I try and adapt the code. If you look at the newer tutorial page for the ST edition BT chip (which I am using), it was uploaded only 6 weeks ago. Hence my frustration is getting any working examples of interfacing with the new ST edition chip; any Instructable page or example from TinyCircuits is based on the Nordic chip edition.

I will add the example UART pass-through code at the very end of this post that is supplied by TinyCircuit. Any help will be highly regarded.
Just a note, I am using this for my Master’s dissertation project, and will reference any code accordingly. I am currently a post-grad student at the Department of Civil Engineering at the University of Pretoria, South Africa, specializing in railway instrumentation. Haven’t played that much with Arduino but have read up on it extensively over the years, and I’m busy brushing up my knowledge on BT and its protocols :blush:

Kind regards,

Andre Broekman

The example code which I want to adapt to switching digital pins.
******* ARDUINO CODE EXAMPLE *******

//  TinyCircuits ST BLE TinyShield UART Example Sketch
//  Last Updated 2 March 2016
//  This demo sets up the BlueNRG-MS chipset of the ST BLE module for compatiblity 
//  with Nordic's virtual UART connection, and can pass data between the Arduino
//  serial monitor and Nordic nRF UART V2.0 app or another compatible BLE
//  terminal. This example is written specifically to be fairly code compatible
//  with the Nordic NRF8001 example, with a replacement UART.ino file with
//  'aci_loop' and 'BLEsetup' functions to allow easy replacement. 
//  Written by Ben Rose, TinyCircuits http://tinycircuits.com

#include <SPI.h>
#include <STBLE.h>

//Debug output adds extra flash and memory requirements!
#ifndef BLE_DEBUG
#define BLE_DEBUG true

#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB

uint8_t ble_rx_buffer[21];
uint8_t ble_rx_buffer_len = 0;
uint8_t ble_connection_state = false;

void setup() {
  while (!SerialMonitorInterface); //This line will block until a serial monitor is opened with TinyScreen+!

void loop() {
  aci_loop();//Process any ACI commands or events from the NRF8001- main BLE handler, must run often. Keep main loop short.
  if (ble_rx_buffer_len) {//Check if data is available
    SerialMonitorInterface.print(" : ");
    ble_rx_buffer_len = 0;//clear afer reading
  if (SerialMonitorInterface.available()) {//Check if serial input is available to send
    delay(10);//should catch input
    uint8_t sendBuffer[21];
    uint8_t sendLength = 0;
    while (SerialMonitorInterface.available() && sendLength < 19) {
      sendBuffer[sendLength] = SerialMonitorInterface.read();
    if (SerialMonitorInterface.available()) {
      SerialMonitorInterface.print(F("Input truncated, dropped: "));
      if (SerialMonitorInterface.available()) {
    sendBuffer[sendLength] = '\0'; //Terminate string
    if (!lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, (uint8_t*)sendBuffer, sendLength))
      SerialMonitorInterface.println(F("TX dropped!"));

Something you might not be aware of… Blynk normally runs in a App <-> Server <-> Hardware configuration with all three connecting via a network/internet.

With BT/BLE, Blynk still needs the server link to the App, but the App communicates directly to the hardware via Blynk’s independent and non-user-accessible BT/BLE link.

So you will not be able to treat it as you would any typical BT/BLE connection between an App and hardware. Thus your current code can not be simply converted to a Blynk sketch by adding in Blynk’s pin control commands.

First thing is to determine if your BLE module is even compatible with Blynk… so far there are only four options to chose from in the Sketch Builder, so you would have to load in a basic Blynk BLE sketch and try each one out at a time (just a few library changes and module pinouts between them).

Your TinyDuino should be fully UNO compatible, so chose UNO both in the App and the Sketch Builder:


In the App you will need to add in the BLE widget and get it connected to your module.

With this sketch working, you should be able to assign widgets like button or slider to digital pins and see the results on the hardware.

1 Like

Dear Andre,

First of all, please excuse my late rely.
Unfortunately in the end I had to abruptly change work topic and therefore I didn´t manage to work on the BT shield + tinyscreen project… :frowning:

Hopefully I will be able to go back to it eventually and update the Blynk community on my progress.

Good luck with your work! :slight_smile:

I’m just beginning research about how to use Blynk with BLE connection to custom hardware.
This App <-> Server <-> Hardware configuration is good to know about.
Do you know what is the purpose of connection to Server when using direct connection like BLE?
What are limitation of BLE connection (ie. device status in App, etc) ?