Add details :
• Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
• Smartphone OS (iOS or Android) + version
• Blynk server or local server
• Blynk Library version
• Add your sketch code. Code should be formatted as example below.
Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.
/* Comment this out to disable prints and save space */
#define BLNYK_PRINT DebugSerial
/* Fill-in your Template ID (only if using Blynk.Cloud) */
//#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_TEMPLATE_ID "TMPL5hdx8s9L"
#define BLYNK_DEVICE_NAME "Capstone Project"
#include <Blynk.h>
// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
#include <BlynkSimpleStream.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "f0TlYnnGV9yksWG18nvC380-g6P5_NYc";
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup(){
Serial.begin(9600);
Blynk.begin(Serial, auth);
lcd.init();
lcd.backlight();
lcd.clear();
pinMode (2, OUTPUT);
digitalWrite(2, HIGH);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("IRRIGATION");
lcd.setCursor(0, 1);
lcd.print("SYSTEM IS ON ");
lcd.print("");
delay(3000);
lcd.clear();
}
void loop(){
Blynk.run();
int moist = analogRead(A0);
Serial.println(moist);
if (moist > 950) {
digitalWrite(2, LOW);
lcd.setCursor(0, 0);
lcd.print("Water Pump is ON ");
} else {
digitalWrite(2, HIGH);
lcd.setCursor(0, 0);
lcd.print("Water Pump is OFF");
Blynk.logEvent("auto_water", ("Plant Already Watered!"));
}
if (moist > 950) {
lcd.setCursor(0, 1);
lcd.print("Moisture : LOW ");
} else if (moist < 950 && moist > 400) {
lcd.setCursor(0, 1);
lcd.print("Moisture : MED ");
} else if (moist < 500) {
lcd.setCursor(0, 1);
lcd.print("Moisture : HIGH ");
}
}
I’d suggest that you post your updated sketch along with screenshots of how your event and associated notification are configured.
If you’ve not previously been sending events to the timeline then you may have already exceeded your daily quote, but in that case you should now see a message to that effect.
You need to use triple backticks when you post code.
Also, you need to post a screenshot of the EVENT screen as well as the associated notification screen, and your screenshots probably need to be done at a different screen resolution, or in multiple parts, so that ALL of the options can be seen.
Okay, firts if all you need to remove all of your code from the void loop except Blynk.run() and place it in a function, then use a BlynkTimer to call that function.
I’ve already shared a link to the “keep your void loop clean” article earlier 8n this topic. You need to read it and act upon it.
I also asked you to…
You’ve posted a shot of the Events tab, but you haven’t shown the detail associated with the Auto Water event, or the Notifications tab within that event.
It you look at the tutorial I linked to regarding events, notifications and flag variables then you’ll see examples of the sort of screenshots that we need to see. However, if you actually worked through that article yourself then you’d probably find the answer to your problem anyway.
Even when you’ve fixed the notification issue, you still need to implement at least one flag variable to ensure that you don’t very quickly exceed your daily event/notification quota.
Until you do these things we can’t really help you any further.
I’d like to see ALL of the parameters in each of the two tabs for the Auto Water event. You’ve provovided a screenshot of half of the notification tab, which tells me very little.
Also, if you’ve updated your sketch don’t you think it would be sensible to post that sketch here?
i think the problem sir is the code, because i don’t know which line should i put the blynk.logevent, etc.
What do you think of my code? it is correct or not?
’ ’ ’
float m_threshold = 950;
bool info_sent = true;
BlynkTimer timer;
void moistureSensor() {
int moist = analogRead(A0);
Serial.println(moist);
if (moist > 950) {
digitalWrite(2, LOW);
lcd.setCursor(0, 0);
lcd.print("Water Pump is ON ");
} else {
digitalWrite(2, HIGH);
lcd.setCursor(0, 0);
lcd.print("Water Pump is OFF");
if(moist > m_threshold && info_sent == true) {
Blynk.logEvent("auto_water", String("Plant Already Watered!") + moist);
info_sent = false;
Serial.println("Blynk Alert Notification sent!");
Serial.println();
} else if(moist <= m_threshold && info_sent == false) {
info_sent = true;
Serial.println("Moist is now equal to or below the threshold");
Serial.println("New low-moist detected events will trigger a new alert notification");
Serial.println();
}
}
if (moist > 950) {
lcd.setCursor(0, 1);
lcd.print("Moisture : LOW ");
} else if (moist < 950 && moist > 400) {
lcd.setCursor(0, 1);
lcd.print("Moisture : MED ");
} else if (moist < 500) {
lcd.setCursor(0, 1);
lcd.print("Moisture : HIGH ");
}
}