Blynk crashes frequently

Greetings

I have an Arduino sketch running a greenhouse, and am having problems with frequent Blynk crashes. My code is elaborate, so I’d like to break the problem down into smaller parts and work on those. Some of the reasons for instability include:

  • the Tweet function has never worked

  • timing issues? I received advice to add multiple calls to Blynk.run();, and that only seems to have made it worse

  • connectivity with the CC3000?

    I would appreciate y’all’s help, as I’m new to Arduino and Blynk and appreciate y’all’s expertise. Let’s tackle what should be the simplest one first - why does the Tweet function fail? I have a Twitter icon on my Blynk app, and it tells me it is connected to the Twitter account I set up specifically for the greenhouse. But it has never actually Tweet-ed. Thoughts?


CODE REDACTED

Hardware is a Sparkfun Redboard (UNO clone), with a CC3000 shield. The CC3000 is running firmware 1.14, the most recent version. (Is 1.12 more stable?). I use IDE v. 1.6.7 and the latest Blynk version.

Without going deeper - most probably - yes.

Also “crash” usually applied to app side and not sketch. This is confusing.

Quite old now. You might want to consider a newer version.

Have you considered a switch to Sparkfun’s Blynk Board / WeMos / nodeMCU?

Two pieces of hardware cobbled together are not normally going to perform as well as a single piece of hardware specifically designed for the job.

Here is my app, to illustrate what I mean by “crash” and so you can see what I’m trying to do. I used the Tab function to build four tabs. One shows a history chart with the three greenhouse temperatures, and an average temp in a separate indicator in the image center. There are also LEDs to show when the fan, louver, misters, pump, and two irrigation systems are running.

On the next tab, I’ve placed all the commands. There are sliders for various ON/OFF temperature-related functions, and three buttons to manually start the misters and two irrigation systems.

The third tab contains a pair of timers to run the irrigation systems. And the Tweet widget.

The fourth tab (not shown) has a red button in the middle labeled “reset”. I tried to write a software reset function but that doesn’t appear to work either.

You can see the “crash” in the first tab, on the history graph. The app stops showing data or accepting commands at random intervals. The reset button I wrote doesn’t work, either. It is not clear if the sketch continues to run without the Blynk app or not - I’ve been at work and have only had this up and running for the past few days.

I think you are only going to find out what your problems are by testing each part of the project in a separate app.

Test unit 1 thoroughly.
Test unit 2 thoroughly
Test unit 3 thoroughly
Test 1 + 2
Test 1 + 3
Test 2 + 3
Put it all together.

Why main loop every 1 second?

Try more seconds…

Your graph shows poor DHT reads, not crash…

You beat me to it.

Put Blynk.run() in the loop()

1 Like

Minutes, unless it’s mission critical.

1 Like

My DHT22 loops are between 4 minutes (living space ventilation) and 12 minutes (subfloor and basement)…

1 Like

This IS the “put it all together” version! :slight_smile: It is version 16 of the sketch, each version of which had multiple changes and saves. Version 8 ran the greenhouse just fine without Blynk, and 7-16 have been additions of WiFi and Blynk functionality. Only 13-16 have been Blynk versions. One of the versions read DHT data without any other functionality, and it was reasonably stable but I only ran it for a day or two before adding input from the app.

That’s easily done; I’ll give it a go with five minutes between reads.

I’ve tried it with Blynk.run in loop() and in MainLoop(). Doesn’t seem to make a difference, but I’ll put it back in loop().

Interesting thing - I added multiple instances of Blynk.run() as per someone else’s suggestion, and it seems to have made it even less stable. That makes me wonder if Blynk.run() is getting interrupted, perhaps by DHT reads.

The Blynk board came out after I started this; I had a simple sketch controlling the greenhouse for a while now. But I dont’ think the Blynk board will work - I need to turn on multiple items (pump and misters together, fan and louver) with a single command. Only virtual pins can do that right now - Blynk doesn’t support multiple digital lines with a single app button as far as I can tell.

Besides, if possible I’d rather make the existing setup work rather than buying new hardware and re-wiring everything.

Sorry I hadn’t caught the missing Blynk.run() in your void loop() - which is your REAL main loop, called by a hidden loop that controls the execution of the Arduino program. Kind of surprised your sketch worked as well as it was.

As I have learned to understand it… Blynk.run() is somewhat the same… is keeps the hidden Blynk functionality running in the background… which is why it needs to be added in the middle of any time consuming loops or tasks… otherwise Blynk kinda times out… but like anything else, overuse keeps Blynk busy with housekeeping and forgetting the guests :wink:

I think he meant upgrade your Arduino IDE :slight_smile:

1 Like

@q_mech I can understand you wanting to use your existing equipment but running an Arduino in your greenhouse is very much different to controlling your greenhouse via the internet.

The best route is to use hardware that was designed for the job.

I have never used a CC3000 but I have read plenty of bad reports about them. I don’t read bad reports about the boards that were designed to run on the internet.

Blynk can control multiple digital lines with a single app button. You simply embed all the digital writes within a single virtual pin call.

you mean like this:

BLYNK_WRITE(V11) // mode selection 
{
  setMode = param.asInt();
  {
    if (setMode == 1) // Off mode
    {
      digitalWrite(roofVent, LOW); // roof vent closed
      digitalWrite(houseVent, LOW); // house vent closed
      digitalWrite(ventFan, HIGH); // ventilation fan is OFF
      Blynk.virtualWrite(V10, 0); //fan LED
      Blynk.virtualWrite(V7, 0); //hse LED on Blynk app
      Blynk.virtualWrite(V8, 0); //rof LED on Blynk app
      Blynk.virtualWrite(V9, 0); //bse LED on Blynk app
      Blynk.virtualWrite(V1, 0); //ERR. LED on Blynk app
      Blynk.virtualWrite(V46, 255); //off LED on Blynk app
      terminal.print(currentTime);
      terminal.println(": OFF mode selected");
      terminal.flush();
    }

roofvent, houseVent and ventFan are all separate GPI/O pins…

3 Likes

Ah; very nice. Now that I see it, it is obvious. Funny how that works.[quote=“Dave1829, post:18, topic:11365, full:true”]

you mean like this:

BLYNK_WRITE(V11) // mode selection 
{
  setMode = param.asInt();
  {
    if (setMode == 1) // Off mode
    {
      digitalWrite(roofVent, LOW); // roof vent closed
      digitalWrite(houseVent, LOW); // house vent closed
      digitalWrite(ventFan, HIGH); // ventilation fan is OFF
      Blynk.virtualWrite(V10, 0); //fan LED
      Blynk.virtualWrite(V7, 0); //hse LED on Blynk app
      Blynk.virtualWrite(V8, 0); //rof LED on Blynk app
      Blynk.virtualWrite(V9, 0); //bse LED on Blynk app
      Blynk.virtualWrite(V1, 0); //ERR. LED on Blynk app
      Blynk.virtualWrite(V46, 255); //off LED on Blynk app
      terminal.print(currentTime);
      terminal.println(": OFF mode selected");
      terminal.flush();
    }

roofvent, houseVent and ventFan are all separate GPI/O pins…
[/quote]


CODE REDACTED

Alrighty. I have changed the timing so that it reads from the DHTs and checks the Blynk connection once every five minutes, but offset from each other by one minute. I moved Blynk.run into the void loop(). The automated monitoring functions still run once per minute… Perhaps I’ll offset that by thirty seconds so that none of the timers are triggered at the same time.

Thank you all for your help! Let’s see how this works.

EDIT: Changed the timing so that the connection check, DHT read, and main loop are offset by at least 30 sec when called.