[SOLVED] How does RPI communicate with GrovePi Sensors

Hello ,
I’m using the grovepi + shield to plug my DHT sensor V1.2 on D4.
Can someone explain me how data are sent between Raspberry PI3 and the shield GrovePi and my Grove sensor of temperature & humidity ?
Thank you

Hi @Erazin,


A short intro

The benefit of the Raspberry Pi is that it has Linux on it and we can program basically anything we want. We have at our disposal entire libraries for everything.

The disadvantage with the Raspberry Pi is that it can’t do real-time processing since all the programs “sit” on top of a kernel, which has the task of prioritizing every process. So, any given process can wait an indefinite time before it’s allowed to run. This is not good for devices which require real-time assistance.

Because of this, the Raspberry Pi wasn’t made to interface with actuators/sensors/modules/etc - it’s just not productive. And let’s not forget that most of these peripherals work at 5V as opposed to 3.3V (the operating voltage of the Raspberry Pi).

On the other hand, we have the RISC chips, which are really good at doing what the Raspberry Pi can’t do.

So, we have combined the benefit of working with a RISC chip and a full-blown Linux machine. And the way to do this is by using the GrovePi - a device which sits nicely on top of the Raspberry Pi.


The Sensor-GrovePi-RaspberryPi Trio

Sensor-GrovePi communication

The Grove DHT sensor communicates only with the GrovePi through the use of digital ports. (like D4 for instance).
Since the Grove DHT is a digital sensor, it means the GrovePi has to issue digital commands to the Grove DHT sensor in order to get the sensor values.

GrovePi-RaspberryPi communication

The Raspberry Pi and the GrovePi communicate only through I2C.
The Raspberry Pi is the master and is the one which initiates communication, while the GrovePi is the slave, which does everything Raspberry Pi requests.

For instance, when you execute a function from the grovepi module (like grovepi.analogRead(0)) on your Raspberry Pi, the request is going to be made of the following 2 elements:

  • a header - here we store information regarding the type of information / data we hold in the payload. For each kind of function we call from the grovepi module, on the Raspberry Pi, we send a specific identifier to the GrovePi in order to know what we want to do.

  • a payload (aka body) - data that’s specific for the kind of function we call in the RaspberryPi. i.e : the analog pin we want to read from, the value we want to assign to a port, etc.

When data arrives at the GrovePi, requests are processed and the GrovePi does whatever we issued to do : i.e : read from a analog pin, write to a digital pin, etc.


Hope I’ve made you clear on how the system works.

Thank you!

4 Likes

Thank you a lot it was well-explained.

1 Like

This topic was automatically closed after 6 hours. New replies are no longer allowed.