I am recently working on a Ultrasonic sensor HC-SR04 to determine the water level. I wanted to get notification when it is in high water level but it just dont work. My esp8266 keeps on repeating online and offline according to Blynk Apps on my phone. I dont know what’s wrong is it. Can anyone please help me in it? Im using Arduino Uno + HC-SR04 + Esp8266 (esp 01) + Blynk. This is my code. Please help me out as i dont even know what’s wrong. Thank you so much!!
@PeteKnight@Gunner
Hi after reading the examples from blynk. I edited my coding but it still dont works. My esp8266 keeps online and offline repeatly. Can anyone help me out? I have no idea whats going on
You don’t need to declare the pinModes every 2.5 seconds. Put those in void setup and you’ll save some processing time in your void sendSensor function.
Notifications are limited to one every 15 seconds. You should have a flag to keep track that a particular type of notification has been sent, and not send repeated notifications of the same type.
Hi everyone. Im working with a ultrasonic sensor as a water level sensor project. I want to get notification when the water level is high but when I connect to blynk, the esp8266 keeps on online and offline repeatly. I dont know what happened. Can anyone help me out? This is my code…
Hmm what do you mean by “You should have a flag to keep track that a particular type of notification has been sent, and not send repeated notifications of the same type.” ?
RX from one goes to TX of the other and vice versa… Think mouth to ear.
Or just Google proper ways to connect Arduino to ESP
You can also search this forum for one of the dozens of topics all about connecting Arduino to ESP… every possible question & solution has already been mentioned a few times.
You currently have four types of notification message: Low, Medium, High & Out of Range.
If Blynk allowed it, you would be getting notification alerts every 2.5 seconds, or almost 1,500 notifications per hour - all day, every day.
For a push notification to be of any use, it needs to tell you that something notable has happened, not keep telling you the same thing over and over and over again. So, you only want to send a notification when the status changes - say from Medium to High. To do this, I’d use a flag to keep track of the fact that a message regarding a particular notification (Medium for example) has already been sent, and that another notification doesn’t need to be sent until the level changes to either Low or High.
This could/will still cause you some issues when the water level is very close to the threshold between two of your levels. You use 20 as the threshold between High and Medium, and a Long variable type to store the distance. 19.999999999 will give a Low message 20 will give a High message so you can expect subsequent readings to hover between Low and High.
If you used an integer for distance then the reading would need to change from 19 to 20 to trigger a notification and depending how you did your rounding it would probably require a 0.5 (cm ?) change in level to cause the flip between Low and High.
Personally, I wouldn’t even bother with a notification for Medium (which presumably is the norm) only for Low and High I fell these are critical situations. Because of my age, I’d also use a set of LED widgets in the app to show the level using an old VU meter style of display, with green LED for the middle range and red for high or low. The youngsters would use a gauge widget instead
So if i just want to show notification when the water level goes from medium to high, what i gonna change for my coding? Im still very new to programming as i only knows basic C++
I’m not going to write your code for you. @Gunner and I have given you enough pointers (see what I did there ) to help you on your way. You need to invest some time in learning how to write your own code.
If you get stuck along the way then come back and post your latest code (correctly formatted this time) and some info about the issues you’re having and we’ll point you in the right direction.
you can add two timer for functions. you can chech water level however you want but you must send notification 4 times in minute. That mean you must wait 15 seconds for next notification.
That’s still 240 notifications per hour. 5,760 in 24 hours. What use is that to anyone?
You don’t want to be told 2 million times per year that your house isn’t on fire, you want to deceive an alert when it is on fire. It’s called Reporting my Exception and it’s where you flag-up notable events, rather than drowning the use in useless repetitive data that requires no action.
if you put your flags in if else condition, you get notification just your house in fire. else, not.
You must check notification state with minimum 15 seconds delay. if you increase delay time, for example 1 hour, you may get notification after 1 hour.
813/5000
The problem you have is that you collapse the server with so many notifications and that’s why it goes offline. There are two ways to treat the problem you have:
Through a timer I sent a status notification every so often. (I do not recommend it to you since it would stop you all the time seeing notifications).
The best and most appropriate would be to only send the notification once just when the values of low, medium, high change. (You do not have to send repeated notifications)
This is achieved by using state flags:
If it goes from low to medium state, the middle flag changes to 1 and you send the message. As long as the flag is medium = 1 nothing happens until another event occurs and the deposit goes low or high and the flag would be changed and only a notification will be sent again.
El problema que tienes es que colapsas el servidor con tantas notificaciones y por eso se va a fuera de linea. Existen dos formas para tratar el problema que tienes:
A través de un temporizador que envié una notificación del estado cada cierto tiempo. (No te la recomiendo ya que te pararia todo el tiempo viendo notificaciones).
La mejor y mas apropiada seria que solo se envíe una vez la notificación justo cuando cambien los valores de bajo, medio, alto. (No tienes que enviar notificaciones repetidas)
Esto se consigue utilizando flags de estado:
Si pasa de estado bajo a medio el flag medio pasa a 1 y envías el mensaje. Mientras sea el flag medio =1 no sucede nada hasta que se produzca otro evento y el deposito pase a bajo o alto y se cambiaría el flag y se enviaría de nuevo solo una notificación.