Hello guys! I’m using google translator to translate to english, sorry if any part gets weird
I’m starting to use Blynk and I’m having a problem in my college project with WeMos , my goal is to build an automatic irrigation system, I want it to work in two ways, the first is that it be activated through a button (ja got it), and another is that it works automatically. This automatic way is based on soil moisture, the problem is that if it’s automatic, I can’t activate the button through the app, I’d like it to work both ways, so when I’m not at home and without internet, the activation of the system happens alone, and if I am, turning on the button it works. My code below.
To use the event widget will I need to use virtual pins? I say this because to activate the relay by the button I’m using D5, and for soil moisture the A0, how can I make the change?
@Bruno_Smicaluk please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
No it’s a coding error. You need to use a timer to read the analog pin at a certain interval and then take that reading and send it to the virtual pin.
Take a look at this example. You would follow the same format.
This code will ONLY be called when the value of the widget attached to V2 changes in the app. You should not be putting code that needs to be called on a timed basis inside a BLYNK_WRITE(vPin) callback function.
That code should be inside a function such as your myTimerEvent function, and this line of code…
should only be present inside your void setup (which it already is) so this duplicate setInterval definition needs to be deleted.
I think you need to take another look at what I had posted, and review the example a little more as well. The example is more to give you an idea of how to use a timer to pass data to a virtual pin, not to copy for your application.
The code snippet I posted would replace that part of the example, and is more specific to what you need.
Once you get the data displaying properly on the gauge, then just add in your code for the button.
It is already running. I also fixed the event widget to fire according to humidity. However, when soil moisture is below 40 the relay should be activated, but it increases to 1540 every second and the relay is deactivated, what is the solution?