Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPi Grove Base Hat with MM32 - I2C error #287

Open
WesEvern opened this issue Aug 19, 2021 · 6 comments
Open

RPi Grove Base Hat with MM32 - I2C error #287

WesEvern opened this issue Aug 19, 2021 · 6 comments

Comments

@WesEvern
Copy link

Hi, I just got my RPi Grove kit but am stuck at the Nightlight experiment.

I am getting the message Check whether I2C enabled and Grove Base Hat RPi inserted

My hat has the MM32 chip instead of the STM32 chip. I posted on the Seeed forum and they advised changing the I2C address to 0x08 in the adc.py. I did that in the /home/pi/grove/grove.py/grove but still no luck. Suggestions?

Thanks,

-Wes

@WesEvern
Copy link
Author

WesEvern commented Aug 23, 2021

Update.

Changing the address in the adc.py file to 0x08 does in fact work as I can run "python adc.py" and it displays values for the light sensor. So appears the address being used in my Nighlight code is not using address 0x08. Need to figure that out.

@WesEvern
Copy link
Author

Update.
Stumbled across that I can run my app.py code, this from IoT-For-Beginners/1-getting-started/lessons/3-sensors-and-actuators/pi-sensor.md, from the Run drop down menu and selecting "Run Without Debugging" which puts a bunch of stuff on the cmd line. It works. Why I am not sure. Perhaps by the end of the course I will know.

@jimbobbennett
Copy link
Contributor

Thanks for the update @WesEvern. I'm going to try to get hold of the new version of this board and put some appropriate instructions in the guide.

@jimbobbennett
Copy link
Contributor

I've got one coming to me, so once that arrives I'll update the instructions.

@marty-optum
Copy link
Contributor

I got it working using the clues in the thread above! This is a bit of a hack, but it works in my environment now, so I'll share my experience here in case it helps others.

Environment - I had installed Raspberry Pi OS in "headless" mode with the smaller install footprint. As a result, I am running VS Code on macOS as my editor, and following the instructions at Remote access to code the Pi.

Here are the steps I took for my workaround:

  1. In the terminal session to the Pi within VS Code, make a backup of adc.py by typing sudo cp /usr/local/lib/python3.7/dist-packages/grove/adc.py /usr/local/lib/python3.7/dist-packages/grove/adc.py.bak (because... safety)

  2. In the terminal session to the Pi within VS Code, change the permissions on adc.py so that you can edit the file from within VS Code by typing sudo chmod 666 /usr/local/lib/python3.7/dist-packages/grove/adc.py (This assumes you installed the python distribution patches in the same location as python3. Your mileage may vary depending on where you installed these Python packages).

  3. Go to the File > Open... menu to open up the Open File Or Folder dialog box.

  4. Enter in /usr/local/lib/python3.7/dist-packages/grove/adc.py, then press the OK button.

  5. In the adc.py file, go to approximately line 57, and change the 0x04 to 0x08 as shown below

    from: def __init__(self, address = 0x04):

    to: def __init__(self, address = 0x08):

  6. Go to the File > Save menu to Save the adc.py file.

  7. In the terminal session to the Pi within VS Code, change the permissions back on adc.py by typing sudo chmod 644 /usr/local/lib/python3.7/dist-packages/grove/adc.py.

  8. In the terminal session to the Pi within VS Code, run nightlight app again by typing python3 app.py

Now it works!

@pmossel
Copy link

pmossel commented Oct 12, 2021

I got the same error message "Check whether I2C enabled..." when I ran the code using a Pi 3 and the just-purchased Base Hat V1.0 with the MM32 chip.

Because not every part of my Grove order had arrived yet, I used the older V1.1 sensor with a CdS cell and the TI LM358 op-amp instead of the suggested grove light sensor v1.2 with photodiode. This did not make a difference since the op-amp just outputs a voltage level to the A0 port.

On a headless Pi 3 with PI OS 10.0 Lite:
Made the change in the base address (0x04 to 0x08) in adc.py proposed by WesEvern.

Pre-test:

  1. connected a light sensor to A0
  2. Run python adc.py

Conclusion: the ADC and drivers work because the light levels output on A0 are converted to digital by the MM32 chip

BUT:
The nightlight code does NOT work in headless mode with the Pi connected to a W10 PC with VS Code. I spent a lot of time investigating but did not get it to work.

Next, I loaded a full desktop OS on a Pi 4 and installed VS Code on the Pi. I followed all instructions including the detailed (Thank you Marty-Optum) to change the base address of the shield to 0x08. And the nightlight code works!!

While I love using VS Code with remote deployment (WSL with Ubuntu on W10), this does not work for the project in this course. I recommend VS Code on the Pi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants