Universal IoT Experiment Kit for ESP32 Documentation
The Universal IoT Experiment Kit for ESP32 is a comprehensive development board designed to facilitate IoT project development using the ESP32 microcontroller. This kit provides a range of peripherals and interfaces, enabling users to explore and implement various IoT applications.
ESP32 microcontroller
Wi-Fi and Bluetooth capabilities
16MB of flash memory
MicroSD card slot
USB-to-UART bridge
Buzzer
RGB LED
Temperature sensor
Light sensor
Joystick
Breadboard-friendly layout
Compatible with MicroPython and C/C++
Supports various communication protocols (Wi-Fi, Bluetooth, HTTP, MQTT, etc.)
Integrated development environment (IDE) support
### Example 1: Wi-Fi Connectivity and HTTP Request
This example demonstrates how to connect to a Wi-Fi network and send an HTTP request using the ESP32 microcontroller.
MicroPython Code:
```python
import network
import urequests
# Initialize Wi-Fi
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
# Connect to Wi-Fi network
wlan.connect('your_wifi_ssid', 'your_wifi_password')
while not wlan.isconnected():
pass
print('Connected to Wi-Fi')
# Send HTTP request
response = urequests.get('http://httpbin.org/ip')
print('Response:', response.text)
```
### Example 2: Bluetooth Low Energy (BLE) Peripherals
This example showcases how to use the ESP32 as a BLE peripheral, advertising its presence and allowing connections from a BLE central device.
C Code:
```c
#include <BLE.h>
BLEServer server;
BLEService service;
BLECharacteristic characteristic;
void setup() {
Serial.begin(115200);
// Initialize BLE
BLE.begin();
// Create BLE service and characteristic
service = server->createService("180F");
characteristic = service->createCharacteristic("2A19", BLECharacteristic::PROPERTY_NOTIFY);
// Start advertising
server->startAdvertising();
}
void loop() {
// Wait for BLE connections
BLEDevice central = server->available();
if (central) {
Serial.println("Connected to BLE central device");
}
delay(50);
}
```
### Example 3: IoT Sensor Reading and Cloud Upload (using MQTT)
This example demonstrates how to read temperature sensor data, connect to an MQTT broker, and publish the sensor readings to a cloud-based IoT platform.
MicroPython Code:
```python
import machine
import ubinascii
import ujson
import umqtt.simple
# Initialize temperature sensor
temp_sensor = machine.ADC(machine.Pin(35))
# Set up MQTT client
mqtt_client = umqtt.simple.MQTTClient('your_mqtt_client_id', 'your_mqtt_broker_url')
# Connect to MQTT broker
mqtt_client.connect()
while True:
# Read temperature sensor
temp_reading = temp_sensor.read_u16()
temp_celsius = (temp_reading / 4095) 3.3
# Create JSON payload
payload = {'temperature': temp_celsius}
# Publish to MQTT topic
mqtt_client.publish('your_mqtt_topic', ujson.dumps(payload))
# Wait for 1 minute before next reading
machine.sleep(60000)
```
These examples demonstrate the versatility of the Universal IoT Experiment Kit for ESP32, showcasing its capabilities in Wi-Fi connectivity, BLE peripherals, and IoT sensor applications.