I’m now trying to dial-in the watering in my garden. I have the garden only watering when it’s not raining based on data from the weather station in the yard. I’m using an LUA script for that. Now I want to use the soil sensor to detect how wet the soil is. For example, it rained all weekend here so my soil is very saturated, but the weather station is reporting that there is no rain (because it hasn’t rained today) so the garden would have watered. I have a sequence that measures the soil, but I’m trying to figure out how to piece all of these together. Is there a place I can store the value of the moisture sensor to then use in a separate sequence or do I have to measure soil first in the watering sequence, then decide when to water? Hope my rambling makes sense
@stre1026 FBOS has a series of internal “registers”. When you read a pin, the value of the reading is cached until the device reboots or a new reading is performed on the same pin number. Since the pin value is cached, you can read the pin once in one sequence, then re-read the same value inside the IF statement of a completely different sequence. The old value will still be used in the second sequence.
Does that help?
This makes sense. What would be the “correct” way to do this? Doing this all in one sequence? When you say reread the same value, how do I do that? Simply call the Soil Sensor again in my new sequence?
You could put a READ PIN block right before an IF block that picks a “rainy day” vs. “sunny day” sequence depending on the value of the sensor. I have actually not done this in a while (my soil is too hard-packed for the standard probe) but it should work fine. Please let me know if you hit any issues.
Is READ PIN the same as READ SENSOR now? I’m not seeing a READ PIN option anymore in my sequence editor. If it is, it doesn’t seem to be retrieving the previous value of my last soil sensor reading.
@stre1026 Sorry, I am still using the old lingo. Yes they are the same.
Can you cross-check what you did with the official documentation and let me know if you are performing the steps in the same manner?
If you are, I can take a deeper look.
This document may also be helpful.
I’m pretty sure I’m doing it correctly. Here’s an example. I made a simple sequence to test and I got these results each time. I would expect the data to be the same each time because I have not actually tested the soil with the sensor so I would expect it to be the same value each time, based on what you said earlier, right?
Here’s the test sequence:
@stre1026 It’s normal for the values to “bounce” a little bit. All of those values are within a few percentages of each other (and since you called READ SENSOR, a new value is fetched each time) so I’d say everything is working as expected. Here’s a blurb from the documentation:
When interpreting results, we recommend dividing by 100 and rounding to the nearest whole number. For example, measurements of 467, 481, 502, and 539, should all be divided and rounded to the same result of 5.
I must be missing something. When I called that Read Sensor, the sensor was not actually attached and I was not actually reading the soil. From your comments above, I thought I could read a cached value that is saved until the bot is rebooted. If that were the case, the cached value would be 730 which is the value that was saved when the sensor was actually mounted and the soil was actually measured. Does this make sense?
Hey @stre1026 Sorry for the confusion here! Every time the Read Sensor sequence step is executed, the FarmBot will read the chosen pin and save/cache the value whether or not anything is actually connected to that pin.
Hi @roryaronson !
Ah this makes sense. I will have to craft a sequence that calls the watering sequence before then!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.