Things used in this project

Hardware components:
D1 mini
Everything ESP Wemos D1 Mini
×1
Mfr 25frf52 10k sml
Resistor 10k ohm
×1
Adafruit industries ada161 image 75px
Photo resistor
LDR used was the GL5528
×1
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service

Schematics

Schematic
Ftrz697ctrty8ysrnut5

Code

init.luaLua
init file, runs at startup connects to wifi, calls washer.lua
print('init.lua ver 1.2')
wifi.setmode(wifi.STATION)
print('set mode=STATION (mode='..wifi.getmode()..')')
print('MAC: ',wifi.sta.getmac())
print('chip: ',node.chipid())
print('heap: ',node.heap())
-- wifi config start
wifi.sta.config("ssid","password")
-- wifi config end
wifi.sta.connect()
 tmr.alarm(1, 1000, 1, function()
  if wifi.sta.getip()== nil then
  print("IP unavaiable, Waiting...")
 else
  tmr.stop(1)
 print("ESP8266 mode is: " .. wifi.getmode())
 print("The module MAC address is: " .. wifi.ap.getmac())
 print("Config done, IP is "..wifi.sta.getip())

 dofile ("washer.lua")
 end
end)
washer.luaLua
Main program
LightStatus = 0
function sendData()

ldr=adc.read(0) -- reads value from Analog Input (max 1V)
print (ldr) -- print value on screen

  if ldr > 500 then  -- If sensor >500 detect status LED is on
        print("LED on")
        LightStatus = 1
        print (ldr)
  end         
  if ldr < 500 and LightStatus == 1 then  -- If sensor >500 detect status LED changed from on to off
        print("LED off")
        LightStatus = 0      
        print (ldr)
        dofile("ifttt.lua")
        print ("ifttt triggered")     
  end  
end 
tmr.alarm(0, 10000, 1, function() sendData() end )
ifttt.luaLua
Sends call to Ifttt Maker Channel
conn = nil
conn=net.createConnection(net.TCP, 0) 

conn:on("receive", function(conn, payload) 
     print(payload) 
     end) 
     
conn:on("connection", function(conn, payload) 
     print('\nConnected') 
     conn:send("GET /trigger/WashDone/with/key/paste-maker-string-here"
      .." HTTP/1.1\r\n" 
      .."Host: maker.ifttt.com\r\n"
      .."Accept: */*\r\n" 
      .."User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n" 
      .."\r\n")
     end) 
     
conn:on("disconnection", function(conn, payload) 
      print('\nDisconnected') 
      end)
      
print('Posting to ifttt.com')                                    
conn:connect(80,'maker.ifttt.com')

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Boost Your Google Home With Prota OS for RPi
Easy
  • 1,702
  • 8

Full instructions

Extend your Google Home features to smart light, smart speakers, smart cam and smart appliances with those DIY tricks based on Raspberry Pi.

Google Home - Control DIY Devices
Easy
  • 868
  • 10

Full instructions

This project show how to control multiple IoT devices using Google Home.

Text Machine, Get Gumball
Easy
  • 34
  • 1

This project describes how to build an Arduino-based, text-controlled gum dispenser

ioTank
Easy
  • 302
  • 2

Full instructions

An indoor environment monitor for the internet of things which senses temperature, humidity, ultraviolet, and clear light intensity

ioTank

Team Object Syndicate LLC

DIY Smart Home Automation for Everyone
Easy
  • 1,520
  • 15

Full instructions

Smart Home automation made easy and accessible for anyone, for little budget and no skills needed with Prota OS on Raspberry Pi

IoT Made Simple: Servo Control With NodeMCU and Blynk
Easy
  • 242
  • 3

Full instructions

In this simple tutorial, we will explore how to control a servo motor over the internet, using a smartphone.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback