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
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
#endif
#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif
uint8_t ble_rx_buffer[21];
uint8_t ble_rx_buffer_len = 0;
uint8_t ble_connection_state = false;
#define PIPE_UART_OVER_BTLE_UART_TX_TX 0
void setup() {
SerialMonitorInterface.begin(9600);
while (!SerialMonitorInterface); //This line will block until a serial monitor is opened with TinyScreen+!
BLEsetup();
}
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);
SerialMonitorInterface.print(" : ");
SerialMonitorInterface.println((char*)ble_rx_buffer);
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();
sendLength++;
}
if (SerialMonitorInterface.available()) {
SerialMonitorInterface.print(F("Input truncated, dropped: "));
if (SerialMonitorInterface.available()) {
SerialMonitorInterface.write(SerialMonitorInterface.read());
}
}
sendBuffer[sendLength] = '\0'; //Terminate string
sendLength++;
if (!lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, (uint8_t*)sendBuffer, sendLength))
{
SerialMonitorInterface.println(F("TX dropped!"));
}
}
}