I spent the day outside yesterday, adding more sensors to two existing stations, which included some RS485 sensors. I’ll share how I did it and that will hopefully help you along!
The stations are: https://data.envirodiy.org/sites/WSP01/ and
My sensor station added RS485 sensors and a new implementation of hardware I2C for PaleoTerra redox probes (previous probes said they were I2C, but they all had the same address as the Real Time Clock on the Mayfly … and every other RTC, so we had to implement as software I2C, which ate up so many pins). I now have 11 sensors chiming happily away on one Mayfly at each of those stations. We’ll see how the battery holds up, they get a lot of shade.
How I did this is the subject of a blog post in process. I use PlatformIO as my IDE. What *broke* me and forced me into using PlatformIO was managing libraries for the Modular Sensor sketch. And I don’t regret learning to use PlatformIO at all (but other IDEs exist, I just don’t know them by name… pick one!). The Modular Sensor library is the only way I know how to do all the things we need for environmental monitoring (I’m an end-user, not a coder or an engineer). The Modular library is designed to
* get multiple sensors to run with energy efficiency,
* with solar charging and telemetry (Northern Widget hasn’t supported telemetry yet, but they are working on it),
* and more recently with calculated variables (like water level corrected for atmospheric pressure).
This sketch is the starting point that does it all:
Note: There’s a Keller Modbus sensor in this sketch, that might require slight modifications to get it running for your Keller sensors. Keller was very supportive of @aufdenkampe developing Arduino-framework compatibility for their sensors.
I see that with Keller sensors you won’t need atmospheric pressure corrected values to log, but for those who would this sketch has that capacity and it’s the base of the example that I’m sharing below:
This is even more complicated than the logging sketch because in order to calculate variables from two separate sensors, @srgdamiano had to break out some of the functions.
After you peek at those, then look at one of the sketches that I deployed yesterday. It’s modified from baro_rho_correction and it has some extra stuff in the loop because there’s an energy bleed from the RS485 wing. The bleed happens because when the modbus pins are left high, which happens because modbus stop bits are high, and the power is off to the module (the Wagoneer RS485 widget), it bleeds.
Here’s the sketch.
Here’s the PlatformIO ini file that I used to compile/build the sketch, which is how you manage libraries in this IDE.
That’s a lot to take in… I expect you will have next questions! Meanwhile, this is a good push for me work on the blog post that I hope will help people get started in PlatformIO (or their IDE of choice) and Modular Sensors.