NodeMCU
Blynk Library v1.0.1
in Blynk I have the event code “mailbox_opened” set up with notifications enabled
I have confirmed the data that belongs in the “” below is correct
I have tried for hours to read and learn and experiment, I would really appreciate any assistance! thanks.
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "";
char ssid[] = "";
char pass[] = "";
BlynkTimer timer; // Announcing the timer
int sensorPin = 5; // choose the input pin (for PIR sensor)
int sensorValue = LOW; // variable for reading the pin status
void setup()
{
pinMode(sensorPin, INPUT);
Blynk.begin(auth, ssid, pass);
Serial.begin(9600);
Serial.println("READY");
timer.setInterval(5000L, sensorDataSend);
}
void sensorDataSend()
{
sensorValue = digitalRead(5); // reading sensor value
Blynk.virtualWrite(V0, sensorValue); // sending sensor value to Blynk app
if (sensorValue == HIGH)
{ Blynk.logEvent("mailbox_opened");}}
void loop()
{
Blynk.run();
timer.run(); // run timer every second
}
sorry I’m not sure what you mean by increasing the priority.
regarding testing, not sure if this is what you mean–but at one point I had it working so that, yes, every movement of the motion sensor resulted in a notification (and the high/low behavior with movement has been 100% consistent measured with multimeter whenever I test it). however I think it was also flooding because of virtual write being in the loop with nothing limiting it. unfortunately i can’t find that sketch darn it, but I don’t think the code was that great anyway
Ok, check longer period like a day or week. If limit is reached it’s not gonna send anything to the timeline anymore, so could be longer then last hour.
Also change your code for only send a notification once, you can do that with using a flag.
Sorry, I should have use the correct terminology, which is “Type”
You currently have the Type set to Warning.
I meant, are you certain that you are obtaining a situation where sensorValue == HIGH ?
Have you tried adding a serial print statement inside this if statement to demonstrate that it is evaluating to true ?
Is your PIR sensor attached to the pin labelled D1 ?
there’s nothing in the timeline from the current sketch, i.e. since the earlier flooding
also, when I use Arduino IDE on macOS, I have two port options: usbserial, and slab_USBtoUART, the only difference seems to be what gets written in serial port.
I’ll try adding a serial print statement for sensorValue High and post back
if I didn’t mention it, I am plugged into D1
after adding a print statement inside the “if”, what gets printed with motion is the number 1. so I decided to change the V0 data stream to integer, low 0 max 1 default 0. the serial monitor continued to print the same thing (“1”) not surprising I guess. will I even be able to truly test notifications until tomorrow due to the over quota message I get?
yah I figured. can you give me an example of a “flag”?? I am no exception to the newbie who just isn’t getting timers and intervals and flags and stuff. I’ve been reading a ton and trying to digest. I thought the interval I inserted would prevent flooding:
timer.setInterval(5000L, sensorDataSend);
except maybe it fails because it’s in void setup and runs only once?
Your timer is ok, but checks every 5 seconds so in 500 seconds your max is reached.
Coding is almost the same between Legacy and IOT but you’ll need to setup more in the webconsule.
Here a simple example for setting the notification once without a reset function.
int flag = 0;
void sensorDataSend()
{
sensorValue = digitalRead(5); // reading sensor value
Blynk.virtualWrite(V0, sensorValue); // sending sensor value to Blynk app
if (sensorValue == HIGH && flag == 0)
{ Blynk.logEvent("mailbox_opened");
flag = 1;}
}