HELP Grove Base Hat with LED Socket not working!

Hi all,

For a school project I am building a device using a Raspberry Pi 4, Grove Base Hat and a LED socket.

My goal for now is to blink the LED light on and off.

This is what I’ve done so far.

  1. Connected the Grove Base Hat on to the Raspberry Pi 4.

  2. Started up the Raspberry Pi, opened up a terminal and ran sudo raspi-config. Inside the interface options I enabled the I2C then clicked on finish. And sudo reboot.

  3. I opened up a terminal and ran

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

Installation was done successfully.

  1. Turned off the Raspberry Pi. Connected 3 light sockets on D5, D22 and D24. Then turned the Raspberry Pi on.

  2. cd Desktop and Then nano led.py.
    I wrote a simple script.

from time import sleep
from grovepi import *

led = 5
pinMode(led, "OUTPUT")
sleep(1)

for i in range(2):
    digitalWrite(led, 1)
    print('ON')
    sleep(1)
    digitalWrite(led, 0)
    print('OFF')

print('next..')

led = 22
pinMode(led, "OUTPUT")
sleep(1)

for i in range(2):
    digitalWrite(led, 1)
    print('ON')
    sleep(1)
    digitalWrite(led, 0)
    print('OFF')

print('next..')

led = 24
pinMode(led, "OUTPUT")
sleep(1)

for i in range(2):
    digitalWrite(led, 1)
    print('ON')
    sleep(1)
    digitalWrite(led, 0)
    print('OFF')

print('next..')

led = 25
pinMode(led, "OUTPUT")
sleep(1)

for i in range(2):
    digitalWrite(led, 1)
    print('ON')
    sleep(1)
    digitalWrite(led, 0)
    print('OFF')

print(‘exiting...’)
  1. I ran this script with both sudo python3 led.py and just python3 led.py. The print messages are printed but nothing turns on. I tried changing the file ownership to root and ran it again but still doesn’t work.

I saw someone on the internet trying to run sudo i2cdetect -y 1. Maybe this is something we need for debugging this problem. I ran this command and got:

pi@raspberrypi:~/Desktop $ 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: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --    

Can anyone please help me out? I think my Grove Base Hat is not detected at all. I keep changing the values of led to 5, 22 or 24, but not one led turns on… I will add some pictures!

Hi, @buzzzlightyear,

First, we can quickly test the grove Led , I’ll give you instructions

Step 1: Git clone the Github repository.
git clone https://github.com/Seeed-Studio/grove.py

Step 2: Execute below commands.
cd yourpath/grove.py/grove
then run python grove_led.py 5

after that, you can see the led connected on D5 start to blink, if it’s working please let me know.

Hi @salman ,

When I run this script it does not do anything except for printing some text.

pi@raspberrypi:~/Desktop/grove.py/grove $ python grove_led.py 5
Hat Name = 'Grove Base Hat RPi'

Nothing happens after and I have to force quit this program.

I tried these commands

>> python grove_led.py 5
>> python3 grove_led.py 5
>> sudo python grove_led.py 5
>> sudo python3 grove_led.py 5

It looks like RPI4 and RPI3 are very different and somewhat incompatible.

ok, there might be a problem with grove code on RPi 4, Can you try one more time please, with the below code?

#blinking with gpiozero library
from gpiozero import LED
from time import sleep
led = LED(24)
while True:
    led.on()
    print('LED ON')
    sleep(1)
    led.off()
    print('LED OFF')
    sleep(1)
1 Like

@salman Your a genius!!

It now works! Can you maybe explain in short what the problem was, you think? Has it to do with that the grovepi library is not supported by the Raspberry Pi 4? So from now on I should use the gpiozero library. Do you know if I could use the this library also for other grove sensors especially the grove PIR sensor?

Thanks so far! You’ve helped me a lot!!

The problem with the grovepi library raspberry pi 4 compatibility issues, and gpiozero official library from raspberry pi 4 and no problem with the Raspberry Pi 4, you can use the gpiozero library.

You can find more details about the gpiozero here at https://gpiozero.readthedocs.io/en

for the PIR you can try this with gpiozero

from gpiozero import MotionSensor

pir = MotionSensor(4)  # 4 is pin attached PIR
pir.wait_for_motion()
print("Motion detected!")
1 Like

@salman Thanks for all the help and the well explained solution!

Happy to help you :slightly_smiling_face:, happy-making

1 Like

@salman Is gpiozero working well with grove sensors?If its fully compatible great to hear that :grinning: