Use the Grove sensor on the Raspberry Pi

Introduction

When I try to use Grove Sensor on Raspberry Pi, the first thing I do is "[ "GrovePi +" (https://wiki.seeedstudio.com/GrovePi_Plus/) "remembers, but now" Grove Base HAT for Raspberry Pi " There are, so I would like to try various things here.

appearance

The "Grove Base HAT for Raspberry Pi" interacts with the Grove sensor via the Raspberry Pi's GPIO.

There are tons of ports available, and it feels like you can't say it's not enough. image.png

I will try to connect with my Raspberry Pi 3B + immediately. DSC_0005.JPG

Nantecotter / (^ o ^)
If there is a case, it will not stick. .. .. Let's remove the lid. DSC_0006.JPG

The other side is floating, so you may want to put your feet on it. DSC_0007.JPG

Preparation

You will need the seeed grove.py library to use it, so install it first.

There seem to be several installation methods, but the simplest "Online one-click installation" is done.

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

image.png

There are programs (see below) that run quite a few types of sensors.

grove_12_key_cap_i2c_touch_mpr121
grove_16x2_lcd
grove_1wire_thermocouple_amplifier_max31850
grove_3_axis_accelerometer_adxl372
grove_3_axis_compass_bmm150
grove_3_axis_digital_accelerometer
grove_4_digit_display
grove_6_axis_accel_gyro_bmi088
grove_air_quality_sensor_v1_3
grove_button
grove_cap_touch_slider_cy8c
grove_collision_sensor
grove_current_sensor
grove_gesture_sensor
grove_gpio
grove_high_accuracy_temperature
grove_i2c_color_sensor_v2
grove_i2c_motor_driver
grove_i2c_thermocouple_amplifier_mcp9600
grove_imu_9dof_icm20600_ak09918
grove_lcd_1.2inches
grove_led
grove_light_sensor_v1_2
grove_loudness_sensor
grove_mech_keycap
grove_mini_pir_motion_sensor
grove_moisture_sensor
grove_multi_switch
grove_multi_switch_poll
grove_oled_display_128x64
grove_optical_rotary_encoder
grove_piezo_vibration_sensor
grove_pwm_buzzer
grove_recorder_v3_0
grove_relay
grove_rotary_angle_sensor
grove_round_force_sensor
grove_ryb_led_button
grove_servo
grove_slide_potentiometer
grove_sound_sensor
grove_step_counter_bma456
grove_switch
grove_temperature_humidity_bme680
grove_temperature_humidity_sht31
grove_temperature_sensor
grove_thumb_joystick
grove_tilt_switch
grove_time_of_flight_distance
grove_touch_sensor
grove_ultrasonic_ranger
grove_uv_sensor
grove_water_sensor
grove_ws2813_rgb_led_strip

I will try "grove_led" in this. The port that can be stabbed

==============
 pin | slot
==============
  5  | D5   
 12  | PWM  
 16  | D16  
 18  | D18  
 22  | D22  
 24  | D24  
 26  | D26  

So I will connect it to D5.

$ grove_led 5
Hat Name = 'Grove Base Hat RPi'

Then, the LED will blink at regular intervals.

DSC_0008.JPG

programming

It's boring just to run the prepared program, so let's create the program as you want. (Language uses Python)

For the time being, let's create a program that lights up the same LED.

Access via grove.py library (it looks like a file name, but it's a library name).

Preparation

To read and write to GPIO pins, use the "GPIO" class in the "grove.gpio" package.

import time
from grove.gpio import GPIO

The "time" package is used to specify the ON / OFF time interval.

access

This time, ON / OFF is sent to pin 5 (digital), so create an instance as follows.

led = GPIO(5, GPIO.OUT)

control

It repeats ON / OFF in an infinite loop. (1 second interval)

while True:
    led.write(1)
    time.sleep(1)
    led.write(0)
    time.sleep(1)

Run

Execute the created program. (Suppose you saved it with the file name "led.py")

$ python3 led.py

As before, the LED will blink at regular intervals.

bonus

The material for "grove.py" can be found at here. However, there is almost no content and it is not helpful. It is most helpful to read the sample source.

Summary

If you use "grove.py", you can easily use the Grove sensor from Python.

Reference URL

https://wiki.seeedstudio.com/Grove_Base_Hat_for_Raspberry_Pi/ https://qiita.com/matsujirushi/items/4d54e076902cbbdd2704 https://github.com/Seeed-Studio/grove.py

Recommended Posts

Use the Grove sensor on the Raspberry Pi
Use Grove-Temperature & Humidity Sensor (DHT11) on Raspberry Pi
Use NeoPixel on Raspberry Pi
Try using the temperature sensor (LM75B) on the Raspberry Pi.
Use PIR motion sensor with raspberry Pi
Try the Grove Pi + Starter Kit Sensor
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
pigpio on Raspberry pi
Cython on Raspberry Pi
Sound the buzzer using python on Raspberry Pi 3!
Use BME280 temperature / humidity / barometric pressure sensor from Python on Raspberry Pi 2
A memo to simply use the illuminance sensor TSL2561 with Raspberry Pi 2
Use python on Raspberry Pi 3 to light the LED with switch control!
Using the digital illuminance sensor TSL2561 with Raspberry Pi
How to use the Raspberry Pi relay module Python
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Introduced pyenv on Raspberry Pi
Using the 1-Wire Digital Temperature Sensor DS18B20 from Python on a Raspberry Pi
Use python on Raspberry Pi 3 and turn on the LED when it gets dark!
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
I tried using the DS18B20 temperature sensor with Raspberry Pi
Testing uart communication on Raspberry Pi
MQTT on Raspberry Pi and Mac
raspberry pi 4 centos7 install on docker
Install ghoto2 on Raspberry Pi (memo)
Try using ArUco on Raspberry Pi
OpenCV installation procedure on Raspberry Pi
Power on / off Raspberry pi on Arduino
Detect switch status on Raspberry Pi 3
Install OpenMedia Vault 5 on Raspberry Pi 4
Sakura Use Python on the Internet
L Chika on Raspberry Pi C #
Build wxPython on Ubuntu 20.04 on raspberry pi 4
Control the motor with a motor driver using python on Raspberry Pi 3!
Raspberry Pi --1 --First time (Connect a temperature sensor to display the temperature)
Periodically log the value of Omron environment sensor with Raspberry Pi
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
Use The Metabolic Disassembler on Google Colaboratory
USB boot on Raspberry Pi 4 Model B
"Honwaka Notification Lamp" on Raspberry Pi Part 1
Enable UART + serial communication on Raspberry Pi
Adafruit Python BluefruitLE works on Raspberry Pi.
Accelerate Deep Learning on Raspberry Pi 4 CPU
Set swap space on Ubuntu on Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Install 64-bit OS (bate) on Raspberry Pi
Improved motion sensor made with Raspberry Pi
Install docker-compose on 64-bit Raspberry Pi OS
Run servomotor on Raspberry Pi 3 using python
"Honwaka Notification Lamp" on Raspberry Pi Part 3
Working with sensors on Mathematica on Raspberry Pi
Build OpenCV-Python environment on Raspberry Pi B +
Detect temperature using python on Raspberry Pi 3!
Mount Windows shared folder on Raspberry Pi
Matrix multiplication on Raspberry Pi GPU (Part 2)
How to install NumPy on Raspberry Pi
I installed OpenCV-Python on my Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
Use Raspberry Pi to solve the problem of insufficient mobile Wi-Fi connection
The microphone was not recognized on Linux's Raspberry Pi OS (formerly Raspbian).