BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Arduino and HM-10

I am experimenting with Arduino Mega 2560 and HC-08 BLE module (a clone of HM-10).

My results are:

  1. Never use SoftwareSerial to comunicate with HM-10 because it is the reason of “Packet too big” error

  2. BLE widget on Android app cannot connect. I personally tested Android 8 (Samsung A5 and Xiaomi redmi Note 5), Android 5.0.1 and Android 4.4.2 with no succes. May be HC-08 is not a fully compatible HM-10 device. Do you know if the original HM-10 works like a charm?

  3. iOS app works better but it is not perfect. BLE widget connect to HC-08 but device is not reported online even if communication is established. Data from the app to arduino works. Any communication from arduino to the app doesn’t work. BLYNK_WRITE(vPin) works but virtualWrite() doesn’t update virtual pin on the app.

When the BLE widget will be out of the beta phase?

Thanks

Wow that really sounds strange. I have never experienced anything like that on my Arduino + Hm-10 setup. I use software serial though: A classic one : Arduino + Iphone + nrf8001

It works with simple sketch (see below) but it doesn’t works with more complex scketch. Blynk protocol looks the same on debug print. I will add some debug output.


#define BLYNK_DEBUG
#define BLYNK_USE_DIRECT_CONNECT

#define BLYNK_PRINT Serial
#include <BlynkSimpleSerialBLE.h>

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

WidgetLED led1(V1);

BLYNK_WRITE(V0) {
  //(param.asInt()) ? led1.on() : led1.off();
  (param.asInt()) ? Blynk.virtualWrite(V1, 255) : Blynk.virtualWrite(V1, 0);
}

void setup()
{
  Serial.begin(115200);

  Serial1.begin(9600);
  Blynk.begin(Serial1, auth);
}

void loop()
{
  Blynk.run();
}

Here in the following the debug of Blynk protocol of some virtualWrite that do not change the state of widget in the app. Do you see anything wrong?

Thanks

[418] Connecting...
[15791] >[02|00|01|00] 
[15836] >xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[15837] Ready
[15838] Free RAM: 3180
Connected to Blynk
[15840] <[14|00|01|00|07]vw[00]20[00]6
[15950] <[14|00|02|00|08]vw[00]30[00]16
[16059] <[14|00|03|00|07]vw[00]21[00]2
[16167] <[14|00|04|00|07]vw[00]22[00]2
[16275] <[14|00|05|00|08]vw[00]23[00]31
[16384] <[14|00|06|00|09]vw[00]24[00]127
[16492] <[14|00|07|00|07]vw[00]25[00]0
[16601] <[14|00|08|00|07]vw[00]33[00]1
[16709] <[14|00|09|00|07]vw[00]34[00]1
[16818] <[14|00|0A|00|07]vw[00]38[00]1
[16926] <[14|00|0B|00|08]vw[00]51[00]34
[17034] <[14|00|0C|00|09]vw[00]52[00]930
[17143] <[14|00|0D|00|07]vw[00]40[00]3
[17251] <[14|00|0E|00|07]vw[00]41[00]1
[17359] <[14|00|0F|00|07]vw[00]42[00]1
[17467] <[14|00|10|00|07]vw[00]43[00]0
[17576] <[14|00|11|00|07]vw[00]44[00]1
[17618] <[00|00|01|00|C8]
[17705] >[00|00|01|00|C8]
[27660] <[06|00|12|00|00]
[27744] >[00|00|12|00|C8]
[37703] <[06|00|13|00|00]
[37783] >[00|00|13|00|C8]
[47746] <[06|00|14|00|00]
[47822] >[00|00|14|00|C8]
[57789] <[06|00|15|00|00]
[57862] >[00|00|15|00|C8]
[67833] <[06|00|16|00|00]
[67900] >[00|00|16|00|C8]
[77876] <[06|00|17|00|00]
[77939] >[00|00|17|00|C8]

I believe this “ternary operator” is a TRUE FALSE comparison argument…

…But, if I am interpreting this correctly, you appear to be sending many different values from the V0 widget…

EDIT - it actually looks like you are sending lots of other widget commands on different vPins/digital pins (nothing on V0), but nothing in your code matches up to all that? Are you also running direct pin manipulation in some App widgets? I have found it best to never mix direct pin manipulation and virtual pins… one or the other.

As for your V0 example, It needs to be a button or switch with 0/1 not a slider or other range in order for anything to happen with V1

And besides… if you are connected and seeing actions in the debug from App processes (even if not quite what you expect), then your BLE connection is working… so what is the issue?

Sorry for the mistake. The log is not related to the code.
The published code is the easy one that works.
The log is related to a more complex code and a different app. The code is very long to attach here. I am attaching a few lines of code.
The full code is available here https://github.com/alf45tar/Pedalino/tree/master/src/esp

The strange thing is that Arduino is sending the correct values but they are not used by the app.

#define BLYNK_BANK                  V20
#define BLYNK_MIDIMESSAGE           V21
#define BLYNK_MIDICHANNEL           V22
#define BLYNK_MIDICODE              V23
#define BLYNK_MIDIVALUE1            V24
#define BLYNK_MIDIVALUE2            V25

