PiicoDev issues "incorrect device"

Hi forum, getting a curly one, hoping for input on this issue.

I have a newly setup fresh Pi 3B+ setup exactly per the guide here:

I’m getting bad (~7m) readings & rarely detecting a close object.
I get a message when code starts “incorrect device found at address 53”

i2cdetect -y 1 works & shows sensor at 35

sensor light is on & blinks with activity

if relevant, installing piicodev via Thonny instructions didn’t work (got environment errors) & had to clone the git hub

2 Likes

Hi there @Nick101707, and welcome to the forums, glad to have you here.

There’s definitely something wrong with your I2C addresses there.

The error message ‘incorrect device found at address 53’ indicates that the sensor is not where it’s supposed to be. The 0x35 address is in hexadecimal, or base 16, which means that 0x35 address translates to the decimal 53.

That is triggered because PiccoDev-Ultrasonic class expects itself to have the i2C address of 0x01 when it has the device ID of 578. But, for some reason in your setup, it does not.

One of two things is most likely occuring:

  • Wiring could be off. Could you please upload photos of your setup, taking particular attention to show wiring, so we can confirm if its ok.
  • If you’re getting environment errors in Thonny, it’s likely you have not configured a Virtual Environment. Did you follow the steps here:

1 Like

So here’s a pic of the setup producing this problem.

The environment errors were not in Thonny, I did create the environment there OK.

Problems were when trying to get Thonny to add the piicodev package, eg Using Tools > Manage packages, enter “piicodev” > Search on PyPI gave blank, no results found.

Since that didn’t work, I went to GitHub - CoreElectronics/CE-PiicoDev-PyPI: PyPI package for the PiicoDev ecosystem

and tried this:

Installation

On Raspberry Pi, run the following to install:

sudo pip3 install piicodev

which gave errors about environment

1 Like

It is quite strange that you couldn’t find PiicoDev in Thonny. I just tried on a random computer and it was the top search result. So, I’m not sure what is happening there. But it sounds like you’re not using a Virtual Environment.

Essentially, Raspbian OS is refusing to download the code because it needs Python to function and doesn’t want any changes. To get around this, we need to make a Virtual Environment we can install the dependencies to.

cd /path/to/your/project 
python3 -m venv ultrasonic #Anything you want, ultrasonic seems on theme.
source ultrasonic/bin/activate 
sudo pip3 install piicodev

Then try running your code again.

Oh, and if you want to leave the Venv and go back to the regular shell, just type deactivate. Or close the terminal and open a new one (which is what I usually do…)

If you’re still receiving the same error, please upload a screenshot showing the error message. It will help us solve any issues.

1 Like

Thanks for responding.

Re the env error, this was the issue, solved earlier as Thonny does now have the piicodev package listed in installed packages list.

However, guide instructions didn’t mention this, I got the error, googled, did the above already. I’m guessing this has to be done after the Thonny environment creation & the Thonny env can be used for this? Hopefully posting it here helps others.

Unfortunately after several reboots, the code still glitches as described.

Update: I changed the device addresses with the switches, copying the “Multiple Rangefinders on the same PiicoDev Bus” section in the guide. I did connect both sensors. Suddenly it’s working perfectly, no more “incorrect device” errors.

3 Likes

Hey @Nick101707,

Glad to see this one is up and running! Best of luck with the project.

2 Likes

Hi Nick, Ryan

I wonder why that happened. There has got to be a reason for everything.

How true. Oh how I love those self fixing problems !!! I don’t think.
Cheers Bob

1 Like

I think the issue was the default address. Changing it from default 0000 with the switches seemed to get it going (1,0,0,0 & 0,1,0,0 switch settings worked).

2 Likes

Hi Nic.
Yes that would probably do it. Thanks for confirming.
Cheers Bob

2 Likes