Duration between sensor readings?

Posted on
  • I can successfully read ph, ec and temp sensor readings. Ph and EC are attached to i2c and the temp is attached to analog. I'm using the waveform to gather the analog readings and repeat is set to false so I can manually call the waveform function. Both ph and ec need at least a 3 second pause each in order to get the reading from the sensors.

    I have a boolean named getSensorValues which will be set to true to start the process and remain in that state until all the readings are successfully gathered. The reason for that is, so I can control the readings using a timer, where the timer will continuously loop and trigger a function to start the gathering process if the boolean is set to true and not when it's set to false. And I'm assuming I will need to set the boolean to false during the readings so it won't start another process.

    I will be sending all the values compiled into a JSON string via wifi to a sever and then wait for an "OK" response from the server.

    I hope that makes sense :/

    Anyways, I'm trying to find the duration between sensor readings "sweet spot" where the Pico won't call the individual readings to fast or too slow, sorta like the goldilocks principle.

    So far I need to wait at least 6 seconds(maybe 7 seconds to be safe) for the ec and ph to respond with their readings. I'm not sure about the temp reading using waveform and the wifi duration.

    What do you guys recommend for the durations between readings?

    Also does anyone recommend a better approach to what I'm attempting to do?

  • I'm not sure - what you're doing sounds fine. Maybe rather than setInterval you could just do a setTimeout after you've got the result? It might be simpler than having to have a boolean value as well?

    What are you actually reading the values for? Is it something that is likely to change quickly?

    If it's not going to change quickly, it might actually be worth checking even less often. If you're powering stuff off a battery you could power the sensors down when you don't need them, and checking every 10 minutes vs every 10 seconds would make a massive difference to power usage (if you care about that).

  • @Gordon I am reading ph and ec values which will change but not drastically when the plants feed. I'm reading the values to know when to add nutrients and fix the ph value either by hand or by using a Peristaltic pump. From experience, tomatoes, peppers and cucumbers are heavy feeders so I normally see the values change more often.

    I will take your advise and read every 10 minutes and power down. 10 minutes is well with an acceptable time frame to take all readings and also to save on power.

  • @d0773d what hardware have you selected for ec and ph? Also that peristaltic pump? Have you sampled a variety of options and settled into one that you like? or are you still early in the process?

  • @RandyHarmon I'm using atlas-scientific EZO sensors. Ive tried sparkyswidgets sensors before but the breakout boards are quite large for my project so I settled for atlas. However, atlas sensors are closed sourced which is a bummer, but they seem to work quite well.

    As far as the paristaltic pump, I havent gotten that far.

    I take it that you are working on a project similar to mine? Maybe you have any sensor suggestions?

  • ...I'm sure you came also across this: http://hackaday.com/2015/07/29/universitĀ­y-peristaltic-pump-has-hacker-heritage/ - looks like something to accomplish in/for a protoype - and may be even for operation...

  • @allObjects no, I haven't seen that and thanks for the link. I will see how well my 3d printer can print out the parts needed to create the pump.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Duration between sensor readings?

Posted by Avatar for d0773d @d0773d

Actions