Wemos d1 & blynk

Today I tried to recompile everything and to make a new log in the server.
Now the notification is working properly.
I would like to try the board now,
A simple question …: because the reading of an analog / digital sensor can have a real time reading while a notification needs to be called only one time per minute?

Thanks again for your support!
this is the code:

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * Simple push notification example
 *
 * App project setup:
 *   Push widget
 *
 * Connect a button to pin 2 and GND...
 * Pressing this button will also push a message! ;)
 *
 **************************************************************/

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

long prevZeroMillis = 0;    // used to debounce button, set at 100 millis, 0.1s, debounce time
bool buttonChanged = false; // used to ensure button press is handled correctly
bool buttonStatus = false;  // toggle on and off

char auth[] = "*****Your Token*****";// You should get Auth Token in the Blynk App.

SimpleTimer timer;


void setup()
{
     Serial.begin(115200);
     Blynk.begin(auth, "**Your SSID**", "**Your Password**");
     while (Blynk.connect() == false) {
    // Wait until connected
  }
    Blynk.notify("Device started");
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(2), notifyOnButtonPress, RISING);
}

void notifyOnButtonPress()                // debounced, disabled interrupt and enabled interrupt
{
    noInterrupts();                       // disable interrupts
    if(millis() - prevZeroMillis > 100) { // different buttons need different debounce period, test it
      buttonStatus = !buttonStatus;
      buttonChanged = true;               // just set a flag for loop() or SimpleTimer to pick up
      prevZeroMillis = millis();
    }
    interrupts();                         // enable interrupts   
}

void BlynkButton(){                    //lines below will crash the ESP in notifyOnButtonPress() function 
  if(buttonChanged){                   // only do something if button state has changed
    Serial.println("Button is pressed.");
    Blynk.notify("Button is pressed!");
    buttonChanged = false; 
  }      
}

void notifyUptime()
{
  long uptime = millis() / 60000L;
  Blynk.notify(String("Running for ") + uptime + " minutes.");
}

void loop()
{
  Blynk.run();
  timer.run ();
  if(buttonChanged){ 
      BlynkButton();    
  }
}
1 Like

@n3v3r glad we got there in the end and thanks for posting your final sketch.

If I understand your question correctly the answer is you can process data from “real” pins up to 100 times per second http://docs.blynk.cc/#troubleshooting-flood-error. Actually it is the same for most “virtual” pins but sending emails and push messages are a few of the items that have a restriction of one per minute.

If you do any analogue data processing please note the port is restricted to 3.2V even though the board operates at 3.3V. This is because of the resistors chosen by WeMos to step up the 1V maximum ESP analogue feed.

Sometimes you might to be able to get to 3.3V as it depends on the precise tolerance of the resistors but almost all of the ones I have checked fail at 3.3V. You can set up your own additional voltage divider if you need to go to 5V.

1 Like

In general you may send as many notifications as you want, however server will send only 1 per minute (latest one). You can also decrease 1 minute limit with local server. We also will decrease this 1 minute limit to 1 sec limit I think in nearest future.

1 Like