Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Dana Mah
Created June 30, 2018 © GPL3+

Wireless Automated switch

This is a switch that will turn on your lights when the devices gets close enough.

BeginnerWork in progress1 hour34
Wireless Automated switch

Things used in this project

Story

Read more

Code

autoSwitch

C/C++
This code is suppose to call the home automation system with an http.get call with a status=1 to turn on a light. But is still needs some work as the call doesnt seem to work propertly
#include "HttpClient/HttpClient.h"

HttpClient http;

http_request_t request;
http_response_t response;

IPAddress IP(192.168.2.100);
IPAddress remoteAddress;


void setup() {
    request.port = 1880;
    request.ip = remoteAddress;
    request.path = "/lighSwitch?status=1";
    Serial.begin(9600);
}

void loop() {     
    //request.body = "";
    http.get(request, response, headers);
    Serial.println(response.status); 
    Serial.println(response.body);
    delwy(5);
}

Credits

Dana Mah

Dana Mah

12 projects • 27 followers
I'm a hobbyist interested in microcontroller solutions to simple problems.

Comments