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

Cloud-Based Temperature Logger for Homebrew Fermenter
Easy
  • 227
  • 7

Work in progress

Using battery powered NodeMCU v2 and DS18B20 thermometer to log temperature and system voltage on Google Sheets.

IoT Made Simple: Home Weather Station With NodeMCU and OLED
Easy
  • 1,827
  • 26

Full instructions

Weather station displaying indoor temp/hum, as well as climate conditions and present day/3-day forecast.

ESP8266 & Temperature Sensors DS18b20 with HTTP Server
Easy
  • 148
  • 4

Protip

ESP8266 and multiple temperature sensors DS18b20 with HTTP server.

When IoT Meets AI: Home Automation With Alexa and NodeMCU
Easy
  • 155
  • 3

Full instructions

A Home Automation project, with 4 smart emulated WeMo devices being controlled by voice.

PlatformIO for Visual Studio Code
Easy
  • 592
  • 5

Protip

PlatformIO is an open source ecosystem for IoT development. And now, PlatformIO for Visual Studio Code is coming!

ESP8266 & Seeed Light Sensor - quick start in 2 mins
Easy
  • 224
  • 3

Full instructions

Explains how use Seeed Light sensor with Mongoose OS on ESP8266 NodeMCU. Solderless, in less than 3 minutes and in a simple JavaScript!

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback