I’m using the PiicoDev ultrasonic rangefinder but getting very unreliable results. I really like the little I2C interface board that you can plug sensors into. I’ve tried the RCWL-1601 (that came with it) and also the Weatherproof ultrasonic sensor (SKU: SEN0208) which has it’s own little board that can plug into the Piico board.
I’m running the Python code on a RPi Model 3B. Both sensors mostly give garbage readings with an occasional “accurate” one. But my questions are more around the I2C board. Looking at PiicoDev_Ultrasonic.py and PiicoDev_Unified.py there are a bunch of class properties that I’ve tried.
Initialising usually returns
sensor = PiicoDev_Ultrasonic()
Incorrect device 33346 found instead of 578 at address=53
However turning the led on and off with sensor.led = True/False is working so clearly board comms is functioning.
Next taking readings with sensor.distance_mm will return mostly large values (>5m) and then occasionally the short distance ~20cm I’m testing.
The sample period (in ms) is set by the ultrasonic library code to be 20, but when I read that back from sensor.period_ms the register mostly returns 32778 and infrequently a 20.
Likewise for the sensor.self_test property returns a lot of 129’s and the occasional 1 (which I would assume to be ok).
Even the sensor.firmware version is not consistent with (129, 128), (1, 128), (1, 0), (129, 0) all possible.
Whoami will flip between 578 (the right answer) and 33346 (the error I see at initialisation).
So my guess is the ultrasonic sensors themselves are not any great problem, but the little chip on the rangefinder board (ATtiny1616 according to the schematic) is not behaving very well. My next option is to wire the sensor direct to the Pi’s GPIO pins - I wrote some code ages ago to make these sensors work in a robot and that was fairly reliable. That would help to confirm, but the Piccodev board is a nice option and I’d hate to have to ditch it.
To confirm everything is as expected would it be possible to send through some photos of your setup?
From the numbers, it looks like there might be a fault somewhere in the connections between (I2C fails high), reseating the connections everywhere is worth a shot and even using different I2C connectors on your Pi PiicoDev adapter.
How were you interfacing with the SEN0208 board? Would it be possible to send through some photos of that as well?
Tried a quick test of the Ultrasonic Sensor running the code available from Core Electronics web site, including the basic test code. Could not duplicate the results you have stated.
Raspberry Pi Pico, I2C 400khz. Worked ok with 100khz.
It sounds like there is a I2C communication problem and that is why you are getting invalid results. But of course there could be a problem with the PiicoDev board you have.
I’ll try to do a bit more investigation later today and get some photos. I did quickly look at a couple of things.
I tried a few different I2C cables since I got the mixed collection of lengths and that made no difference.
Visually it looks like the Piicodev rangefinder board has I2C pull-ups connected by default and there’s no other i2c devices on the bus now. But can I double check with you, is the RCWL-1601 itself operating in I2C mode, or the Trig/Echo mode? I assumed the latter but the pin labeling suggests it can do either of those or UART. Out of curiosity, is i2c comms “enabled” with a surface mount 10k resistor (I saw a photo on Adafruit with one) on those I2C labelled pads? I’m guessing this is a mode change - you’d need two 10k’s do actual pull-up the SDA/SCL lines.
The RCWL-1601 operating as an I2C device makes no sense to me anyway as it would have another address. Also plugging the weatherproof sensor SEN0208 via it’s board into the piico wouldn’t work at all if the piico board was expecting an I2C device. DFRobot’s site clearly shows that sensor’s default operation is mode 0 with Trig/Echo outputs.
This is my best guess.
The RCWL-9600 chip on the back of the RCWL-1601 board can be programmed as Trig/Echo or I2C or Uart using the Resistor pads R5 or R4.It currently works as Trig/Echo.
From the Adafruit forum someone stated the RCWL-9600 is a one time programmable microcontroller. I found a poor quality data sheet for an RCWL-1655 board. It listed one resistor to change to set the interface, R7. 100k 10k 0k NC. The I2C address was listed as 0x57. There is no guarantee this will work with a RCWL-1601 board.