Porting SDI-12 Electron library to Boron LTE

Has anyone had success in using the SDI-12 on the Boron or other mesh devices without using a shield?

We came across the electron-sdi12-library and referenced the Electron and Boron pinouts when changing the library’s source code to match the pins on the Boron.

Upload the modified library to the Web IDE and add it to our project.

When compiling in the Web IDE, the following errors are returned:

error
lib/electron-sdi12-library/SDI12Master.cpp:79:16: ‘Serial4’ was not declared in this scope
error
lib/electron-sdi12-library/SDI12Master.cpp:84:16: ‘Serial5’ was not declared in this scope
error
lib/electron-sdi12-library/SDI12Master.cpp:85:12: ‘MO’ was not declared in this scope
error
lib/electron-sdi12-library/SDI12Master.cpp:272:17: ‘C3’ was not declared in this scope
error
lib/electron-sdi12-library/SDI12Master.cpp:275:12: ‘MO’ was not declared in this scope
error
lib/electron-sdi12-library/SDI12Master.cpp:322:12: ‘C3’ was not declared in this scope
error
lib/electron-sdi12-library/SDI12Master.cpp:326:12: ‘MO’ was not declared in this scope
error
lib/electron-sdi12-library/SDI12Master.cpp:361:12: ‘MO’ was not declared in this scope

Is there a possibility of this library working with the Boron, or will I need to develop one for the Boron based on the SDI-12 specification? If not we are just going to use the already working Arduino for SDI-12 data collection and connect the Boron to it.

1 Like

The simple answer to your question is that you should be able to port this library easily to your boron by removing the offending lines as shown in the error message.

The complex answer to your question is that SDI-12 is a little finicky – your hardware will need to match whatever the creator of that libraries hardware looked like.

My advice would be to try to get your Boron talking to your SDI-12 sensor via a transceiver chip with simple Serial.print commands and whatnot and go from there.

1 Like

@Eyeohtee, that library was written for the Electron’s multiple serial ports. It would not take much work to either remove the Electron-specific code or add compiler directives to turn on and off sections of code based on the Particle device type.

2 Likes

Have you had any luck porting the SDI-12 library to the Boron? This is also something we would like to do.

@crispy I know this might sound bad, but we didn’t have time to port the library and instead just used an Arduino Nano copy to handle the SDI-12 from our ClimaVUE50 weather station. We parsed it on the Nano and then sent the data to the Boron’s RX pin through a voltage divider. From there it made it to our server. Sorry I couldn’t be of more help on the mesh SDI-12 library.

1 Like

@crispy, the library is perfectly suited for the Boron. I can clone the repo and make the necessary changes. It also needs to be updated to the v2.0 library format. The testing I will need to leave to you as I don’t have an SDI-12 device to test against.

Thanks for responding and that works!

1 Like

Hi @peekay123, Thank you!

In looking at the original library posted, it looks like it requires external hardware to be able to do SDI-12. It has been implemented without extra hardware using softwareserial. Does anyone know if softwareserial could work on the boron or do we need to build some external circuitry (or use @Eyeohtee solution)?

@crispy, softwareserial is not possible on the Mesh devices at this time. It will run on the Gen2 devices if @ScruffR’s ParticleSoftSerial is used and adapted.

1 Like

Thank you!

Hi All,

I need to do SDI-12 on Boron, and am not clear what the answer was to the question of if it was possible. I have a custom board that level shifts to 5V, I just need to know if there’s a lib or if the Electron code can work to send/receive SDI-12 on a GPIO. Right now honestly I’m having timing issues… :frowning:

Thanks for any help, we chose Boron for the LTE and hope to sell 100s of these a year for telemetry.

In essence the answer was: It should be possible, you may just need to remove the Electron specific stuff from the library and then test whether it actually works.
Since no-one seems to have done the testing, the concept is still to be proven :wink:

However, you cannot use any arbitrary GPIO but need to use the UART pins (RX/TX).

A soft-serial approach is no option for exactly that reason.

Thank you for answering. I am confused however about using a UART to talk on a 1-wire data interface, when the UART is 2 wire for RX/TX. I see from @crispy

it looks like it requires external hardware to be able to do SDI-12. It has been implemented without extra hardware using softwareserial

also from @hwestbrook

My advice would be to try to get your Boron talking to your SDI-12 sensor via a transceiver chip with simple Serial.print commands and whatnot and go from there.

So I think most of my confusion comes from the multiple ways to skin the cat being talked about, and I’m not sure if some are the same, dependent on each other, or what.

If you were me what would you try first?

Can anyone suggest an approach that might work, I guess I’m looking for a mux and 5v converter to go inline with the UART?

The following works for me and our products, but its probably not a “best practice”:

  • RS485 transceiver frontend connected to Boron’s UART
  • 10K pull downs on RS485 A and B
  • SDI-12 data line connected to RS485 B
  • Boron does not support 7E1, so you need to use Serial1.begin(1200, SERIAL_8N1);
  • Using functions from this lib: GitHub - pkourany/SDI12-library: Implementation of SDI-12 protocol for a Particle Devices to translate to and from 7E1
  • Need to switch to and from Serial mode on RX/TX in order to generate the correct timings for SDI-12

Hopefully this helps.

2 Likes

It very helps. I will take this to my people. I already had sdi12 working with Arduino, so I might decide that’s the less troublesome route, to have the Arduino do sdi12 and talk to the boron on the uart :slight_smile:

My people talk of the “curse of sdi12” , this seems to be it.

I’m not a fan of SDI-12 either, but its what our customers want :man_shrugging::man_shrugging:t3:. We use it with high-end soil moisture sensors. I wish all these sensors supported MODBUS over RS485.

The PCB we use for this is our “Valve” controller. I’m not opposed to selling you one to prototype on, although we currently have a limited supply. If you’re interested, send me a DM.

I don’t see a DM option, but I’m interested. Do I have to “friend” you first?

You can click at the “avatar” image then you will see a image button to send a DM.

thank you it was too obvious. :confused: