Grove Starter IoT Kit Documentation
The Grove Starter IoT Kit is a comprehensive bundle of IoT components and sensors designed to help users get started with building innovative IoT projects. This kit includes a range of modules, including sensors, actuators, and communication modules, that can be easily connected and programmed using the Arduino or Raspberry Pi platforms.
Grove Base Shield v2.0
Grove Temperature and Humidity Sensor
Grove Light Sensor
Grove Sound Sensor
Grove Button
Grove LED
Grove Relay
Grove Ethernet Module
Grove WiFi Module
Jumper wires
### Example 1: Temperature and Humidity Monitoring using Arduino
This example demonstrates how to use the Grove Temperature and Humidity Sensor to monitor and display temperature and humidity values using the Arduino platform.
Grove Base Shield v2.0
Grove Temperature and Humidity Sensor
Arduino Board (e.g., Arduino Uno)
Code:
```c++
#include <DHT.h>
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
int temp = dht.readTemperature();
int humi = dht.readHumidity();
if (isnan(temp) || isnan(humi)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println(" C");
Serial.print("Humidity: ");
Serial.print(humi);
Serial.println(" %");
delay(2000);
}
```
Output:
The code will print the temperature and humidity values to the serial monitor every 2 seconds.
### Example 2: IoT-Based Home Automation using Raspberry Pi and WiFi Module
This example demonstrates how to use the Grove WiFi Module and the Grove Relay to control a lamp remotely using a Raspberry Pi.
Grove Base Shield v2.0
Grove WiFi Module
Grove Relay
Raspberry Pi
Lamp or any other appliance to be controlled
Code:
```python
import RPi.GPIO as GPIO
import time
import socket
# Set up GPIO pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT) # Relay pin
# Set up WiFi connection
SSID = 'your_wifi_ssid'
PASSWORD = 'your_wifi_password'
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('192.168.0.100', 8080)) # Replace with your Raspberry Pi's IP address
sock.listen(5)
while True:
conn, addr = sock.accept()
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break
if data.decode() == 'ON':
GPIO.output(17, GPIO.HIGH) # Turn on the lamp
elif data.decode() == 'OFF':
GPIO.output(17, GPIO.LOW) # Turn off the lamp
conn.close()
```
Note: Replace `your_wifi_ssid` and `your_wifi_password` with your WiFi network's SSID and password.
The code will establish a WiFi connection and start a server on the Raspberry Pi. When a client sends an `ON` or `OFF` command to the server, the lamp will be turned on or off accordingly.
These examples demonstrate the versatility of the Grove Starter IoT Kit and its potential to be used in a wide range of IoT applications.