Hi guys, currently i am working on my project which is smart irrigation. Here the wiring detail, all component is working, but the main is the pump doesn't work correctly as the code, like i want the pump off if the soil moisture is above 30%, but when already above 30% the pump still pumping the water, and i see the relay led is turn on the red and the green one, please help me what's wrong?
Please post your sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
It is also helpful to post error messages in code tags as it makes it easier to scroll through them and copy them for examination
Oh i am so sorry, there's a typo, i'm using D5 esp8266 for the input of relay and The uno i use for the source to relay and lcd i2c which is these two need a 5v input
why not use the 'D' pin number in the code is because the esp8266 uses a numbering system where some pins might be labeled "D0", "D1", "D2", etc., on development boards. These labels correspond to specific GPIO numbers (e.g., GPIO16, GPIO1, GPIO0, etc.). I see there's many more example code related to esp8266 is different than the uno when mention the pin it must be mention the GPIO number, if i stay at D there will be an error like this "Compilation error: 'D5' was not declared in this scope"
I wrote an example (though not complete) to show how to write non-blocking code, which helps carry out all necessary operations without delays caused by other parts of the program (such as waiting loops or delays). Now, what should the missing function do? It needs to handle reading the values and controlling the relay—things you've already written in the sendTelemetry function.
That is a very bad hardware set-up.
You should not use an Uno as a power source.
Your relay may not work with the 3,3V signal from the 8266
Connecting a 5V relay to the 8266 may damage the 8266.
But you are not using a Generic ESP8266. Set the board to one of the NodeMCU variants and you will be able to use the 'D' pin names. This will avoid the need to convert the pin number shown on the board to a chip GPIO pin number
okay, thanks for the reference, but is there any other solution besides me having to find a 5v source, I don't know what to replace the 5v, is there any ways like replace a suitable type of relay or something?