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

Countdown Calendars
Easy
  • 220
  • 7

Full instructions

Display the number of days until the next event from your google hosted calendars.

Echo Kill Switch
Easy
  • 4,357
  • 21

Full instructions

Use Amazon Alexa to trigger an IFTTT applet that causes a Particle Photon to remove power from an Echo.

IoT Made Simple: Monitoring Temperature Anywhere
Easy
  • 928
  • 8

Full instructions

We will learn how to capture temperature data, upload it to internet with a NodeMCU and monitor it on a Smart device using a Blynk app.

NodeMCU Web Server with DHT11 data
Easy
  • 234
  • 3

Need to serve data points for your 'connected' home? This is a very simple way.

DIY WiFi Smart Plug
Easy
  • 1,395
  • 7

Full instructions

A DIY version of the Tp-link HS100 smart plug implemented using Wemos D1 Mini and Relay shield.

WebServerBlink Using NodeMCU
Easy
  • 867
  • 9

Full instructions

NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 Wi-Fi SoC. It's a simple Blink using Webserver.

ProjectsCommunitiesContestsLiveJobsFree StoreBlogAdd projectSign up / Login
Respect project