Smart Science IoT Kit compatible with Micro:Bit by Elecfreaks
The Smart Science IoT Kit is a comprehensive kit designed specifically for the Micro:Bit, allowing users to explore the world of Internet of Things (IoT) and develop innovative projects. The kit includes a range of sensors and modules that enable users to collect and analyze data, interact with their environment, and create interactive projects.
The Smart Science IoT Kit includes the following components:
Temperature and Humidity Sensor
Light Sensor
Sound Sensor
Soil Moisture Sensor
Water Detector
relay Module
Buzzer Module
4-Digit Display Module
Micro:Bit Adapter Board
### Example 1: Temperature and Humidity Monitoring
In this example, we will use the Temperature and Humidity Sensor to monitor the ambient temperature and humidity levels.
Micro:Bit Code
```
from microbit import
import ustruct
# Initialize the temperature and humidity sensor
temp_humidity_sensor = pin2
while True:
# Read the temperature and humidity data
temp_data = ustruct.pack('f', temp_humidity_sensor.read_analog())
humidity_data = ustruct.pack('f', temp_humidity_sensor.read_analog())
# Convert the data to Celsius and percentage
temp_celsius = (temp_data[0] 5 / 1023) - 50
humidity_percentage = humidity_data[0] / 1023 100
# Display the temperature and humidity on the Micro:Bit screen
display.scroll('Temp: {:.2f}C Humidity: {:.2f}%'.format(temp_celsius, humidity_percentage))
# Wait for 1 second before taking the next reading
sleep(1000)
```
Output
The Micro:Bit screen will display the temperature and humidity levels in real-time, updating every second.
### Example 2: Soil Moisture Monitoring with Automatic Watering System
In this example, we will use the Soil Moisture Sensor to monitor the soil moisture levels and trigger an automatic watering system using the relay module.
Micro:Bit Code
```
from microbit import
import ustruct
# Initialize the soil moisture sensor and relay module
soil_moisture_sensor = pin1
relay_module = pin0
# Set the threshold for soil moisture levels
threshold = 50
while True:
# Read the soil moisture data
soil_moisture_data = soil_moisture_sensor.read_analog()
# Convert the data to a percentage
soil_moisture_percentage = soil_moisture_data / 1023 100
# Check if the soil moisture level is below the threshold
if soil_moisture_percentage < threshold:
# Activate the relay module to turn on the water pump
relay_module.write_digital(1)
display.show('Watering...')
sleep(5000) # Wait for 5 seconds before turning off the pump
relay_module.write_digital(0)
display.clear()
else:
display.show('Soil Moisture: {:.2f}%'.format(soil_moisture_percentage))
# Wait for 1 second before taking the next reading
sleep(1000)
```
Output
The Micro:Bit screen will display the soil moisture levels in real-time. When the soil moisture level falls below the threshold, the relay module will activate, turning on the water pump for 5 seconds.
### Example 3: Interactive Light and Sound Show
In this example, we will use the Light Sensor and Sound Sensor to create an interactive light and sound show.
Micro:Bit Code
```
from microbit import
# Initialize the light sensor and sound sensor
light_sensor = pin3
sound_sensor = pin4
# Initialize the buzzer module
buzzer_module = pin5
while True:
# Read the light and sound data
light_data = light_sensor.read_analog()
sound_data = sound_sensor.read_analog()
# Calculate the brightness and loudness levels
brightness = light_data / 1023 10
loudness = sound_data / 1023 10
# Display the brightness and loudness levels on the Micro:Bit screen
display.scroll('Brightness: {} Loudness: {}'.format(brightness, loudness))
# Play a tone on the buzzer module based on the loudness level
if loudness > 5:
buzzer_module.write_analog(loudness 10)
else:
buzzer_module.write_analog(0)
# Wait for 100ms before taking the next reading
sleep(100)
```
Output
The Micro:Bit screen will display the brightness and loudness levels in real-time. The buzzer module will play a tone based on the loudness level, creating an interactive light and sound show.
These examples demonstrate the versatility of the Smart Science IoT Kit and its compatibility with the Micro:Bit. By combining the various components and sensors, users can create innovative projects that interact with their environment and collect valuable data.