Using NodeRED with the Grove-Base-Hat for raspberry pi

Hi, I am new to both NodeRED and raspberry pi. I'd been reading the excellent book by Taiji Hagino. He uses the node-red-contrib-grove-base-hat. Despite installing it from the palette manager, I am not getting it right. I can make simple flows work in NodeRed and they work well until I use the nodes that are for the Grove-Base-Hat. Seeed Studio's wiki doesn't guide how to use the module for NodeRed. I could use some help

Welcome to the forums @rajsiyer

The first thing to remember, it's possible that no one here uses that Node.
Therefore, may have no answer to gives.

Example: I have no idea what Grove is :man_shrugging:

If you can explain what the issue is in detail and what Grove is, it may help.
if still no answer - you're better off seeking support from the Node Author, but they don't give any help links - so good luck

Looking at the website (https://wiki.seeedstudio.com/Grove_Base_Hat_for_Raspberry_Pi/), they seem to use some python packages. So maybe it is worth following this path and send the sensor inputs via mqtt to node-RED.

@rajsiyer node-red-contrib-grove-base-hat hasn't been updated in over 4 years and if you go to it's GitHub issues section and it looks like it won't work with newer Pi versions.

There is another version you could try:
node-red-contrib-grove-base-hat-bash (node) - Node-RED

Note: I have never used either of them.

Thanks, I'm trying out something and will update the outcome here, so that someone may find it useful. Seeed Studio's Grove sensors and hats are reputed to work well. They are like Adafruit isto the Arduino world. And Taiji Hagino is one of the original creators of NodeRED at IBM. His book is great.

Thanks I'll see where this takes us.

Right and I have seen your reply in 2020 to Steve. Nothing appears to have changed after that. Since the original thread was closed, I had to re-open it here again.

Several people have faced this issue. Like @StevenRott who was helped by zenofmud in 2020. Two years later, fenneck got a solution.

This was indeed the case when I debugged the Grove Base Hat using python. He has done something similar here on this link. contrib-grove-capacitive-moisture-sensor - #6 by fenneck So my expectation is that this will certainly resolve the issue in NodeRed as well.

Hi @rajsiyer,

Do you have modify your adc.py file ?
What is the result now ?

Thanks fenneck, This is the story.

When I first tried using the Grove hat for R-pi, (GHRP) it was on python, outside of Node-Red and guided by the instructions at its Wiki page on Seeed Studio. I had a persistent error "Check whether I2C enabled and Grove Base Hat RPi or Grove
Base Hat RPi Zero inserted…"

This was fixed by these steps...
sudo find / -name adc.py
/usr/local/lib/python3.9/dist-packages/grove/adc.py
/home/pi/.local/lib/python3.9/site-packages/grove/adc.py
/home/pi/grove.py/grove/adc.py

Therein, the file was changed
sudo chmod 666 /usr/local/lib/python3.7/dist-packages/grove/adc.py
Some 50-60 lines down, You'll find a line def __init__(self, address = 0x08): I changed it to: def init(self, address = 0x04):` because the my GHRP is the STM32 variant.

This works beautifully in the python virtual environment. Yes you have to create one.

Coming to NodeRED I have not found the solution, I installed the node node-red-contrib-grove-base-hat. I created a flow, placing the light sensor node between an inject and a debug nodes. When triggered, you see the following responses

on the NodeRed Debug:- ----
12/7/2024, 10:04:48 AMnode: debug 1msg.payload : string[41]
"SyntaxError: Unexpected end of JSON input"

on node-red-log by ssh -ing the pi.
Error: Command failed: python -u /home/pi/.node-red/node_modules/node-red-contrib-grove-base-hat/grove-light-sensor-v1_2/grove-light-sensor-v1_2.py 2 1733546091029
Traceback (most recent call last):
File "/home/pi/.node-red/node_modules/node-red-contrib-grove-base-hat/grove-light-sensor-v1_2/grove-light-sensor-v1_2.py", line 24, in
from grove.adc import ADC
ModuleNotFoundError: No module named 'grove'

Regarding grove.adc . I have not found this file as yet. And when I do I'll change it in the same way as adc.py.

Today, I will try out the other node library suggested by @zenofmud

Please guide by sharing your own experience. Thanks again.

Thank you Sir, this works well. I can resume my journey after being stuck here for a couple of days
Best wishes.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.