Hi all !
Hope everyone is well .
Last night was time to start working on the code to collect all the data and send it away to the remote Arduino MKR 1300 WAN via LoRa .
In my last post regarding the data collecting, everything is wired and working, only missing the LoRa code to send the data away.
Data collecting
In summary, for now, I'm collecting:
- Water temperature
- Enclosure Temperature/Humidity
- Water TDS
- Water PH (as soon as the probe arrives)
- Battery percentage
Here's the testing stuff:
The TDS probe and DS18B20 temperature probe were inserted in my water bottle:
After collecting all these values, for now, I'm displaying them in the console, so I can keep track if everything is perfect.
The following image is an example, with a small problem: The TDS value is way, way high - it should be around 130ppm (tap water).
Why ?
If the TDS code was in a Arduino sketch by itself, the TDS values were perfect, but, without any changes, in the main sketch, I was getting crazy values.
The realization
After about 40m and a lot of testing, I decided to change the order of the functions that collect the values.
The TDS reading was after the battery percentage - after changing the TDS reading to before the battery percentage, the first iteration of the code, the reading was perfect. The next iteration, the values were, again, high.
Why was that ?
The Fix
If you recall, in my post about the battery monitoring on the Arduino MKR 1300 WAN, i've changed the AnalogReference to 1V, so that it can measure with accuracy, the battery voltage.
It turns out, instead of taking a reference of 3.3v when reading the values from the Analog PIN, it was taking 1V . After changing the AnalogReference in the TDS collecting function to the default - 3.3v - the values were back to normal.
LoRa sending
After all this sorted out, just create a "package" (more of a string - still need to see if I can send an array) to send via LoRa and receive it on the other end.
The following image shows this
Nice !
Next Steps
For the data collecting end, while on the testing phase, the code is on a loop and delaying for 10 seconds. This is not what I want - not only because I don't need to collect values every 10s - maybe every hour or 4 times a day, this will drain to much battery.
The next move will be to deep sleep the Arduino and wake up only to collect the values and go back to sleep again.
Stay tuned and stay safe
Note: The code (and explanations of it) will all be shared when this is all working .