Gary Watts
Published © GPL3+

ESP8266 Washing Machine Notifier

Use the small, easily programmed and powered Wemos D1 Mini to turn your washing machine into a smart appliance.

BeginnerFull instructions provided1 hour12,728
ESP8266 Washing Machine Notifier

Things used in this project

Hardware components

Wemos D1 Mini
Espressif Wemos D1 Mini
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Photo resistor
Photo resistor
LDR used was the GL5528
×1

Software apps and online services

Maker service
IFTTT Maker service

Story

Read more

Schematics

Schematic

Code

init.lua

Lua
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.lua

Lua
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.lua

Lua
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

Gary Watts

Gary Watts

1 project • 2 followers
Thanks to Noel Portugal and fab-lab.eu.

Comments