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.
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.
I will try to connect with my Raspberry Pi 3B + immediately.
Nantecotter / (^ o ^)
If there is a case, it will not stick. .. ..
Let's remove the lid.
The other side is floating, so you may want to put your feet on it.
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 -
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.
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).
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.
This time, ON / OFF is sent to pin 5 (digital), so create an instance as follows.
led = GPIO(5, GPIO.OUT)
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)
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.
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.
If you use "grove.py", you can easily use the Grove sensor from Python.
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