Timer interrupts on the Particle photon and Blynk Communication via Bluetooth problem

Good day Blynk community

I have encountered a strangely similar problem with my project. I am using the latest blynk version 2.27.1 on my android Samsung note 4 smart using android version 5.1.1 lolipop. My project requires the communication of data from my micro-controller Particle Photon to the Blynk app via a jdy-09 BLE module.

Here is the strange part, my project was working perfectly fine up until a few days ago. i switched my project off the last time it was working and then tried yesterday (no change in code or hardware) and it refused to connect correctly with the Blynk app. The connection status would say “connecting” forever but never connects. Some times it would say connected but variables on Blynk’s widget would never update. Most of the time it would say that it could not connect to the Bluetooth module and that i should make sure my auth token was correct. Here is what i tried:

  1. I changed the auth token on my Blynk project and on my micro to test communication using a different auth token number.
  2. I than suspected that my Bluetooth module might be faulty so i tested my Bluetooth module using a terminal app and an arduino. After setting up the code in arduino i was able to send data to arduino via the bluetooth module from my android phone’s terminal app and from the terminal app to the arduino (Displayed on the serial monitor)
  3. I than tested the bluetooth communication pins of my photon using an arduino. This was to test if the serial pins on my photon were functioning correctly. A number was send from the photon to the arduino and the same number was sent back to the photon from the arduino via their TX and RX pins and the results were displayed on the serial monitor. The pins were functioning correctly.
  4. I than re-uploaded coded examples requiring blynk communication via bluetooth , aside from the code that was already working in my photon a few days ago, and all of them experienced the same communication problem. This eliminated any coding or software errors on the microcontroller.

From this, i think that the only other issue can be with the Blynk app itself. It was the only thing i altered between the two days: I updated the software and added a few new widgets onto the screen (eventor, email notification and led) , that i was planning to program functionality for in the coming few days. Even after i updated the software the app was running fine, i only think i really changed was the addition of widgets. I removed all these added widgets but this also did not solve the problem. Please advise what can i do to find the cause of this problem, or is there a solution that i have not come across as yet?

Isn’t this related to your other topic? I am comparing them and will merge them is needed.

Meanwhile, please do not tack on additional questions into others older topics or create multiple topics regarding similar issues. The way this forum is structured does not require any such “shotgun” approaches to posting for maximum forum awareness.

Which other topic? i have a few with different issues. If you are referring to the topic on timer then no its not the same issue. When i started posting on that thread my blynk app and project was working. I have encountered a new problem as you can see and that is why i have tacked a different question to an existing topic. I am sorry, but i as was not trying to “shotgun” anything. I was looking for an answer to the problem i had and this topic matched more closely to that. I was hoping that there was a solution that was found by those involved on the thread by now.

The one we are bouncing back and forth in… with the same Photon, communication issues and BLE interfaces… thus essentially same topic material.

As it was over two years since last post in that old topic… not likely the answers you would need :slight_smile: Particularly since you already have a current post that seems to imply some limited understanding of the overall timing needed.

I suspect that there have been some recent overall stability issues concerning Blynk and BLE… that is using the BLE link for communicate with the App. But is seems that the Developers may be more focused on a Blynk 2.0 that may changes things up a bit. Simply put, things are not as stable as they may have been (not that I ever really saw stability in BT/BLE link) and we may simply have to wait ans see what changes happen in the near future.

Okay let me clarify, the topic we are bouncing back and forth is the issue regarding the frequency of Blynk.run and Timer.run. When i posted on that thread my code was working and i was looking to implement some power saving methods to reduce power consumption on my battery. The topic i posted to with the issue above is the fact that my communication with the blynk app has suddenly failed. And it has failed without me making any changes that were discussed in the topic that we are going back and forth on

Sometimes topics are solved and people neglect to post solutions, that is why i was asking if there was a solution. :disappointed:

OK… but it still is the same actual project… and probably somewhat related issues… thus instead of two concurrent topics, it should be one. I will merge it for now as one issue seems to require the solution to the other anyhow.

Okay i will follow this procedure going forward as well

I know what you were doing, but this forum is laid out differently with each new post rising to the top… so basically opening old topics can cause confusion and misinformation as Blynk is in constant development and new ideas & solutions are always happening.

I have implemented timers in my program and i believe i have done it correctly. I have the void loop completely clean except for the Blynk.run and Timer.run and i have used timers to execute all my functions. This was working perfectly until a few days ago.

oh no. Is there a way for me to down grade to the more stable version of Blynk that i had running before the update?

Assuming that is in fact the cause of the issue (testing it with a simple sketch will help determine that), changing the library is no problem, but finding an older version of the App will require searching Google for such… and taking your chances that the sources are safe.

Than i am not being clear enough on what i need to know let me try to clearify.
I would like to implement some power saving code that will result in my microcontroller to stop executing code i.e. the Blynk.run and Timer.run will not be executing in void loop constantly because code execution will be halted. I am trying to determine what is the maximum amount of time that those two commands can be prevented from execution i.e. how often are they required to be executed, the minimum number of times do they need to be executed, before i will have issues. Costa suggested me to look at HeartBeat. However i do not fully understand the use of HeartBeat: If i use HeartBeat does that mean i can execute Blynk.run or Timer.run less frequently? if yes than how frequently must those two run commands be called? If not than HeartBeat does not really help me.
If there is a minimum frequency for Blynk.run and Timer.run to be executed than i would like to create a function that implements this periodically as frequently as required and in between the time that it is not being executed i would like to put my microcontroller into sleep mode.

Is there another possible cause for it perhaps? something you suspect that i may have missed?

Can you please elaborate what you mean by changing the library ? Changing the library i used on my photon? I do i include an older library ?

The only real sane way to properly use power savings is to either sleep the hardware and/or not use Blynk in the traditional way, but via the API/Webhook methods, like using NodeRed? that do not necessarily require constant Blynk Library ↔ Server connection. I am not a user of either deep sleep or NodeRed, but search around for ideas on that… EDIT However, probably neither is of any use with a BT/BLE type Blynk link

Changing the heartbeat will allow a limited amount of leeway in the sense that it is tricking the server into not closely monitoring the device status… but the device itself still needs to run its background housekeeping routine ‘Blynk.run()’ as frequently as it can.

Besides, those monitoring delay tricks are more meant for WiFi and I don’t think they will work with the BT/BLE link requirements, as that is handled differently all together, with the phone acting as a conduit between the device and the server as well as the App holder.

BlynkTimer, a version of SimpleTimer, definitely needs to run in the loop as it should have about 1ms accuracy… and none of your timers will work if you effectively keep shooting them in the head with tranq darts :wink:

There is only one Blynk Library… you load that into your IDE and it determines the features available in your device sketch.

Now since you are using Particle devices and IDE… I suspect changing the Blynk Library is different from what I use… so I am no help there.

Anyhow, Sorry, but I have not really been following your issues closely, Mostly only getting involved due the forum moderation issues.

I have never used Particle devices, so do not truly understand their idiosyncrasies… like, don’t they have their own version of timer anyhow? and thus not using BlynkTimer.

1 Like

Blockquote
The only real sane way to properly use power savings is to either sleep the hardware and/or not use Blynk in the traditional way, but via the API/Webhook methods, like using NodeRed? that do not necessarily require constant Blynk Library <–> Server connection. I am not a user of either deep sleep or NodeRed, but search around for ideas on that… EDIT However, probably neither is of any use with a BT/BLE type Blynk link

Okay i will investigate this. Thank you.

Everyone seems so reluctant to quantify the minimum frequency. I guess i will play around with the period and see what works.

Okay basically i need to remove the current library that im using and replace it with the one in the link?
This failing, any idea how long before bug fixes to the new version of Blynk are released ?

No need to apologise, i am grateful for your responses and they have helped me. Hopefully using this new information i will find a solution to both my problems.

Yes they do, but since BlynkTimer serves my purpose why should i use another timer? Timers generally function the same way but BlynkTimer is also able to trigger events/functions at different time intervals unlike simpletimer from what i understood.

Mainly because Blynk.run() is supposed to run all out all the time… Period (when connected to the server). Just because something can sometimes work outside of normal limits, doesn’t mean anyone is willing to endorse it.

BlynkTimer is based on SimpleTimer, and aside from a few modes (16 instances instead of 10 per timer, some form of recently added anti-redundance filter), it functions exactly the same.

I know it will run on Particle, but whether it is better or not for the platform then what Particle has… ??

I think the problem is that you’re trying to use Blynk in a different way to everyone else, and using hardware that is quite niche, and also using Bluetooth - which isn’t exactly mainstream either.

I don’t think you’re going to get a straightforward answer to your question, and the simplest way to find out is to do some experimentation and gather your own data.

Pete.

Okay thanks a lot everyone for all the responses and advice. If i manage to find a solution i will post an update.
Thus far, i have established it is a Bluetooth low energy issue. I am able to pass data to the blynk app via wifi and via an HC05 bluetooth module. When i try connecting via the BLE module however it simply does not work. This is the eventual conclusion of my attempts:

And if it does connect than no values update on widgets on my app.

I have the growing feeling that the issue is on Blynk’s side, more specifically with BLE on Blynk, since i have all but exhausted other sources of the problem. I hope a bug fix will come soon, as this project is on a deadline.

So are you saying that it’s not now running smoothly?
If so, is that since you introduced the sleep code?

Pete.