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();
}
}