Szymon MasternakJack DuffAndrew BerrySpiveyAdam O' Ceallaigh
Published © GPL3+

DIY Dot One Controlled IoT Smart Night Lamp

Ever wanted to have a Smart Night Lamp activated only when the sun sets? With the use of the Wia Platform and Dot One you can!

AdvancedFull instructions provided2 hours702
DIY Dot One Controlled IoT Smart Night Lamp

Things used in this project

Hardware components

Wia Dot One
Wia Dot One
×1
Wia Micro USB Cable
Wia Micro USB Cable
×1
Logic Level FET N-Channel
Logic Level FET N-Channel
×1
Resistor 10k ohm
Resistor 10k ohm
×1
White LED Strip
×1

Software apps and online services

Wia
Wia

Story

Read more

Schematics

Schematic

Code

Code for Wia Code Editor

C/C++
#include <WiFi.h>
#include <Wia.h>

Wia wiaClient = Wia();

void setup() {
  WiFi.begin();
  delay(2500);
  pinMode(15, OUTPUT);
}

void loop() {
  if ((wiaClient.getDeviceState("LED_Light")) == "On") {
    digitalWrite(15, HIGH);
  }
  if ((wiaClient.getDeviceState("LED_Light")) == "Off") {
    digitalWrite(15, LOW);
  }
  delay(2500);

}

Code For Function

JavaScript
var startTime_temp = JSON.parse(input.body).results.sunrise;
var endTime_temp = JSON.parse(input.body).results.sunset;

var startTime = startTime_temp.substring(11,19);
var endTime = endTime_temp.substring(11,19);

var currentDate = new Date();

var startDate = new Date(currentDate.getTime());
startDate.setHours(startTime.split(":")[0]);
startDate.setMinutes(startTime.split(":")[1]);
startDate.setSeconds(startTime.split(":")[2]);

var endDate = new Date(currentDate.getTime());
endDate.setHours(endTime.split(":")[0]);
endDate.setMinutes(endTime.split(":")[1]);
endDate.setSeconds(endTime.split(":")[2]);

if (startDate < currentDate && endDate > currentDate){
  output.body = "Off";
}
else {
		output.body = "On";
}

Credits

Szymon Masternak

Szymon Masternak

6 projects • 5 followers
Jack Duff

Jack Duff

32 projects • 8 followers
Man of the people. Champion of the downtrodden. Marketing magic @ Wia. Becoming a maker by learning, building, and exploring
Andrew Berry

Andrew Berry

25 projects • 11 followers
Spivey

Spivey

82 projects • 59 followers
Tourist in a Tutu || US Born || Melbourne/Mexico/California Raised || New Yorker at ❤️ || SF to Dublin to be COO of Wia the best IoT startup
Adam O' Ceallaigh

Adam O' Ceallaigh

20 projects • 8 followers

Comments