Arduino MKR IoT Bundle Documentation
The Arduino MKR IoT Bundle is a comprehensive kit that combines the best of Arduino's IoT offerings, including the MKR WiFi 1010 board, a Wi-Fi module, and various sensors. This bundle enables developers to create a wide range of IoT projects, from simple devices to complex systems.
Arduino MKR WiFi 1010 board
Wi-Fi module (IEEE 802.11b/g/n)
Temperature and humidity sensor (DHT11)
Light sensor (photoresistor)
Motion sensor (PIR)
3-axis accelerometer (LIS3DH)
Micro-USB cable
Power adapter
Breadboard and jumper wires
The Arduino MKR IoT Bundle is compatible with the Arduino Integrated Development Environment (IDE) and supports various libraries for Wi-Fi, sensors, and other components.
### Example 1: Wi-Fi Connectivity and Temperature/Humidity Monitoring
This example demonstrates how to connect to a Wi-Fi network and read temperature and humidity data from the DHT11 sensor.
```c++
#include <WiFiNina.h>
#include <DHT.h>
// Wi-Fi credentials
char ssid[] = "yourSSID";
char pass[] = "yourPASSWORD";
// DHT11 pin connections
#define DHTPIN 2
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Connect to Wi-Fi
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to Wi-Fi...");
}
Serial.println("Connected to Wi-Fi");
Serial.println(" Initializing DHT11...");
dht.begin();
}
void loop() {
// Read temperature and humidity data
float tempC = dht.readTemperature();
float humidity = dht.readHumidity();
// Print data to serial monitor
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println("C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println("%");
### Example 2: Motion Detection and Notification using IFTTT
This example demonstrates how to use the PIR motion sensor to detect movement and send a notification to an IFTTT (If This Then That) applet using the Arduino MKR IoT Bundle's Wi-Fi capabilities.
```c++
#include <WiFiNina.h>
#include <IFTTTMaker.h>
// Wi-Fi credentials
char ssid[] = "yourSSID";
char pass[] = "yourPASSWORD";
// IFTTT Maker API key
char apiKey[] = "yourAPIKEY";
// PIR pin connections
#define PIRPIN 3
IFTTTMaker ifttt(apiKey);
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Connect to Wi-Fi
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to Wi-Fi...");
}
Serial.println("Connected to Wi-Fi");
pinMode(PIRPIN, INPUT);
}
void loop() {
// Read PIR sensor data
int pirState = digitalRead(PIRPIN);
if (pirState == HIGH) {
// Motion detected, send notification to IFTTT
ifttt.sendEvent("motion_detected", "Motion detected!");
Serial.println("Motion detected!");
}
### Example 3: Accelerometer Data Streaming to a Web Dashboard
This example demonstrates how to use the LIS3DH 3-axis accelerometer to stream acceleration data to a web dashboard using the Arduino MKR IoT Bundle's Wi-Fi capabilities.
```c++
#include <WiFiNina.h>
#include <WiFiClient.h>
#include <LIS3DH.h>
// Wi-Fi credentials
char ssid[] = "yourSSID";
char pass[] = "yourPASSWORD";
// Web dashboard URL
char dashboardURL[] = "http://yourdashboard.com/accelerometer";
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Connect to Wi-Fi
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to Wi-Fi...");
}
Serial.println("Connected to Wi-Fi");
accelerometer.begin();
}
void loop() {
// Read acceleration data
int x, y, z;
accelerometer.readAcceleration(x, y, z);
// Create a WiFi client instance
WiFiClient client;
// Connect to the web dashboard
if (client.connect(dashboardURL, 80)) {
// Send acceleration data to the dashboard
client.print("GET /update?");
client.print("x=");
client.print(x);
client.print("&y=");
client.print(y);
client.print("&z=");
client.print(z);
client.println(" HTTP/1.1");
client.println("Host: yourdashboard.com");
client.println("Connection: close");
client.println();
}
These examples demonstrate the versatility of the Arduino MKR IoT Bundle and its potential applications in IoT projects.