Grove Base Hat for Raspberry Pi Zero
Today, the grove series of sensors, actuators, and displays have grown into a large family. More and more grove modules will join the whole
Grove ecosystem in the future. We see the Grove helps makers, engineers, teachers, students and even artists to build, to make, to
create...We always feel it is our responsibility to make the Grove module compatible with more platforms. Now we bring you the Grove Base
Hat for Raspberry Pi and Grove Base Hat for Raspberry Pi Zero, in another word, we bring the Raspberry Pi the whole Grove System.
The Grove Base Hat for Raspberry Pi provide Digital/Analog/I2C/PWM/UART port to meet all your needs. With the help of build-in MCU, a
12-bit 6 channel ADC is also available for Raspberry Pi.
Frankly speaking, it's about 60 Grove modules support the Grove Base Hat for Raspberry Pi now. However, we will continue to add new
compatible modules, the more you use, the more grove added.
Features
Support Raspberry 2/ 3 B/B+ Zero
build-in MCU
12-bit ADC
Multi-type Grove port
Specification
Item
Value
Operating Voltage
3.3V
MCU
STM32
ADC
12-bit 6 channel
Grove Port
2 Digital
3 Analog
1 I2C
1 PWM
1UART
Raspberry pi communication bus
I2C
I2C Address
0x04
Attention
The operating voltage is 3.3V, please do not input more than 3.3V, otherwise it may damage the Raspberry Pi. Moreover, this hat can not
work with 5V grove module via grove port, please use 3.3V compatible Grove module.
Hardware Overview
Pin Out
Overview
GPIO
The same pin out as the raspberry pi.
Digital
There are 2 digital Grove sockets in this board, normally the yellow wire(which connect to the top pin of the 4 pins Grove socket as) of Grove
cable is the signal wire, so we name the digital Grove port D5/D16.
Analog
As we know, there is no ADC in the Raspberry Pi, so it can not work with analog sensor directly. Now with the help of the build-in MCU
STM32, the Grove base hat can work as an external 12-bit ADC, which means you can use analog sensor with your Raspberry Pi. Even
more pleasing is that not one but four analog Grove sockets are available.
The analog sensor inputs the analog voltage into the 12-bit ADC. After the ADC convert the analog data to digital data, it input the digital data
to the Raspberry Pi through the I2C interface.
PWM(pulse-width modulation)
The Grove PWM Port connect to GPIO/BCM pin12(PWM0) and GPIO/BCM pin13(PWM1), which is the hardware PWM pin of Raspberry Pi,
in addition, you can use all the GPIO pin as the soft PWM pin.
Note
0- All the silkscreen layer pin number besides the Grove port is the BCM pin number. The difference between BCM pins and the physical
pins please refer to here
1- Compared with hardware PWM, the software PWM isn't so accurate and will have trouble at high frequencies.
2- The GPIO/BCM pin18 is also marked as PWM0, actually the GPIO/BCM 12 and the GPIO/BCM 18 share the same PWM channel, so they
can't set to different rate.
3- The audio jack output also uses PWM 0 and PWM 1, so you can't have audio output on that socket and use the PWMs at the same time.
I2C
The Grove I2C port connect to the I2C pin of the raspberry directly. Most of seeed's new grove modules have I2C interface, you may find this
port is extremely useful.
UART
The Grove UART port connect to the GPIO14(UART0 TX) and GPIO15(UART0 RX). UART is commonly used on the Pi as a convenient way
to control it over the GPIO, or access the kernel boot messages from the serial console (enabled by default).It can also be used as a way to
interface an Arduino, bootloaded ATmega, ESP8266, etc with your Pi.
SWD
We use SWD port to burn the firmware to this hat. In addition, you can see 3 GPIO pins in this section, i.e., pin 9/pin 10/pin 11. Those three
pins do not used by any Grove port, you are free to use them without worrying about pin conflicts.
Getting Started
Hardware
Materials required
-- Raspberry Pi Zero x1
-- Grove Base Hat for Raspberry Pi Zero x1
-- Grove module
Step 1. Plug the Grove Base Hat for Raspberry Pi Zero into the Raspberry Pi Zero.
Step 2. Plug the Grove module into the corresponding Grove port.
Step 3. Power the Raspberry Pi Zero with micro-usb cable.
Warning
We recommend that you power up the Raspberry Pis after all the hardware connections are complete. Please do not hot plug the sensor
module, otherwise the Raspberry Pi may crash.
Software
In this section we will introduce how to install the seeed grove.py library and how to use I2C, PWM, Digital and analog port of the Grove
Base Hat for Raspberry Pi Zero.
Tip
If you do not know how to use a raspberry pi, please check here before start.
Archtecture
To operate grove sensors, the grove.py depends many hardware interface libraries such as mraa/smbus2/rpi.gpi/rpi_ws281x.
Online one-click installation
One-click installation, quick start, what ever you call, with the single command below, we can install/update all dependencies and latest
grove.py.
1 curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh |
sudo bash -s -
Success
if everything goes well, you will see the following notice.
1 Successfully installed grove.py-0.5
2 #######################################################
3 Lastest Grove.py from github install complete
!!!!!
4 #######################################################
Step by step installation
Besides the one-click installation, you can also install all the dependencies and latest grove.py step by step. Please refer to our github page
for more information.
Step by step installation
You can check the source file by cloning the grove.py library.
1 git clone https://github.com/Seeed-Studio/grove.py
Usage
Now you can use the Grove Base Hat for Raspberry Pi Zero with dozens Grove modules, tap the command grove_ and press the Tab key
to check the supported Grove list.
1 pi@raspberrypi:~$ grove_
2 grove_3_axis_compass_bmm150
3 grove_mini_pir_motion_sensor
4 grove_temperature_sensor
5 grove_4_digit_display
6 grove_moisture_sensor
7 grove_thumb_joystick
8 grove_air_quality_sensor_v1_3
9 grove_oled_display_128x64
grove_tilt_switch
grove_button
grove_piezo_vibration_sensor
grove_touch_sensor
grove_collision_sensor
grove_pwm_buzzer
grove_ultrasonic_ranger
grove_gesture_sensor
grove_recorder_v3_0
grove_water_sensor
grove_high_accuracy_temperature
grove_relay
pi@raspberrypi:~$ grove_
grove_i2c_color_sensor_v2
grove_rotary_angle_sensor
grove_i2c_motor_driver
grove_ryb_led_button
grove_lcd_1.2inches
grove_servo
grove_led
grove_slide_potentiometer
grove_light_sensor_v1_2
grove_sound_sensor
grove_loudness_sensor
grove_switch
grove_mech_keycap
grove_temperature_humidity_sensor
Then we will show you how to use them according to port type.
PWM Port
We will take the Grove - buzzer for example to introduce the PWM port.
Hardware connection diagram
Tap the following command sudo
grove_pwm_buzzer in the command line interface.
1 pi@raspberrypi:~$ sudo grove_pwm_buzzer
2 Insert Grove-Buzzer to Grove-Base-Hat slot PWM[12 13 VCC GND]
3
4 3800
5 3400
6 3000
7 2900
8 2550
9 2270
10 2000
11 exiting application
The buzzer will ring a few times and then stop, the program will automatically exit.
Digital Port
We will take the Grove - Ultrasonic Ranger for example to introduce the Digital port.
Hardware connection diagram
Tap the following command grove_ultrasonic_ranger
5 6 in the command line interface.
1 pi@raspberrypi:~$ grove_ultrasonic_ranger 5 6
2 Detecting distance...
3 6.979909436456088 cm
4 7.966469074117726 cm
5 12.451204760321255 cm
6 15.184797089675378 cm
7 17.429220265355603 cm
8 18.73230112010035 cm
9 20.717752390894397 cm
10 19.83807004731277 cm
11 17.3059003106479 cm
12
13 ^CTraceback (most recent call last):
14 File "/usr/local/bin/grove_ultrasonic_ranger", line 11, in
15
load_entry_point('grove.py==0.5', 'console_scripts',
16 'grove_ultrasonic_ranger')()
17 File "/usr/local/lib/python3.5/dist18 packages/grove/grove_ultrasonic_ranger.py", line 107, in main
time.sleep(1)
KeyboardInterrupt
When you change the distance between the Grove - Ultrasonic Ranger and the target object, the measurment value will change accordingly.
Press Ctrl+C to quit.
Attention
For most grove module, you need to add the pin number parameter, like grove_ultrasonic_ranger
5 6, 5 and 6 are the
GPIO/BCM pin. However, you may have noticed that in the first example grove_pwm_buzzer, we didn't add a parameter after the
command. This is because the PWM port and I2C port do not require pin number parameters. You can find the pin number silkscreen just
besides the Grove sokect.
Analog Port
We will take the Grove - Air quality sensor v1.3 for example to introduce the Analog port.
Hardware connection diagram
Tap the following command grove_air_quality_sensor_v1_3
0 1 in the command line interface.
1 pi@raspberrypi:~$ grove_air_quality_sensor_v1_3 0 1
2 Detecting ...
3 62, Air Quality OK.
4 63, Air Quality OK.
5 61, Air Quality OK.
6 61, Air Quality OK.
7 59, Air Quality OK.
8 62, Air Quality OK.
9 60, Air Quality OK.
10 60, Air Quality OK.
11 59, Air Quality OK.
12 60, Air Quality OK.
13 60, Air Quality OK.
14 60, Air Quality OK.
15
16 57, Air Quality OK.
17 ^CTraceback (most recent call last):
18 File "/usr/local/bin/grove_air_quality_sensor_v1_3", line 11, in
19
load_entry_point('grove.py==0.5', 'console_scripts',
20 'grove_air_quality_sensor_v1_3')()
21 File "/usr/local/lib/python3.5/dist22 packages/grove/grove_air_quality_sensor_v1_3.py", line 68, in main
time.sleep(.1)
KeyboardInterrupt
You can use this sensor to detect the air quality. Press Ctrl+C to quit.
Notice
You may have noticed that for the analog port, the silkscreen pin number is something like A1, A0, however in the command we use
parameter 0 and 1, just the same as digital port. So please make sure you plug the module into the correct port, otherwise there may be pin
conflicts.
I2C
We will take the Grove - OLED Display 128x64 for example to introduce the I2C port.
Hardware connection diagram
Tap the following command grove_oled_display_128x64 in the command line interface.
1 pi@raspberrypi:~$ grove_oled_display_128x64
2 pi@raspberrypi:~$
It seems nothing happened, however you can find the most famous sentence in the cyber world if you check your oled.😄
Note
If you use the I2C tool to scan the I2C address of the grove module, you may find two or more address. 0x04 is the adrress of the Grove
Base Hat for Raspberry Pi.
Tech Support
Please do not hesitate to submit the issue into our forum
http://wiki.seeedstudio.com/Grove_Base_Hat_for_Raspberry_Pi_Zero/ 12‐4‐18