There are 5 sensors (dht22, ds18b20, analog ph, analog tds, float switch)
There are 5 relays (irrigation pump-repeat operation every 30 min, misting pump-based on temp, acid pump- based on ph, nutrient pump- based on tds, water inlet pump-based on float switch)
For the sampling part, I want to take 50 analog inputs(ph, tds), sample them by sorting and then taking the average value of middle 30 values. In the whole process, the loop should not halt, no other process should be affected, total time taken for input must be less than output time. I need help with readph() and readtds() functions.
Read input #1, set relay #1
Read input #2, set relay #2
...
Read input #6, set relay #6
Repeat
It really is as simple as that. In reality, the code is not monitoring all inputs simultaneously, and not updating all relays simultaneously. But it happens so fast that it appears to do that.
Wow. You have now added 100 times more detail to your question. What help did you imagine anyone could give from your original short question? Were you just testing the forum to see if you got a response?
You say you need help with 2 functions. But what help do you need exactly? What is wrong with the code you have? How did you want it to behave differently to that?
Why this complex method of taking 30 readings from 50? Have you investigated the distribution of errors from these sensors? If the distribution is Gaussian, why not just take the mean? If it is not Gaussian, taking the 30 from 50 may not give a good answer.