Giter Club home page Giter Club logo

grove.py's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grove.py's Issues

Can't Run Examples

It seems that mraa and upm libraries and not maintained anymore. So you cannot use mraa and upm related Grove modules. FIX THIS BLOODY ISSUE AND DO NOT CLOSE IT AGAIN UNTIL IT IS FIXED.

ADC of Grove Base Hat not working with reTerminal

The analog to digital converter (ADC) of the [https://wiki.seeedstudio.com/Grove_Base_Hat_for_Raspberry_Pi/](Grove Base Hat for Raspberry Pi) is no longer working after commit a4a5c9b.

To get it working, the i2c address 0x04 must be explicitly passed to the ADC class constructor:

from grove.adc import ADC
adc = ADC(address = 0x04)

My understanding is that Seeed is prioritizing a new default micro-controller for the Base Hat (change from STM32 to MM32). However, it is important to clearly inform those who have the STM32 Base Hat of the changes and how to get it working.

I suggest adding a note to the adc.py module and a note on the Base Hat's Wiki page.

Interface Grove Ultrasonic Sensor without shield

Hi,
I am working on interfacing grove ultra sonic sensor v2.0 with my Jetson NX board. I dont have a base hat/shielf/I2C adapter. I want to interface the sensor directly with Jetson board.

I started with looking into : https://wiki.seeedstudio.com/Grove-Ultrasonic_Ranger/ where they have mentioned "If we don't have Grove Base Shield, We also can directly connect Grove_Ultrasonic_Ranger to Seeeduino as below." But this example C library will not work since it uses arduino library.h.

Then I started to work with code in this git: https://github.com/Seeed-Studio/grove.py/blob/master/grove/grove_ultrasonic_ranger.py
Like I mentioned I dont have base shield so I replaced (pin number) with my GPIO pin and got the below error.

Check whether I2C enabled and Grove Base Hat RPi or Grove Base Hat RPi Zero inserted

So i had to remove the lines 98 to 100 and directly configure my pin number and try. It is just printing "Detecting distance.." and nothing else.

It would be really helpful to get some inputs on this.

Regards
Niranjan

I can not RUN Grove KiT on Raspberry Pi 400 and Pi 8GB

curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:3 https://seeed-studio.github.io/pi_repo stretch InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-pip is already the newest version (20.3.4-4+rpt1+deb11u1).
The following package was automatically installed and is no longer required:
libfuse2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I2C interface enabled...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-rpi.gpio' has no installation candidate
dpkg-query: package 'python-rpi.gpio' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-rpi.gpio' has no installation candidate
dpkg-query: package 'python-rpi.gpio' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-rpi.gpio' has no installation candidate
dpkg-query: package 'python-rpi.gpio' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.

 Grove.py installation FAILED, FAILED, FAILED      

Grove Kit does not install on Raspberry Pi 400 - 8gb

curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:3 https://seeed-studio.github.io/pi_repo stretch InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-pip is already the newest version (20.3.4-4+rpt1+deb11u1).
The following package was automatically installed and is no longer required:
libfuse2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I2C interface enabled...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-rpi.gpio' has no installation candidate
dpkg-query: package 'python-rpi.gpio' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-rpi.gpio' has no installation candidate
dpkg-query: package 'python-rpi.gpio' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

GPS module only reads US satellites

In the GPS module code, the only source that is detected is GP, the US GPS constellation. The Air530 sensor supports other constellations, but this library is unable to detect them.

The logic in the read function should ignore the 2 characters for the sender field at the start of the NMEA message to support other constellations.

Unable to install dependencies upm and mraa on Raspberry Pi Bullseye

Possibly related to issue #46, I can't get the dependencies upm and mraa installed:

sudo apt install python3-mraa python3-upm
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python3-mraa : Depends: libjson-c3 (>= 0.10) but it is not installable
                Depends: libmraa1 but it is not going to be installed
                Depends: libpython3.5 (>= 3.5.0~b1) but it is not installable
 python3-upm : Depends: libmraa1 but it is not going to be installed
               Depends: libpython3.5 (>= 3.5.0~b1) but it is not installable
               Depends: libupm1 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Can not run codes at other than the root directory of grove.py

I installed the package as it is described in the documentation but I can't call GPIO of grove.gpio like from grove.gpio import GPIO because it throws an error that No module named grove.gpio etc. But when I copy my python file into the root directory of grove.py and run it, everything seems ok and the code works. What is the problem with that? Shouldn't I be able to run my codes which call grove classes/modules from any location on a Pi?

grove water sensor example seems incorrect?

I tried to follow grove water sensor example shown in https://github.com/Seeed-Studio/grove.py/blob/master/grove/grove_water_sensor.py
The below condition is opposite in my case:

if sensor.value > 800:
            print("{}, Detected Water.".format(value))
        else:
            print("{}, Dry.".format(value))

It prints >800 Detected water when sensor is not in water and prints <800 Dry when sensor is in water..

Is that expected ?

Can't install Grove lib on Jetson Nano

Hi, I'm getting some permissions errors I can't seem to resolve on my own when running curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s –
I've tried running the curl command as root, and setting sudo's -H flag as the error message suggests, but still got the following errors. Was wondering if you had suggestions for getting around what appears to be user conflicts between user root and my user?


...
upgraded, 0 newly installed, 0 to remove and 53 not upgraded.
The directory '/home/kristin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/kristin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Collecting smbus
Downloading https://files.pythonhosted.org/packages/4d/5c/70e14aa4f0c586efc017e1d1aa6e2f7921eefc7602fc2d03368ff912aa91/smbus-1.1.post2.tar.gz (104kB)
100% |████████████████████████████████| 112kB 1.6MB/s
Installing collected packages: smbus
Running setup.py install for smbus ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-9ddcdzvv/smbus/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-cuxgtx1g-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'i2c' library
b''
building 'smbus' extension
creating build
creating build/temp.linux-aarch64-3.7
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c smbusmodule.c -o build/temp.linux-aarch64-3.7/smbusmodule.o -Iinclude
smbusmodule.c:20:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-9ddcdzvv/smbus/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-cuxgtx1g-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9ddcdzvv/smbus/
The directory '/home/kristin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/kristin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Collecting smbus
Downloading https://files.pythonhosted.org/packages/4d/5c/70e14aa4f0c586efc017e1d1aa6e2f7921eefc7602fc2d03368ff912aa91/smbus-1.1.post2.tar.gz (104kB)
100% |████████████████████████████████| 112kB 1.9MB/s
Installing collected packages: smbus
Running setup.py install for smbus ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-4bystfwg/smbus/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-o4ar8ut6-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'i2c' library
b''
building 'smbus' extension
creating build
creating build/temp.linux-aarch64-3.7
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c smbusmodule.c -o build/temp.linux-aarch64-3.7/smbusmodule.o -Iinclude
smbusmodule.c:20:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-4bystfwg/smbus/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-o4ar8ut6-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-4bystfwg/smbus/
The directory '/home/kristin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/kristin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Collecting smbus
Downloading https://files.pythonhosted.org/packages/4d/5c/70e14aa4f0c586efc017e1d1aa6e2f7921eefc7602fc2d03368ff912aa91/smbus-1.1.post2.tar.gz (104kB)
100% |████████████████████████████████| 112kB 2.1MB/s
Installing collected packages: smbus
Running setup.py install for smbus ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-8lpoao6f/smbus/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-ki5y2f3q-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'i2c' library
b''
building 'smbus' extension
creating build
creating build/temp.linux-aarch64-3.7
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c smbusmodule.c -o build/temp.linux-aarch64-3.7/smbusmodule.o -Iinclude
smbusmodule.c:20:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-8lpoao6f/smbus/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-ki5y2f3q-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-8lpoao6f/smbus/

 Grove.py installation FAILED, FAILED, FAILED      

Strip Led is not working

using GROVE BASE HAT RPI with Grove - RGB Led ring (16-WS2813 Mini)
On Rpi 3B Buster version
The Led are on PWM slot .
i can't get the leds switch on
and no error message is given

code :
from grove.i2c import Bus
from rpi_ws281x import PixelStrip
from time import time, sleep
from grove.gpio import GPIO
from RPi import GPIO as io

def light_led(led, pix, r, g, b):
for pixel in range(pix):
led.setPixelColorRGB(pixel, r, g, b)

print("led mode {} {} {}".format(str(r),str(g),str(b)))
led.show()

led20 = PixelStrip(16, 12) # Grove RGB led connected to grove PWM
led20.begin()

light_led(led20, 16, 55, 0,0)
sleep(5)
light_led(led20, 16, 0, 55, 0)
sleep(5)
led20._cleanup()

Problem opening multiple i2c busses at the same time

in i2c.py the line #51

Bus.instance = smbus.SMBus(bus)

causes problems when trying to open two distinct i2c busses from the same app. in our case both calls would open a device on the same i2c bus.

changing to

self.instance = smbus.SMBus(bus)

fixed the problem.

using respberry py at the paj7620 sensor on i2c bus 1 & 3

Trouble installing grove.py

Hello,

I've been playing around with an OKdo Air Quality kit and I seem to have fallen at an early hurdle.

The installation of grove.py on to a Pi using the command below seems to go well until the very end where I am told that the installation failed.

curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -

main: line 107: pip: command not found
main: line 108: pip: command not found
main: line 107: pip: command not found
main: line 108: pip: command not found
main: line 107: pip: command not found
main: line 108: pip: command not found

 Grove.py installation FAILED, FAILED, FAILED

Any thoughts on how to solve this would be awesome.

regards,

"grove_temperature_humidity_sensor" command is not found.

I want to use Temperature & Humidity Sensor(DHT11).

I installed grove.py following the steps.
But [grove_temperature_humidity_sensor] Command is not found.
Also, I can't find the source code(grove_temperature_humidity_sensor.py).

[grove_temperature_humidity_bme680] Command and [grove_temperature_humidity_sht31] Command can be confirmed.

Please let us know if you know why it doesn't work.
Thank you very much.

Problem in i2c.py opening multiple i2c busses

This issue was reported by @nikolozka in Issue #12.

The issue is still in the code and I would like to submit a PR for it, however, I'm trying to understand the reasoning behind this.

class Bus:
    instance = None
    MRAA_I2C = 0

    def __init__(self, bus=None):
       ... skipping code ...

       if not Bus.instance:
            Bus.instance = smbus.SMBus(bus)

      ... rest of code ...

Why is instance being used as a class attribute? It effectively makes the Bus class a singleton class.
Are there any advantages to doing this that I'm missing?

To reproduce this problem:

  • Connect a Base Hat to the reTerminal.
  • Use an analog sensor such as the Grove Soil Humidity sensor with the ADC of the Base Hat.
  • Create a new I2C bus 4 for the reTerminal (using this example).
  • Connect an I2C sensor such as the AHT20 temperature & humidity sensor to the base hat.
  • Try to read from both sensors.
File "/usr/local/lib/python3.7/dist-packages/grove/grove_temperature_humidity_aht20.py", line 44, in read
    self.bus.write_i2c_block_data(self.address, 0x00, [0xac, 0x33, 0x00])
File "/usr/local/lib/python3.7/dist-packages/smbus2/smbus2.py", line 643, in write_i2c_block_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 6] No such device or address

