Free delivery on orders above Rs 900 | Single Delivery charges for Multiple Items

Cart

Your Cart is Empty

Back To Shop

Cart

Your Cart is Empty

Back To Shop

How You Can Control Devices Remotely with Arduino MKR WiFi 1010 Web Server?

mkr tutorial 04 img 01 rev2

Controlling devices remotely with the Arduino MKR WiFi 1010 using its web server capabilities is a cool project! Here’s a basic outline of the steps involved:

Set Up Arduino MKR WiFi 1010:

    • Ensure your Arduino MKR WiFi 1010 is connected to your computer.
    • Install the Arduino IDE and necessary drivers.

Connect Arduino to WiFi:

    • Write a sketch to connect the Arduino to your WiFi network using the h library.

Code-

#include <WiFi.h>

const char* ssid = “your-SSID”;
const char* password = “your-PASSWORD”;

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println(“Connecting to WiFi…”);
}

Serial.println(“Connected to WiFi”);
}

void loop() {
// Your code here
}

Create a Web Server:

  • Use the WiFiServer and WiFiClient classes to create a basic web server.

Code-

#include <WiFi.h>

WiFiServer server(80);

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println(“Connecting to WiFi…”);
}

Serial.println(“Connected to WiFi”);

server.begin();
}

void loop() {
WiFiClient client = server.available();

if (client) {
Serial.println(“New client connected”);
// Handle the client’s request
client.println(“Hello from Arduino!”);
client.stop();
Serial.println(“Client disconnected”);
}
}

Handle Remote Commands:

  • Extend your server to handle different paths or parameters in the URL, representing different commands.

Code-

void handleRequest(WiFiClient client) {
String request = client.readStringUntil(‘\r’);
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-type:text/html”);
client.println();

if (request.indexOf(“/on”) != -1) {
// Code to turn on the device
client.println(“Device is ON”);
} else if (request.indexOf(“/off”) != -1) {
// Code to turn off the device
client.println(“Device is OFF”);
} else {
client.println(“Invalid command”);
}

client.stop();
}

Upload the Sketch:

    • Upload your sketch to the Arduino MKR WiFi 1010.

Access the Web Server:

    • Find the IP address assigned to your Arduino by the router.
    • Open a web browser and navigate to that IP address.

Control Devices Remotely:

    • Enter different URLs (e.g., http://arduino_ip/on) to control your devices remotely.

Remember, this is a simplified example. Depending on your project, you might need to implement security measures, handle more complex commands, and ensure the stability of your remote control system. Always consider security best practices, especially when controlling devices remotely.

Cart

Your Cart is Empty

Back To Shop
GET DISCOUNT CODE

It will take just few seconds to claim 7% Discount, After Submitting check Email for Coupon code.

    X
    GET DISCOUNT CODE