Welcome to RazMesh! This guide will help you get started with our IoT management platform designed specifically for students.
Create your RazMesh account
Set up the RazMesh client
Add your IoT devices
Set up your dashboard
Follow these steps to install the RazMesh Arduino library.
RazMMeshClient.h and RazMeshClient.cppRazMMeshClient.h and RazMeshClient.cppRazMeshClientEnhanced in your Arduino libraries folderThis library requires the following Arduino libraries:
How to configure your Arduino code to connect to the RazMesh API.
Before you begin coding, make sure you have these credentials from your RazMesh account:
Unique identifier for your IoT device
Found in your RazMesh dashboard under "Devices"
Authentication token for API access
Generated in your RazMesh account under "API Keys"
#include <WiFi.h> // or <ESP8266WiFi.h> for ESP8266
#include <RazMMeshClient.h>
// WiFi credentials
const char* ssid = "YOUR_WIFI_SSID";
const char* pass = "YOUR_WIFI_PASSWORD";
// RazMesh credentials - REQUIRED
const char* DEVICE_ID = "RZM-2023-XXXX"; // Your device ID
const char* AUTH_KEY = "rzm_auth_xxxxxxxxxxxx"; // Your auth key
// API configuration
const char* API_URL = "https://your-domain.com/RazMesh";
const bool USE_HTTPS = true; // Set to false if your server doesn't support HTTPS
RazMeshClientEnhanced raz;
void setup() {
Serial.begin(115200);
// Connect to WiFi
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
// Initialize RazMesh client
raz.begin(API_URL, AUTH_KEY, USE_HTTPS);
// Register device (only needed once)
String resp;
int code;
if (raz.post("/register-device.php",
"{\"device_id\":\"" + String(DEVICE_ID) + "\",\"type\":\"sensor\"}",
resp, code)) {
Serial.printf("Device registration: %d - %s\n", code, resp.c_str());
}
}
void loop() {
// ...
}
raz.begin(url, key, true, 10000)
The DEVICE_ID and AUTH_KEY are required for all API requests.
The auth key is automatically included in all requests by the library, but you'll need to include the device ID in your data payloads
when sending sensor readings or other device-specific data.
Use the RazMesh Arduino library to easily integrate ESP8266/ESP32 devices with the RazMesh API. This library supports HTTPS, custom headers, and all HTTP methods.
RazMMeshClient.h and RazMeshClient.cpp into libraries/RazMeshClientEnhanced/ in your Arduino sketchbook folder.#include <WiFi.h> // or <ESP8266WiFi.h> for ESP8266
#include <RazMMeshClient.h>
const char* ssid = "YOUR_SSID";
const char* pass = "YOUR_PASS";
RazMeshClientEnhanced raz;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) delay(500);
Serial.println("WiFi connected");
// Initialize client: base URL, auth key, useHttps, timeoutMs
raz.begin("https://your.domain.com/RazMesh", "YOUR_AUTH_KEY", true, 10000);
String resp;
int code;
// 1) GET request
if (raz.get("/api/get-device.php", "device_id=42", resp, code)) {
Serial.printf("GET %d: %s\n", code, resp.c_str());
}
// 2) POST request
if (raz.post("/api/update-water.php", "{\"level\":12.3}", resp, code)) {
Serial.printf("POST %d: %s\n", code, resp.c_str());
}
// 3) DELETE with extra headers
if (raz.request("DELETE", "/api/device", "id=42", resp, code, {"X-Custom: Foo"})) {
Serial.printf("DEL %d: %s\n", code, resp.c_str());
}
// 4) Send email
if (raz.sendEmail("user@example.com", "Alert", "Threshold exceeded", resp, code)) {
Serial.printf("EMAIL %d: %s\n", code, resp.c_str());
}
}
void loop() {
// ...
}
RazMeshClientEnhanced()
Creates a new client instance.
begin(baseUrl, authKey, useHttps=false, timeoutMs=5000)
Set up the client with your API URL and auth key.
get(endpoint, queryParams, response, httpCode)
Send GET to baseUrl + endpoint?queryParams
post(endpoint, jsonPayload, response, httpCode)
Send POST with JSON body to baseUrl + endpoint
request(method, endpoint, payload, response, httpCode, extraHeaders={})
Any HTTP verb with custom headers. Payload is query for GET or body for others.
sendEmail(to, subject, content, response, httpCode)
Shortcut to send email via RazMesh API.
There's a mismatch between filenames and class names in this library:
RazMMeshClient.h
(note the double 'M')
RazMeshClient.cpp
RazMeshClientEnhanced
When installing, make sure both files go into the same folder, and your include statement matches the header filename exactly.
NodeMCU, Wemos D1 Mini, and other ESP8266-based boards
ESP32 DevKit, ESP32-WROOM, and other ESP32-based boards