Support for WS2813 RGB LED strips on Jetson Nano

Any idea on if or when this will be available? Or does anyone know of any alternative libraries I can use to connect the Jetson Nano to an LED strip (not just aWS2813 - I'm also looking at using a WS2812 or WS2812B)

issue with UPM: No module named UPM

Hi,

I have an rpi model 3b
pi@mark2:~/python/grove.py $ uname -a Linux mark2 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

pi@mark2:~/python/grove.py $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 9.8 (stretch) Release: 9.8 Codename: stretch

The install script seems to run succesffully:

#######################################################

  Lastest Grove.py from github install complete   !!!!!

#######################################################

mraa and upm are installed on my pi:

pi@mark2:~/python/grove.py $ dpkg -s libupm1
Package: libupm1
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 4238
Maintainer: Flavian Costin Manea <[email protected]>
Architecture: armhf
Source: upm
Version: 1.6.0-git20190404-pi20190404
Depends: libc6 (>= 2.15), libgcc1 (>= 1:3.5), libjpeg62-turbo (>= 1.3.1), libmraa1, libstdc++6 (>= 6)
Description: Sensor/Actuator repository for MRAA (runtime)
 UPM is a high level repository for sensors that use MRAA. Each sensor
 links to MRAA and are not meant to be interlinked although some
 groups of sensors may be.
 .
 This package contains the library used at runtime.
Homepage: http://iotdk.intel.com/docs/master/upm/
pi@mark2:~/python/grove.py $ dpkg -s libmraa1
Package: libmraa1
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 183
Maintainer: Tom Ingleby <[email protected]>
Architecture: armhf
Source: mraa
Version: 1.9.0-git20190404-pi20190404
Depends: libc6 (>= 2.15), libjson-c3 (>= 0.10)
Description: userspace I/O library (runtime)
 mraa (libmraa) is library for interacting with userspace I/O on GNU/Linux
 platforms. The library abstracts platform quirks away from the end user.
 Currently interfaces supported include GPIO/PWM/I2C/SPI.
 .
 This package contains the library used at runtime.
Homepage: http://iotdk.intel.com/docs/master/mraa/

Yet when I try to run grove_temperature_sensor I get this error:

Traceback (most recent call last):
  File "/usr/local/bin/grove_temperature_sensor", line 11, in <module>
    load_entry_point('grove.py==0.6', 'console_scripts', 'grove_temperature_sensor')()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 487, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2728, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2346, in load
    return self.resolve()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2352, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.7/site-packages/grove/grove_temperature_sensor.py", line 31, in <module>
    from grove.factory import Factory
  File "/usr/local/lib/python3.7/site-packages/grove/factory/__init__.py", line 2, in <module>
    from .factory import *
  File "/usr/local/lib/python3.7/site-packages/grove/factory/factory.py", line 38, in <module>
    from grove.temperature import *
  File "/usr/local/lib/python3.7/site-packages/grove/temperature/__init__.py", line 2, in <module>
    from .mcp9808 import TemperMCP9808
  File "/usr/local/lib/python3.7/site-packages/grove/temperature/mcp9808.py", line 38, in <module>
    from upm.pyupm_mcp9808 import MCP9808
ModuleNotFoundError: No module named 'upm'

this is with version 0.6.
Is there any way you can help me with this?

Kind regards,
Chris

Errors when installing on a Raspberry Pi running Bullseye

When running this script on a Raspberry Pi running Bullseye, I get the following errors:

pi@tracker:~ $ curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -
deb https://seeed-studio.github.io/pi_repo/ stretch main
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
100  3822  100  3822    0     0  15991      0 --:--:-- --:--:-- --:--:-- 15991
OK
Get:1 https://seeed-studio.github.io/pi_repo stretch InRelease [3,167 B]
Hit:2 http://raspbian.raspberrypi.org/raspbian bullseye InRelease                                                                                
Hit:3 http://archive.raspberrypi.org/debian bullseye InRelease                                                      
Get:4 https://seeed-studio.github.io/pi_repo stretch/main armhf Packages [31.0 kB]
Fetched 34.1 kB in 1s (32.2 kB/s) 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python3-pip

E: Package 'python-pip' has no installation candidate
dpkg-query: package 'python-pip' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-pip is already the newest version (20.3.4-4+rpt1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Enable I2C interface ...
I2C interface enabled...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-rpi.gpio' has no installation candidate
dpkg-query: package 'python-rpi.gpio' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-rpi.gpio' has no installation candidate
dpkg-query: package 'python-rpi.gpio' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-rpi.gpio is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-rpi.gpio' has no installation candidate
dpkg-query: package 'python-rpi.gpio' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
-------------------------------------------------------
     Grove.py installation FAILED, FAILED, FAILED      
-------------------------------------------------------

This looks like the Python2 packages are not compatible with bullseye, which makes sense as Python2 has been deprecated. It would be nice if the script was update to only install Python3 libraries to avoid these errors.

Illegal instruction

If I import this:

from grove.factory import Factory 

and run python3 main.py, I get:

Illegal instruction

Any idea why?

grove_imu_9dof_icm20600_ak09918 module seems to not work

I'm a pretty new user of Grove modules. I have successfully run 16x2 LCD and ultrasonic ranger with that Python library but I can't run IMU9DOFICM20600 (gyro/accelerometer/compass) with it.

What I try:

from grove.grove_imu_9dof_icm20600_ak09918 import GroveIMU9DOFICM20600

imu = GroveIMU9DOFICM20600()

and just instantly I get an error message being logged: Failed to open i2c bus /, error = -1. It's not an exception, I can still go on and run methods like imu.get_accel() or imu.get_gyro() but they keep returning all zeros. That module have no documentation in the library so I don't have an idea if I do something wrong. Did anyone use that module and can confirm it works?

Device info:
Raspberry Pi 2B
Raspbian 10 "Buster"
Python 3.7.3
I use Grove Base Hat for Raspberry Pi.
IMU 9DOF v.2.2 is connected to the first I2C port on the hat.
I have the newest version of the library installed from source.
I have other devices connected to the hat (ultrasonic ranger and LCD) but tried to remove them and it didn't help.
I've run i2cdetect and it seems like 68 address is detected.

pi@raspberrypi:~/work $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3e -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --      

Installation of python3-mraa fail on Debian GNU/Linux 10 (buster) on docker container

Hello. I want to use GrovePi on my Raspberry Pi 4 on top of IoT Edge runtime (docker engine).
I prepared python module, but have problems with installing all dependencies in dockerfile.
I am using: arm32v7/python:3.7-buster as base image. Image using Debian GNU/Linux 10 (buster) as OS.
Using instructions of both auto and manual install of dependencies, I end up with error:

The following packages have unmet dependencies:
 python3-mraa : Depends: libpython3.5 (>= 3.5.0~b1) but it is not installable
E: Unable to correct problems, you have held broken packages.

The same instructions work well directly on Raspberry Pi 4. (which is Raspbian GNU/Linux 10 (buster))

I know that this is due to some python libraries missing - but both distributions have 3.7.5. What is done extra in Raspbian distribution that this instructions works, and on pure buster, not?

How to fix that?
Thanks in advance for help :)

curl installation fails due to libmraa1 and libbma456

When I try to use the online option (curl) to install grove.py I get the following error:

fjp@ubuntu:~/git/grove.py$ curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -
Warning: apt-key output should not be parsed (stdout is not a terminal)
Hit:1 http://ports.ubuntu.com/ubuntu-ports bionic InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports bionic-updates InRelease                                       
Hit:3 http://ports.ubuntu.com/ubuntu-ports bionic-backports InRelease                                     
Hit:4 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease                
Hit:5 https://seeed-studio.github.io/pi_repo stretch InRelease                      
Hit:6 http://ports.ubuntu.com/ubuntu-ports bionic-proposed InRelease
Hit:7 http://ppa.launchpad.net/oibaf/graphics-drivers/ubuntu bionic InRelease
Hit:8 http://packages.ros.org/ros/ubuntu bionic InRelease     
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
N: Skipping acquire of configured file 'main/binary-arm64/Packages' as repository 'https://seeed-studio.github.io/pi_repo stretch InRelease' doesn't support architecture 'arm64'
Enable I2C interface ...
I2C interface enabled...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-rpi.gpio is already the newest version (0.6.3-1ubuntu4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-rpi.gpio is already the newest version (0.6.3-1ubuntu4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libmraa1
dpkg-query: package 'libmraa1' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libmraa1
dpkg-query: package 'libmraa1' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libmraa1
dpkg-query: package 'libmraa1' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
-------------------------------------------------------
     Grove.py installation FAILED, FAILED, FAILED      
-------------------------------------------------------

I think this happens because libmraa1 cannot be located.

Installing libmraa from here with the following commands:

sudo add-apt-repository ppa:mraa/mraa
sudo apt-get update
sudo apt-get install libmraa2 libmraa-dev libmraa-java python-mraa python3-mraa node-mraa mraa-tools

After that, I executed the curl command again and got a little further but the installation of grove.py stilll fails because of libbma456:

fjp@ubuntu:~/git/grove.py$ curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -
Warning: apt-key output should not be parsed (stdout is not a terminal)
Hit:1 http://ports.ubuntu.com/ubuntu-ports bionic InRelease
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic-updates InRelease [88.7 kB]                             
Hit:3 https://seeed-studio.github.io/pi_repo stretch InRelease                                                       
Get:4 http://ports.ubuntu.com/ubuntu-ports bionic-backports InRelease [74.6 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease [88.7 kB]
Get:6 http://ports.ubuntu.com/ubuntu-ports bionic-proposed InRelease [242 kB]
Get:7 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 DEP-11 Metadata [290 kB]
Get:8 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main DEP-11 48x48 Icons [73.8 kB]
Get:9 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main DEP-11 64x64 Icons [147 kB]     
Get:10 http://ports.ubuntu.com/ubuntu-ports bionic-updates/universe arm64 DEP-11 Metadata [259 kB]
Get:11 http://ports.ubuntu.com/ubuntu-ports bionic-updates/universe DEP-11 48x48 Icons [207 kB]     
Get:12 http://ports.ubuntu.com/ubuntu-ports bionic-updates/universe DEP-11 64x64 Icons [445 kB]
Get:13 http://ports.ubuntu.com/ubuntu-ports bionic-backports/universe arm64 DEP-11 Metadata [7976 B]
Get:14 http://ports.ubuntu.com/ubuntu-ports bionic-security/main arm64 DEP-11 Metadata [32.6 kB]
Get:15 http://ports.ubuntu.com/ubuntu-ports bionic-security/main DEP-11 48x48 Icons [17.6 kB]
Get:16 http://ports.ubuntu.com/ubuntu-ports bionic-security/main DEP-11 64x64 Icons [41.5 kB]
Get:17 http://ports.ubuntu.com/ubuntu-ports bionic-security/universe arm64 DEP-11 Metadata [37.0 kB]
Get:18 http://ports.ubuntu.com/ubuntu-ports bionic-security/universe DEP-11 48x48 Icons [16.4 kB]
Get:19 http://ports.ubuntu.com/ubuntu-ports bionic-security/universe DEP-11 64x64 Icons [111 kB]  
Get:20 http://ports.ubuntu.com/ubuntu-ports bionic-proposed/main arm64 DEP-11 Metadata [4612 B] 
Get:21 http://ports.ubuntu.com/ubuntu-ports bionic-proposed/universe arm64 DEP-11 Metadata [212 B]
Hit:22 http://ppa.launchpad.net/mraa/mraa/ubuntu bionic InRelease                                                                                                                        
Hit:23 http://ppa.launchpad.net/oibaf/graphics-drivers/ubuntu bionic InRelease                                                                                                           
Hit:24 http://packages.ros.org/ros/ubuntu bionic InRelease                                                                                                                               
Fetched 2185 kB in 11s (198 kB/s)                                                                                                                                                        
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
N: Skipping acquire of configured file 'main/binary-arm64/Packages' as repository 'https://seeed-studio.github.io/pi_repo stretch InRelease' doesn't support architecture 'arm64'
I2C interface enabled...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-rpi.gpio is already the newest version (0.6.3-1ubuntu4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-rpi.gpio is already the newest version (0.6.3-1ubuntu4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libmraa1
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 59.1 kB of archives.
After this operation, 179 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/mraa/mraa/ubuntu bionic/main arm64 libmraa1 arm64 1.9.0-1~ubuntu18.04 [59.1 kB]
Fetched 59.1 kB in 10s (5800 B/s)   
Selecting previously unselected package libmraa1.
(Reading database ... 211870 files and directories currently installed.)
Preparing to unpack .../libmraa1_1.9.0-1~ubuntu18.04_arm64.deb ...
Unpacking libmraa1 (1.9.0-1~ubuntu18.04) ...
Setting up libmraa1 (1.9.0-1~ubuntu18.04) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-mraa is already the newest version (2.0.0-1~ubuntu18.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libupm1
The following NEW packages will be installed:
  libupm1 python-upm
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3962 kB of archives.
After this operation, 39.3 MB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/mraa/mraa/ubuntu bionic/main arm64 libupm1 arm64 1.7.1-1~ubuntu18.04 [656 kB]
Get:2 http://ppa.launchpad.net/mraa/mraa/ubuntu bionic/main arm64 python-upm arm64 1.7.1-1~ubuntu18.04 [3307 kB]
Fetched 3962 kB in 11s (352 kB/s)     
Selecting previously unselected package libupm1.
(Reading database ... 211875 files and directories currently installed.)
Preparing to unpack .../libupm1_1.7.1-1~ubuntu18.04_arm64.deb ...
Unpacking libupm1 (1.7.1-1~ubuntu18.04) ...
Selecting previously unselected package python-upm.
Preparing to unpack .../python-upm_1.7.1-1~ubuntu18.04_arm64.deb ...
Unpacking python-upm (1.7.1-1~ubuntu18.04) ...
Setting up libupm1 (1.7.1-1~ubuntu18.04) ...
Setting up python-upm (1.7.1-1~ubuntu18.04) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-mraa is already the newest version (2.0.0-1~ubuntu18.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  python3-upm
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3264 kB of archives.
After this operation, 33.5 MB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/mraa/mraa/ubuntu bionic/main arm64 python3-upm arm64 1.7.1-1~ubuntu18.04 [3264 kB]
Fetched 3264 kB in 12s (283 kB/s)      
Selecting previously unselected package python3-upm.
(Reading database ... 212946 files and directories currently installed.)
Preparing to unpack .../python3-upm_1.7.1-1~ubuntu18.04_arm64.deb ...
Unpacking python3-upm (1.7.1-1~ubuntu18.04) ...
Setting up python3-upm (1.7.1-1~ubuntu18.04) ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libbma456
dpkg-query: package 'libbma456' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libbma456
dpkg-query: package 'libbma456' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libbma456
dpkg-query: package 'libbma456' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
-------------------------------------------------------
     Grove.py installation FAILED, FAILED, FAILED      
-------------------------------------------------------

I couldn't find out how to install the missing dependency libbma456. Any ideas how I can fix this? Thank you!

Issue with one click installation on Ubuntu 18.04 LTS

I want to use Grove Base Hat for Raspberry Pi 3B running Ubuntu 18.04 LTS.

I tried
curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -
But it never succeeds with the below error messages,
main line 30: lua command not found
main line 82: dtparam command not found
E: Unable to locate package libmraal
dpkg-query: package 'libmraa1' is not installed and no information is available

I have executed "sudo add-apt universe" so that i see "universe" in /etc/apt/source.line

My goal is to complete installing grove.py so that user application has path to Grove hardware

Raspberry Pi 4 and hat not working

I have two different raspberry Pi 4 b and each has the same issue.

'No modules name upm'

I followed the instructions on #46 but it didn't work.

I also followed all the instructions on the wiki as well.

I have I2C enabled.
Python 3.9.2
OS: Linux Debian GNU Linux 11

It was the 64-bit image provided by Raspberry Pi folks.

Please advise.

Thank you

ADC.version() - wrong implementation for register 0x03

@property def version(self): return self.read_register(0x3)

Reading from this register doesn' t return a firmware version - int value.
Reapeated reading from this register returns following string:
GROVE BASE HAT RPI

I2C error (Please check if the I2C device insert in I2C of Base Hat)

I'm getting this I2C error which I can't seem to figure out why:

raceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/seeed_si114x.py", line 296, in _ReadByte
    read_data = self.bus.read_byte_data(self.addr,Reg)
  File "/usr/local/lib/python3.9/dist-packages/smbus2/smbus2.py", line 433, in read_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/logic/./tests/sunlight_test.py", line 16, in <module>
    main()
  File "/home/pi/logic/./tests/sunlight_test.py", line 7, in main
    SI1145 = seeed_si114x.grove_si114x()
  File "/home/pi/.local/lib/python3.9/site-packages/seeed_si114x.py", line 184, in __init__
    assert self.Begin() , "Please check if the I2C device insert in I2C of Base Hat"
  File "/home/pi/.local/lib/python3.9/site-packages/seeed_si114x.py", line 194, in Begin
    if self._ReadByte(SI114X_PART_ID) != 0X45:
  File "/home/pi/.local/lib/python3.9/site-packages/seeed_si114x.py", line 298, in _ReadByte
    raise  OSError("Please check if the I2C device insert in I2C of Base Hat")
OSError: Please check if the I2C device insert in I2C of Base Hat
Exception ignored in: <function grove_si114x.__del__ at 0xb659cad8>
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/seeed_si114x.py", line 186, in __del__
    self._WriteByte(SI114X_COMMAND, SI114X_RESET)
  File "/home/pi/.local/lib/python3.9/site-packages/seeed_si114x.py", line 306, in _WriteByte
    raise OSError("Please check if the I2C device insert in I2C of Base Hat")
OSError: Please check if the I2C device insert in I2C of Base Hat

The code I'm running is from: https://github.com/Seeed-Studio/Seeed_Python_SI114X/blob/master/examples/BasicRead.py
but the error message indicates that it's within this library? (please correct me if I'm wrong)

  • I found some sources claiming that the "OSError: Please check if the I2C device insert in I2C of Base Hat" is due to incorrect wiring but I don't see how this would be the case when using the Pi hat..
  • I've checked with "i2cdetect -y 1" to make sure the device is recognised (it is)
  • The above error ("OSError: [Errno 121] Remote I/O error") goes away when I type in the I2C device address manually (in my case 0x53), but the bottom error ("OSError: Please check if the I2C device insert in I2C of Base Hat") remains..
  • I'm using this module from grove: https://wiki.seeedstudio.com/Grove-Sunlight_Sensor/
  • I've tried clean-installing from scratch and only downloading the required libs for the hat+sensor
  • I've also tried installing from source (this repo) instead of fetching directly from pip
  • I've tried using a different Pi (same specs) just to be sure it's not an issue with my pi

Unfortunately I don't have any other I2C devices I can try.

i2cdetect -y 1 output:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         08 -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --   

I'm running raspbian 11 (bullseye) on a raspberry pi 4

Bug: Wrong i2c bus number for CM4

Problem

The smbus instantiation logic in i2c.py selects the wrong i2c bus number for CM4 Pi.

This presents itself in the form of an uncaught IOError that crashes a python script when any of the adc methods are called, for eg:

>>> from grove.adc import ADC
>>> adc = ADC() 
>>> print(adc.read_voltage(0))
Check whether I2C enabled and   Grove Base Hat RPi  or  Grove Base Hat RPi Zero  inserted

I have written a workaround (see Bug Fix) but I don't understand the i2c logic well enough to know if this is the appropriate resolution in general.

Explanation

When the ADC class is instantiated, the bus number is chosen based on the value of GPIO.RPI_REVISION. See https://github.com/Seeed-Studio/grove.py/blob/master/grove/i2c.py#L39-L49.

I don't understand the motivation behind this choice, but I can see it causes the wrong outcome for CM4 Pis (such as the reTerminal).

The CM4 has RPi.GPIO.RPI_REVISION=0. https://raspi.tv/2014/rpi-gpio-quick-reference-updated-for-raspberry-pi-b.

The above logic results in bus=0 for the smbus used by the adc class. However, the bus should be 1, as can be seen by running i2cdetect:

pi12@pi12:~/ $ i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

pi12@pi12:~/ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
40: -- -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                 

Environment

Example

Assume there is an analog device connected at A0, that the i2c interface is enabled, and that there are no wiring issues (as can be seen by the successful "Bug Fix" result).

Bug

>>> from grove.adc import ADC
>>> adc = ADC(0x04) # 0x04 for STM base hat, see https://github.com/Seeed-Studio/grove.py/issues/64 
>>> print(adc.read_voltage(0))
Check whether I2C enabled and   Grove Base Hat RPi  or  Grove Base Hat RPi Zero  inserted

Bug Fix

It is possible to extend the definition of the ADC class such that the bus number can be chosen at instantiation.

>>> import grove.i2c
>>> from grove.adc import ADC
>>> class customADC(ADC):
...    def __init__(self, address=0x04, bus=1)
...        self.address=address
...        self.bus=grove.i2c.Bus(bus)
...
>>> adc = customADC() 
>>> print(adc.read_voltage(0))
1628

Since we can make bus an optional parameter, this extension could be pulled upstream without breaking the interface, however, this would replace the existing bus determination logic.

Is that better? In my case, yes, since the bus determination logic does not work for my device. But, I'm not sure in general what makes the most sense, I don't understand how i2c bus numbers are determined for different devices.

Related issues

Not 100% certain, but this may be related to the following issues:

#70
#68
#61
#46

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.