Open WesEvern opened 2 years ago
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.
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.
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.
I've got one coming to me, so once that arrives I'll update the instructions.
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:
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)
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).
Go to the File > Open... menu to open up the Open File Or Folder dialog box.
Enter in /usr/local/lib/python3.7/dist-packages/grove/adc.py, then press the OK button.
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):
Go to the File > Save menu to Save the adc.py file.
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.
In the terminal session to the Pi within VS Code, run nightlight app again by typing python3 app.py
Now it works!
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:
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.
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