### Install Grove.py (System-wide) Source: https://github.com/seeed-studio/grove.py/blob/master/README.md Installs grove.py system-wide using a provided installation script. This method requires superuser privileges and is intended for broader system access. ```Bash curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s - ``` -------------------------------- ### Install Grove.py (User Local) Source: https://github.com/seeed-studio/grove.py/blob/master/README.md Installs grove.py into a virtual environment using a provided installation script, bypassing GUI installation. This is suitable for users who want to install the library locally. ```Bash curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | bash -s -- --user-local --bypass-gui-installation ``` -------------------------------- ### Install Grove.py from Source (Python 3) Source: https://github.com/seeed-studio/grove.py/blob/master/README.md Installs grove.py from its source code by cloning the repository, navigating into the directory, and then using pip3 to install the package. It also includes steps for setting up and using a Python 3 virtual environment. ```Bash git clone https://github.com/Seeed-Studio/grove.py cd grove.py # Python3 sudo pip3 install . # virutalenv for Python3 (If the installation fails when using pip3) sudo apt install python3-virtualenv virtualenv -p python3 env source env/bin/activate pip3 install . ``` -------------------------------- ### Setup Python Virtual Environment Source: https://github.com/seeed-studio/grove.py/blob/master/doc/INSTALL.md Installs the python3-virtualenv package and creates a virtual environment named 'env' using Python 3. It then activates the virtual environment. ```shell sudo apt install python3-virtualenv virtualenv -p python3 env source env/bin/activate ``` -------------------------------- ### Run SGP30 Example Script Source: https://github.com/seeed-studio/grove.py/blob/master/grove/modules/sgp30/README.md This command executes the example Python script for the Grove SGP30 sensor. Ensure the sensor is connected to an I2C port on the GrovePi Plus. ```bash sudo python3 sgp30_example.py ``` -------------------------------- ### Install Documentation Tool Packages Source: https://github.com/seeed-studio/grove.py/blob/master/sphinx/README.md Installs essential packages for documentation generation, including Sphinx, AutoAPI, and sphinx-rtd-theme, for both Python 2 and Python 3 environments. ```shell sudo apt-get install python-sphinx python3-sphinx graphviz sudo pip install autoapi sphinx-rtd-theme sudo pip3 install autoapi sphinx-rtd-theme ``` -------------------------------- ### Grove Electromagnet Control with Python Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Provides an example of controlling a Grove Electromagnet using the grove.py factory. It activates the electromagnet for 1 second and deactivates it for 3 seconds. Requires the Factory class to get the Electromagnet wrapper. ```Python import time from grove.factory import Factory magnet = Factory.getGpioWrapper("Electromagnet", 12) while True: magnet.on() time.sleep(1) magnet.off() time.sleep(3) ``` -------------------------------- ### Grove Button Input with Python Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Provides an example of reading the state of a Grove Button using the grove.py factory. It continuously checks if the button is pressed and prints the status. Requires the Factory class to get the Button wrapper. ```Python import time from grove.factory import Factory pin = 12 button = Factory.getButton("GPIO-HIGH", pin) while True: if button.is_pressed(): print('Button is pressed') else: print('Button is released') time.sleep(1) ``` -------------------------------- ### Run BME280 Example Script Source: https://github.com/seeed-studio/grove.py/blob/master/grove/modules/bme280/README.md This command executes the example Python script for the BME280 sensor. Ensure the sensor is connected to an I2C port on the GrovePi Plus before running. ```bash sudo python3 bme280_example.py ``` -------------------------------- ### Install Grove.py Dependencies Source: https://github.com/seeed-studio/grove.py/blob/master/README.md Installs necessary dependencies for grove.py on a Debian-based system by adding a repository, GPG key, and updating the package list before installing specific libraries. ```Shell echo "deb https://seeed-studio.github.io/pi_repo/ stretch main" | sudo tee /etc/apt/sources.list.d/seeed.list curl https://seeed-studio.github.io/pi_repo/public.key | sudo apt-key add - sudo apt update sudo apt install libbmi088 libbma456 ``` -------------------------------- ### Install grove.py Library from PyPI Source: https://github.com/seeed-studio/grove.py/blob/master/doc/INSTALL.md Installs the 'grove.py' library from the Python Package Index (PyPI). It provides installation commands for both system-wide Python 3 and within a virtual environment. ```shell sudo pip3 install grove.py ``` ```shell pip install grove.py ``` -------------------------------- ### Add Seeed Studio Repository Source: https://github.com/seeed-studio/grove.py/blob/master/doc/INSTALL.md Adds the Seeed Studio repository to the system's sources list for package management on Raspberry Pi. ```shell echo "deb https://seeed-studio.github.io/pi_repo/ stretch main" | sudo tee /etc/apt/sources.list.d/seeed.list ``` -------------------------------- ### Add Public GPG Key Source: https://github.com/seeed-studio/grove.py/blob/master/doc/INSTALL.md Adds the public GPG key for the Seeed Studio repository to verify package authenticity. It provides two methods for adding the key. ```shell curl https://seeed-studio.github.io/pi_repo/public.key | sudo apt-key add - ``` ```shell sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BB8F40F3 ``` -------------------------------- ### Read Digital Light Sensor Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This example shows how to read the ambient light level using the GroveDigitalLight sensor. It continuously prints the light intensity detected by channel 0. ```Python import time from grove.grove_digital_light_sensor import GroveDigitalLight sensor = GroveDigitalLight() while True: print('light: %d' %(sensor.read_light_chan0())) time.sleep(0.5) ``` -------------------------------- ### Install rpi_ws281x Library Source: https://github.com/seeed-studio/grove.py/blob/master/doc/INSTALL.md Installs the 'rpi_ws281x' library, which is used for controlling WS281x addressable LEDs. It provides installation commands for both system-wide Python 3 and within a virtual environment. ```shell sudo pip3 install rpi_ws281x ``` ```shell pip install rpi_ws281x ``` -------------------------------- ### Install raspberry-gpio-python Library Source: https://github.com/seeed-studio/grove.py/blob/master/doc/INSTALL.md Updates the package list and installs the 'python3-rpi.gpio' package, which is required for GPIO control on Raspberry Pi. ```shell sudo apt update sudo apt install python3-rpi.gpio ``` -------------------------------- ### Grove Buzzer Control with Python Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Shows how to activate a Grove Buzzer using the grove.py factory. It turns the buzzer on for 1 second and off for 3 seconds repeatedly. Requires the Factory class to get the Buzzer wrapper. ```Python import time from grove.factory import Factory buzzer = Factory.getGpioWrapper("Buzzer", 12) while True: buzzer.on() time.sleep(1) buzzer.off() time.sleep(3) ``` -------------------------------- ### Grove PIR Motion Sensor with Python Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Demonstrates how to detect motion using a Grove PIR Motion Sensor with the grove.py factory. It checks for motion and prints messages accordingly. Requires the Factory class to get the PIRMotion wrapper. ```Python import time from grove.factory import Factory ### connect to pin 5(slot D5) pir = Factory.getGpioWrapper("PIRMotion", 5) while True: if pir.has_motion(): print("Hi, people is moving") else: print("Watching") time.sleep(1) ``` -------------------------------- ### Grove Relay Control with Python Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Shows how to control a Grove Relay module using the grove.py factory. It toggles the relay on for 2 seconds and off for 5 seconds. Requires the Factory class to get the Relay wrapper. ```Python import time from grove.factory import Factory relay = Factory.getGpioWrapper("Relay",16) while True: relay.on() time.sleep(2) relay.off() time.sleep(5) ``` -------------------------------- ### Enable I2C Interface Source: https://github.com/seeed-studio/grove.py/blob/master/doc/INSTALL.md Enables the I2C interface on the Raspberry Pi using the raspi-config tool. This is a crucial step for many Grove modules. ```shell sudo raspi-config ``` -------------------------------- ### Measure Distance with Ultrasonic Ranger Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This example shows how to use the GroveUltrasonicRanger to measure distance. It initializes the sensor with a specified pin and continuously prints the detected distance in centimeters. ```Python from grove.grove_ultrasonic_ranger import GroveUltrasonicRanger import time sonar = GroveUltrasonicRanger(12) # pin12, slot D12 print('Detecting distance...') while True: print('{} cm'.format(sonar.get_distance())) time.sleep(1) ``` -------------------------------- ### Read Temperature and Humidity with DHT Sensor Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This example shows how to read temperature and humidity data from a DHT sensor (DHT11) using the DHT class in grove.py. It specifies the sensor type and the connected GPIO pin. ```Python import time from grove.grove_temperature_humidity_sensor import DHT # DHT11 type # insert to GPIO pin 5, slot D5 dht11 = DHT("11", 5) while True: humi, temp = dht11.read() print('DHT{0}, humidity {1:.1f}%, temperature {2:.1f}*'.format(dht11.dht_type, humi, temp)) time.sleep(1) ``` -------------------------------- ### Control Stepper Motors with Factory Class Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This example shows how to control stepper motors like the 24BYJ48 or 28BYJ48 using the Factory class in grove.py. It covers setting rotation angle, speed, enabling the motor, and monitoring the remaining rotation. ```Python from grove.factory import Factory import time motor = Factory.getStepperMotor("24BYJ48") # If it's 28BYJ48 # motor = Factory.getStepperMotor("28BYJ48") ANGLE = 360 # rotate 360 degrees = 1 cycle motor.rotate(ANGLE) # set speed to max rpm, for Motor 24BYJ48, it's 30 RPM. # direction is clockwise, anti-clockwise use negative value (-30) SPEED = motor.speed_max # SPEED = 30 motor.speed(SPEED) motor.enable(True) # enable the motor, begin to run seconds = ANGLE / 360.0 / SPEED * 60 print("Motor {} rotate {} degrees, time = {:.2f}".format(motor.name, ANGLE, time.time())) print(" with speed {} RPM".format(SPEED)) print(" will be stop after {:4.2f} seconds".format(seconds)) while True: left = motor.rotate() if left < 1e-5: break print("Angle left {:6.2f} degrees, time = {:.2f}".format(left, time.time())) time.sleep(1.0) print("Motor run ended, time = {:.2f} !".format(time.time())) ``` -------------------------------- ### Basic GPIO Input/Output Demo Source: https://github.com/seeed-studio/grove.py/blob/master/README.md Demonstrates basic GPIO control using the grove.py library. It initializes an LED as an output and a button as an input, then continuously reads the button state to control the LED. ```Python import time from grove.gpio import GPIO led = GPIO(12, GPIO.OUT) button = GPIO(22, GPIO.IN) while True: if button.read(): led.write(1) else: led.write(0) time.sleep(0.1) ``` -------------------------------- ### Grove Temperature, Humidity, Pressure, Gas Sensor (BME680) Initialization Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Initialize the Grove Temperature, Humidity, Pressure, and Gas Sensor (BME680) using I2C. ```Python from grove.grove_temperature_humidity_pressure_gas_sensor_bme680 import GroveTemperatureHumidityPressureGasSensorBME680 # bme680 = GroveTemperatureHumidityPressureGasSensorBME680(bus=1) ``` -------------------------------- ### Grove VOC and eCO2 Gas Sensor (SGP30) Initialization Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Initialize the Grove VOC and eCO2 Gas Sensor (SGP30) using I2C communication. ```Python from grove.grove_voc_eco2_gas_sensor_sgp30 import GroveVOCeCO2GasSensorSGP30 # sgp30 = GroveVOCeCO2GasSensorSGP30(bus=1) ``` -------------------------------- ### Generate Documentation HTMLs Source: https://github.com/seeed-studio/grove.py/blob/master/sphinx/README.md Executes the make command to build the HTML documentation for the Grove.py project. The generated files will be located in the ~/grove.py/docs/ directory. ```shell cd ~/grove.py make -C sphinx html ``` -------------------------------- ### Clone Grove.py Repository Source: https://github.com/seeed-studio/grove.py/blob/master/sphinx/README.md Clones the Grove.py Python project repository from GitHub to the local machine. ```shell cd git clone https://github.com/Seeed-Studio/grove.py.git ``` -------------------------------- ### Grove UV Sensor (VEML6070) Initialization Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Initialize the Grove UV Sensor (VEML6070) using I2C communication. ```Python from grove.grove_uv_sensor_veml6070 import GroveUVSensorVEML6070 # uv_sensor = GroveUVSensorVEML6070(bus=1) ``` -------------------------------- ### Grove Temperature & Humidity Sensor (SHT31) Initialization Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Initialize the Grove Temperature & Humidity Sensor (SHT31) using I2C communication. ```Python from grove.grove_temperature_humidity_sensor_sht31 import GroveTemperatureHumiditySensorSHT31 # sht31 = GroveTemperatureHumiditySensorSHT31(bus=1) ``` -------------------------------- ### Grove Air Quality Sensor v1.3 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command interfaces with the Seeed Studio Grove Air Quality Sensor v1.3. It requires an analog pin to be specified as an argument. ```Python grove_air_quality_sensor_v1_3 ``` -------------------------------- ### Grove Step Counter (BMA456) Initialization Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Initialize the Grove Step Counter (BMA456) using I2C communication. ```Python from grove.grove_step_counter_bma456 import GroveStepCounterBMA456 # step_counter = GroveStepCounterBMA456(bus=1) ``` -------------------------------- ### Grove LED Control with Python Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Demonstrates how to control a Grove LED module using the grove.py library. It blinks the LED on and off at a 1-second interval. Requires the GroveLed class. ```Python import time from grove.grove_led import GroveLed led = GroveLed(12) while True: led.on() time.sleep(1) led.off() time.sleep(1) ``` -------------------------------- ### Grove Button Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is for the Seeed Studio Grove Button. It requires a digital pin to be specified as an argument. ```Python grove_button ``` -------------------------------- ### Grove 3-Axis Digital Compass V2 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is for the Seeed Studio Grove 3-Axis Digital Compass V2. It utilizes an I2C connection for communication. ```Python grove_3_axis_compass_bmm150 ``` -------------------------------- ### Set PYTHONPATH for Working Copy Source: https://github.com/seeed-studio/grove.py/blob/master/sphinx/README.md Exports the current working directory of the Grove.py project to the PYTHONPATH environment variable, ensuring that the latest documentation from the working copy is generated. ```shell cd ~/grove.py; export PYTHONPATH=`pwd` ``` -------------------------------- ### Grove Time of Flight Distance Sensor (VL53L0X) Initialization Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Initialize the Grove Time of Flight Distance Sensor (VL53L0X) using I2C communication. ```Python from grove.grove_time_of_flight_distance_sensor_vl53l0x import GroveTimeOfFlightDistanceSensorVL53L0X # tof_sensor = GroveTimeOfFlightDistanceSensorVL53L0X(bus=1) ``` -------------------------------- ### Grove 16x2 LCD Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is used to control various Seeed Studio Grove 16x2 LCD displays. It requires an I2C connection. ```Python grove_16x2_lcd ``` -------------------------------- ### Grove 1-Wire Thermocouple Amplifier MAX31850K Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is used to interface with the Seeed Studio Grove 1-Wire Thermocouple Amplifier MAX31850K. It requires a 1-Wire connection. ```Python grove_1wire_thermocouple_amplifier_max31850 ``` -------------------------------- ### Import SGP30 Class in Python Source: https://github.com/seeed-studio/grove.py/blob/master/grove/modules/sgp30/README.md Demonstrates how to import the SGP30 class from the grove.modules.sgp30 library to interact with the Grove SGP30 sensor. ```python from grove.modules.sgp30 import SGP30 ``` -------------------------------- ### Grove I2C Color Sensor V2 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command interfaces with the Seeed Studio Grove I2C Color Sensor V2. It requires an I2C connection. ```Python grove_i2c_color_sensor_v2 ``` -------------------------------- ### Grove IMU 9DOF ICM20600 AK09918 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is for the Seeed Studio Grove IMU 9DOF (ICM20600+AK09918). It requires an I2C connection. ```Python grove_imu_9dof_icm20600_ak09918 ``` -------------------------------- ### Grove Gesture Sensor v1.0 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command interfaces with the Seeed Studio Grove Gesture Sensor v1.0. It operates via an I2C interface. ```Python grove_gesture_sensor ``` -------------------------------- ### Read Sunlight Sensor Values Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This snippet demonstrates how to read ambient light levels using the GroveSi115xSensor. It continuously prints the visible and infrared light readings. ```Python from grove.grove_sunlight_sensor import GroveSi115xSensor import time SI1151 = GroveSi115xSensor() while True: print('Visible %03d IR %03d' % (SI1151.ReadVisible , SI1151.ReadIR),end=" ") print('\r', end='') time.sleep(0.5) ``` -------------------------------- ### Grove Capacitive Touch Slide Sensor CY8C4014LQI Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command interfaces with the Seeed Studio Grove Capacitive Touch Slide Sensor (CY8C4014LQI). It uses an I2C connection. ```Python grove_cap_touch_slider_cy8c ``` -------------------------------- ### Grove 3-Axis Digital Accelerometer Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command interfaces with the Seeed Studio Grove 3-Axis Digital Accelerometer. It uses an I2C connection. ```Python grove_3_axis_digital_accelerometer ``` -------------------------------- ### Display Text on LCD 16x2 or OLED 1.12" Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This snippet demonstrates how to display text on either an LCD 16x2 display or an OLED 1.12" display using the Factory class in grove.py. It covers setting the cursor, writing text, and clearing the display. ```Python import time from grove.factory import Factory # LCD 16x2 Characters dobj = Factory.getDisplay("JHD1802") # If it's OLED Display 1.12" # dobj = Factory.getDisplay("SH1107G") rows, cols = dobj.size() print("LCD model: {}".format(dobj.name)) print("LCD type : {} x {}".format(cols, rows)) dobj.setCursor(0, 0) dobj.write("hello world!") dobj.setCursor(0, cols - 1) dobj.write('X') dobj.setCursor(rows - 1, 0) for i in range(cols): dobj.write(chr(ord('A') + i)) time.sleep(3) dobj.clear() ``` -------------------------------- ### Grove Recorder v3.0 Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Record and playback audio using the Grove Recorder v3.0. This module connects to a digital pin and allows specifying the recording duration in seconds. ```Python from grove.grove_recorder_v3_0 import GroveRecorderV3_0 # Example usage (assuming connection to digital pin 7, record for 5 seconds) # recorder = GroveRecorderV3_0(7) # recorder.record(5) # recorder.playback() ``` -------------------------------- ### Grove 4 Digit Display Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is used to control the Seeed Studio Grove 4 Digit Display. It requires a digital pin to be specified as an argument. ```Python grove_4_digit_display ``` -------------------------------- ### Grove Collision Sensor Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is used to control the Seeed Studio Grove Collision Sensor. It requires a digital pin to be specified as an argument. ```Python grove_collision_sensor ``` -------------------------------- ### Grove 12 Key Capacitive I2C Touch Sensor V2 MPR121 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command interfaces with the Seeed Studio Grove 12 Key Capacitive I2C Touch Sensor V2 (MPR121). It uses an I2C connection. ```Python grove_12_key_cap_i2c_touch_mpr121 ``` -------------------------------- ### Generate PWM Sound with Buzzer Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This code snippet demonstrates how to use PWM (Pulse Width Modulation) to generate sound with a buzzer connected to a Grove Base Hat. It sets the frequency and duty cycle to produce a 1000 Hz tone. ```Python import time import RPi.GPIO as GPIO # Grove Base Hat for Raspberry Pi # PWM JST SLOT - PWM[12 13 VCC GND] pin = 12 # create PWM instance pwm = GPIO.PWM(pin, 10) pwm.start(0) # 1000 Hz sound pwm.ChangeFrequency(1000) pwm.ChangeDutyCycle(100) ``` -------------------------------- ### Grove I2C Thermocouple Amplifier MCP9600 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command interfaces with the Seeed Studio Grove I2C Thermocouple Amplifier (MCP9600). It uses an I2C connection. ```Python grove_i2c_thermocouple_amplifier_mcp9600 ``` -------------------------------- ### Grove Light Sensor V1.2 Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Read ambient light levels using the Grove Light Sensor V1.2. This sensor is connected to an analog pin and provides analog readings proportional to the light intensity. ```Python from grove.grove_light_sensor_v1_2 import GroveLightSensorV1_2 # Example usage (assuming connection to analog pin 2) # light_sensor = GroveLightSensorV1_2(2) # print(light_sensor.light()) ``` -------------------------------- ### Grove 4 Digit Display with Python Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Demonstrates how to display time on a Grove 4 Digit Display using the grove.py library. It shows the current hour and minute, and toggles the colon separator. Requires the Grove4DigitDisplay class. ```Python import time from grove.grove_4_digit_display import Grove4DigitDisplay display = Grove4DigitDisplay(12, 13)) count = 0 while True: t = time.strftime("%H%M", time.localtime(time.time())) display.show(t) display.set_colon(count & 1) count += 1 time.sleep(1) ``` -------------------------------- ### Configure Raspberry Pi Serial Ports for GrovePi Source: https://github.com/seeed-studio/grove.py/blob/master/grove/modules/gps/README.md This snippet shows the necessary modifications to `/boot/config.txt` to enable the UART and disable Bluetooth, ensuring the hardware serial port is available for the GrovePi. It also includes the required changes to `/boot/cmdline.txt` to remove console statements from the serial port. ```bash dtoverlay=pi3-miniuart-bt dtoverlay=pi3-disable-bt enable_uart=1 ``` ```bash dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes root wait ``` ```bash dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes root wait ``` -------------------------------- ### Grove I2C Color Sensor V2 Raw Data with Python Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Shows how to read raw data from the Grove I2C Color Sensor V2 using the grove.py library. It prints the values from red-filtered, green-filtered, blue-filtered, and unfiltered photodiodes. Requires the GroveI2cColorSensorV2 class. ```Python import time from grove.grove_i2c_color_sensor_v2 import GroveI2cColorSensorV2 sensor = GroveI2cColorSensorV2() print('Raw data of red-filtered, green-filtered, blue-filtered and unfiltered photodiodes') while True: # r, g, b = sensor.rgb r, g, b, clear = sensor.raw print((r, g, b, clear)) time.sleep(1.0) ``` -------------------------------- ### Grove PWM Buzzer Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Generate sound with the Grove PWM Buzzer. This buzzer is connected via PWM and can produce tones of varying frequencies and durations. ```Python from grove.grove_pwm_buzzer import GrovePWMBuzzer # Example usage (assuming connection to PWM pin 12) # buzzer = GrovePWMBuzzer(12) # buzzer.play_tone(440, 1) # Play A4 for 1 second ``` -------------------------------- ### Grove 6-Axis Accelerometer Gyroscope BMI088 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is for the Seeed Studio Grove 6-Axis Accelerometer & Gyroscope (BMI088). It operates via an I2C interface. ```Python grove_6_axis_accel_gyro_bmi088 ``` -------------------------------- ### Grove OLED Display 1.12" Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Control for the Grove OLED Display 1.12" and its V2 variant. These displays are connected via I2C and are suitable for displaying text and simple graphics. ```Python from grove.grove_lcd_1_12inches import GroveLCD112 # Example usage (assuming I2C connection) # lcd = GroveLCD112() # lcd.write("Hello, Grove!") ``` -------------------------------- ### Grove I2C High Accuracy Temperature Sensor MCP9808 Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is for the Seeed Studio Grove I2C High Accuracy Temperature Sensor (MCP9808). It uses an I2C connection. ```Python grove_high_accuracy_temperature ``` -------------------------------- ### Grove I2C Motor Driver Command Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This command is used to control the Seeed Studio Grove I2C Motor Driver. It operates via an I2C interface. ```Python grove_i2c_motor_driver ``` -------------------------------- ### Grove Mech Keycap Control Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Interface for the Grove Mech Keycap, which is controlled via PWM. This allows for adjustable output, potentially for lighting or other effects. ```Python from grove.grove_mech_keycap import GroveMechKeycap # Example usage (assuming connection to PWM pin 6) # keycap = GroveMechKeycap(6) # keycap.set_duty_cycle(0.5) # Set duty cycle to 50% ``` -------------------------------- ### Grove Slide Potentiometer Reading Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Read values from a Grove Slide Potentiometer connected to an analog pin. ```Python from grove.grove_slide_potentiometer import GroveSlidePotentiometer # potentiometer = GroveSlidePotentiometer(pin=0) ``` -------------------------------- ### Grove Tilt Switch Detection Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Detect the state of a Grove Tilt Switch connected to a digital pin. ```Python from grove.grove_tilt_switch import GroveTiltSwitch # tilt_switch = GroveTiltSwitch(pin=12) ``` -------------------------------- ### Grove Sound Sensor Reading Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Read sound levels from a Grove Sound Sensor connected to an analog pin. ```Python from grove.grove_sound_sensor import GroveSoundSensor # sound_sensor = GroveSoundSensor(pin=0) ``` -------------------------------- ### Grove Thumb Joystick Reading Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Read analog values from a Grove Thumb Joystick connected to an analog pin. ```Python from grove.grove_thumb_joystick import GroveThumbJoystick # joystick = GroveThumbJoystick(pin=0) ``` -------------------------------- ### Grove PIR Motion Sensor Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Detect motion using the Grove mini PIR motion sensor or the standard PIR Motion Sensor. Both are connected to digital pins and provide a digital output indicating motion detection. ```Python from grove.grove_mini_pir_motion_sensor import GroveMiniPirMotionSensor # Example usage (assuming connection to digital pin 2) # pir_sensor = GroveMiniPirMotionSensor(2) # print(pir_sensor.detect()) # Returns True if motion is detected ``` -------------------------------- ### Grove Multi-Switch Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Interface for the Grove 5-Way Switch and 6-Position DIP Switch. These switches are connected via I2C and allow for multiple input states. ```Python from grove.grove_multi_switch import GroveMultiSwitch from grove.grove_multi_switch_poll import GroveMultiSwitchPoll # Example usage (assuming I2C connection) # multi_switch = GroveMultiSwitch() # print(multi_switch.get_value()) # multi_switch_poll = GroveMultiSwitchPoll() # print(multi_switch_poll.poll()) ``` -------------------------------- ### Grove Servo Control Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Control a Grove Servo motor by specifying a digital pin. ```Python from grove.grove_servo import GroveServo # servo = GroveServo(pin=12) ``` -------------------------------- ### Grove Water Sensor Detection Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Detect the presence of water using a Grove Water Sensor connected to a digital pin. ```Python from grove.grove_water_sensor import GroveWaterSensor # water_sensor = GroveWaterSensor(pin=12) ``` -------------------------------- ### Grove Piezo Vibration Sensor Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Detect vibrations using the Grove Piezo Vibration Sensor. This sensor connects to a digital pin and provides a digital output when vibration is detected. ```Python from grove.grove_piezo_vibration_sensor import GrovePiezoVibrationSensor # Example usage (assuming connection to digital pin 4) # vibration_sensor = GrovePiezoVibrationSensor(4) # print(vibration_sensor.detect()) ``` -------------------------------- ### Grove Temperature & Humidity Sensor (DHT11/AM2302) Reading Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Read temperature and humidity from DHT11 or DHT22/AM2302 sensors connected to a digital pin. Specify the DHT type (11 or 22). ```Python from grove.grove_temperature_humidity_sensor import GroveTemperatureHumiditySensor # For DHT11 # temp_hum_sensor_dht11 = GroveTemperatureHumiditySensor(pin=12, dht_type=11) # For DHT22/AM2302 # temp_hum_sensor_dht22 = GroveTemperatureHumiditySensor(pin=12, dht_type=22) ``` -------------------------------- ### Grove LED Button Control Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Control Grove LED Buttons (Red, Yellow, Blue) by specifying a digital pin. ```Python from grove.rgb_led_button import GroveRgbLedButton # Example for Red LED Button # button = GroveRgbLedButton(pin=12) # Example for Yellow LED Button # button = GroveRgbLedButton(pin=12) # Example for Blue LED Button # button = GroveRgbLedButton(pin=12) ``` -------------------------------- ### Grove OLED Display 128x64 Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Control for the Grove OLED Display with a 128x64 resolution. This display is connected via I2C and is suitable for detailed graphical output. ```Python from grove.grove_oled_display_128x64 import GroveOLEDDisplay128x64 # Example usage (assuming I2C connection) # oled = GroveOLEDDisplay128x64() # oled.write_text("128x64 OLED") ``` -------------------------------- ### Grove Touch Sensor Detection Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Detect touch events from a Grove Touch Sensor connected to a digital pin. ```Python from grove.grove_touch_sensor import GroveTouchSensor # touch_sensor = GroveTouchSensor(pin=12) ``` -------------------------------- ### Grove Switch Control Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Detect the state of a Grove Switch connected to a digital pin. ```Python from grove.grove_switch import GroveSwitch # switch = GroveSwitch(pin=12) ``` -------------------------------- ### Control DC Motors with I2C Motor Driver Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md This snippet demonstrates how to control the speed and direction of DC motors using the MotorDriver class from the grove.py library. It allows setting speed from 0 to 100 and direction (clockwise/anti-clockwise) for one or two channels. ```Python import time from grove.grove_i2c_motor_driver import MotorDriver motor = MotorDriver() while True: # speed range: 0(lowest) - 100(fastest) motor.set_speed(100) # channel 1 only # to set channel 1&2: motor.set_speed(100, 100) # direction: True(clockwise), False(anti-clockwise) motor.set_dir(True) # channel 1 only, # to set channel 1&2: motor.set_dir(True, True) time.sleep(2) motor.set_speed(70) motor.set_dir(False) time.sleep(2) ``` -------------------------------- ### Grove Temperature Sensor Reading Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Read temperature values from a Grove Temperature Sensor connected to an analog pin. ```Python from grove.grove_temperature_sensor import GroveTemperatureSensor # temp_sensor = GroveTemperatureSensor(pin=0) ``` -------------------------------- ### Grove LED Control Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Control for various Grove LEDs (Red, Green, Purple, White). These LEDs are connected to a digital pin and can be turned on or off. ```Python from grove.grove_led import GroveLed # Example usage (assuming connection to digital pin 5) # led = GroveLed(5) # led.on() # led.off() ``` -------------------------------- ### Grove IMU 9DOF ICM20600 AK09918 Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Interface for the Grove IMU 9DOF sensor, utilizing the ICM20600 and AK09918 chips. This sensor is connected via I2C and is essential for motion tracking and orientation sensing. ```Python from grove.grove_imu_9dof_icm20600_ak09918 import GroveIMU9DOF # Example usage (assuming I2C connection) # imu = GroveIMU9DOF() # print(imu.get_acceleration()) # print(imu.get_magnetic()) # print(imu.get_gyroscope()) ``` -------------------------------- ### Grove Ultrasonic Ranger Measurement Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Measure distance using a Grove Ultrasonic Ranger connected to a digital pin. ```Python from grove.grove_ultrasonic_ranger import GroveUltrasonicRanger # ranger = GroveUltrasonicRanger(pin=12) ``` -------------------------------- ### Grove Optical Rotary Encoder Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Interface for the Grove Optical Rotary Encoder (TCUT1600X01). This encoder is connected to a digital pin and is used for detecting rotational movement. ```Python from grove.grove_optical_rotary_encoder import GroveOpticalRotaryEncoder # Example usage (assuming connection to digital pin 3) # encoder = GroveOpticalRotaryEncoder(3) # print(encoder.get_rotation()) ``` -------------------------------- ### Grove Loudness Sensor Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Measure sound levels with the Grove Loudness Sensor. This sensor connects to an analog pin and outputs an analog voltage corresponding to the sound intensity. ```Python from grove.grove_loudness_sensor import GroveLoudnessSensor # Example usage (assuming connection to analog pin 1) # loudness_sensor = GroveLoudnessSensor(1) # print(loudness_sensor.loudness()) ``` -------------------------------- ### Grove Moisture Sensor Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Measure soil moisture levels with the Grove Moisture Sensor. This sensor connects to an analog pin and outputs an analog value representing the moisture content. ```Python from grove.grove_moisture_sensor import GroveMoistureSensor # Example usage (assuming connection to analog pin 0) # moisture_sensor = GroveMoistureSensor(0) # print(moisture_sensor.moisture()) ``` -------------------------------- ### Grove Round Force Sensor FSR402 Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Detect pressure or force with the Grove Round Force Sensor FSR402. This sensor connects to an analog pin and outputs an analog value that changes with applied force. ```Python from grove.grove_round_force_sensor import GroveRoundForceSensor # Example usage (assuming connection to analog pin 4) # force_sensor = GroveRoundForceSensor(4) # print(force_sensor.force()) ``` -------------------------------- ### Grove Rotary Angle Sensor Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Measure the angle of rotation using the Grove Rotary Angle Sensor(P). This sensor connects to an analog pin and provides an analog output proportional to the angle. ```Python from grove.grove_rotary_angle_sensor import GroveRotaryAngleSensor # Example usage (assuming connection to analog pin 3) # rotary_sensor = GroveRotaryAngleSensor(3) # print(rotary_sensor.value()) ``` -------------------------------- ### Grove Relay Control Source: https://github.com/seeed-studio/grove.py/blob/master/doc/README.md Control a Grove Relay module, which acts as an electronic switch. This module connects to a digital pin and can be used to switch higher voltage or current devices on and off. ```Python from grove.grove_relay import GroveRelay # Example usage (assuming connection to digital pin 8) # relay = GroveRelay(8) # relay.on() # relay.off() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.