#define BLYNK_PEDAL                 V30
#define BLYNK_PEDAL_MODE1           V31
#define BLYNK_PEDAL_MODE2           V32
#define BLYNK_PEDAL_FUNCTION        V33
#define BLYNK_PEDAL_AUTOSENSING     V34
#define BLYNK_PEDAL_SINGLEPRESS     V35
#define BLYNK_PEDAL_DOUBLEPRESS     V36
#define BLYNK_PEDAL_POLARITY        V38
#define BLYNK_PEDAL_CALIBRATE       V39
#define BLYNK_PEDAL_ANALOGZERO      V51
#define BLYNK_PEDAL_ANALOGMAX       V52

#define BLINK_INTERFACE             V40
#define BLINK_INTERFACE_MIDIIN      V41
#define BLINK_INTERFACE_MIDIOUT     V42
#define BLINK_INTERFACE_MIDITHRU    V43
#define BLINK_INTERFACE_MIDIROUTING V44

void blynk_refresh()
{
  if (Blynk.connected())
  {
    Blynk.virtualWrite(BLYNK_BANK,                  currentBank + 1);
    Blynk.virtualWrite(BLYNK_PEDAL,                 currentPedal + 1);
    Blynk.virtualWrite(BLYNK_MIDIMESSAGE,           banks[currentBank][currentPedal].midiMessage + 1);
    Blynk.virtualWrite(BLYNK_MIDICHANNEL,           banks[currentBank][currentPedal].midiChannel);
    Blynk.virtualWrite(BLYNK_MIDICODE,              banks[currentBank][currentPedal].midiCode);
    Blynk.virtualWrite(BLYNK_MIDIVALUE1,            banks[currentBank][currentPedal].midiValue1);
    Blynk.virtualWrite(BLYNK_MIDIVALUE2,            banks[currentBank][currentPedal].midiValue2);

    Blynk.virtualWrite(BLYNK_PEDAL_FUNCTION,        pedals[currentPedal].function + 1);
    Blynk.virtualWrite(BLYNK_PEDAL_AUTOSENSING,     pedals[currentPedal].autoSensing);
    Blynk.virtualWrite(BLYNK_PEDAL_POLARITY,        pedals[currentPedal].invertPolarity);
    Blynk.virtualWrite(BLYNK_PEDAL_ANALOGZERO,      pedals[currentPedal].expZero);
    Blynk.virtualWrite(BLYNK_PEDAL_ANALOGMAX,       pedals[currentPedal].expMax);

    Blynk.virtualWrite(BLINK_INTERFACE,             currentInterface + 1);
    Blynk.virtualWrite(BLINK_INTERFACE_MIDIIN,      interfaces[currentInterface].midiIn);
    Blynk.virtualWrite(BLINK_INTERFACE_MIDIOUT,     interfaces[currentInterface].midiOut);
    Blynk.virtualWrite(BLINK_INTERFACE_MIDITHRU,    interfaces[currentInterface].midiThru);
    Blynk.virtualWrite(BLINK_INTERFACE_MIDIROUTING, interfaces[currentInterface].midiRouting);
  }
}

I think the error is related to iOS app.
See my other post Arduino Mega + ESP8266: iOS app bug?

In this case I cannot test with Android because Android app cannot connect via BLE.

Sure it can… it is not the App that is the limitation, it is the phone/tablet device. My LG G6 works just fine with BLE and either my Light Blue Bean or an ESP32 and Blynk, but my Nexus 6 does not like the LLB, whereas my old Samsung Note 8 tablet does…

I do not have any BLE module to test on Arduinos through.

Too much Android phones are incompatible with BLE widget. I suppose there is space for improvement for the Blynk app.

Again… I don’t blame the Blynk compatibility entirely. I have four different BLE capable phone/tablets and each has varying results with BLE connections… even when NOT using Blynk

Android still not working but I resolved iOS BLE virtualWrite issue.

My app is using 2 devices: an ESP32 via wifi and an Arduino Mega via HC-08 BLE.
I deleted the second device, changed the remaining one to Arduino MEGA + BLE, relinked all the widgets to virtual PIN and now is working as expected.

I suppose a bug is still present on iOS app.

Sorry, I haven’t been paying attention so I am a bit lost on your situations status about what works and what doesn’t.

I dusted off my BLE kung-foo and converted a WiFi rover sketch over to BLE, in order to use something that is complex, (and even left in the Arduino WiFi OTA to add to the complexity, and make it easier to convert back to WiFi).

Out of 5 (five) devices total… 3 tablets and 2 phones… all were eventually able to connect and run via BLE, but some did so instantly and others took multiple attempts.

The phone and tablets that do work flawlessly are both newer LG models. So my conclusion remains the same… it is the devices overall internal BLE chipset compatibility more so than Blynk that is the issue.

That said, what I did notice when using multiple android devices is that unless I explicitly disconnect, and sometimes disable BT/BLE, on all other Androids, before trying to connect with a particular android device, then there did seem to be some “pick me, pick me” :stuck_out_tongue: confusion going on as sometimes most other androids would either say “connecting” or actually say “connected”, when it was really only the one device that was truly connected and working.

Hello,

I was having the same problem, and I have found a workaround solution to it. In any value display widgets in your app, choose refresh interval to be anytime except “push”. Then, in your code, any virtualWrite should succeed.