i am struggling with reading the analog value
I don't understand what this means. Your readSoil() function looks just fine.
What's your problem?
- Is it not compiling?- Not uploading? - Nothing gets printed out to the serial monitor? - You are seeing garbage on the monitor instead of the text you expect? - Is it always returning a zero? - Random-looking values? - A fixed value that doesn't change even when you wet the soil? - A number in a range you don't expect? - A sensible-looking number, but you don't know how to interpret it? - The number comes back just fine, but you want to do something intricate with your four relays in response to the number and don't know how to proceed?
What? What's the problem?