I got the SRF-01 ultrasonic sensor a while ago, as it comes with a grommet, easy-to-use JST connector, and can sense from 0-600cm (many ultrasonic sensors can’t sense the first 15-20cm).
I made use of the Arduino library here, and used the ParticleSoftSerial library to replace Arduino’s SoftwareSerial. However, I’m unsure how to proceed from here. The ParticleSoftSerial library states that it can be used on two digital GPIOs. However, the SRF-01 communicates through a single pin.
Is the ParticleSoftSerial library unsuited for this? Is there any other way I can make this sensor work on an Electron?
I actually had written that library to support half-duplex communication (also for an ultra sonic sensor) since the HW implementation on the Particel devices had some issues with half-duplex.
So pretty sure the current version does still support it. I’d have to see how, but one thing I’d imagine is that providing the same pin as RX and TX should do the trick.
I’ll have to have a test for myself. I do remember that I got correct readings.
You could try changing this line
//SoftSer.sendBreak(); // this uses the default break of 5 bit length
SoftSer.sendBreak(12); // found one source that mentions 12 bit length instead
But about that
AFAIK single transducers won’t be able to sense the first few centimeters reliably due to the latency in switching from transmitter to receiver mode and the physical ringing of the housing after a transmission cycle.
That’s what I figured as well, however on the official datasheet it states that it has an Advanced Mode, where after acquiring 5 measurements beyond 30cm, it will be able to to sense objects as close as just a few centimeters. The process of acquiring 30+ measurements needs to be repeated every now and then however.
I think the regression happened when I migrated the library to the new library structure but must have taken an old version for the migration
But since I’ll have to update the library for the upcoming mesh devices and 0.8.0 will bring some faster interrupts to accomodate for higher baudrates, I’ll probably not push an updated version till then.