For an index of all of my stories click this text
I found this neat vibration detector called SW-18010P which just costs a few cents.
As you can see it is a very small sensor almost the height of a paperclip.
This makes it possible to build in secretly in all kinds of objects.
What does it do. Well exactly what the name indicates: it detects vibration. And it is very sensitive. Let's have a look at the inside.
As you can see the interior is very simple. It is a wire that as a matter of speak floats in a coil. So as soon as there is some vibration the wire will touch the coil and current can flow.
When I first received these sensors I thought they were broken. I tried to measure the contacts with a multimeter. However the vibration has such a short timespan that the multimeter is to slow to react on it.
So I decided to set up a test with a Wemos ESP8266 on a breadboard.
As far as I know there is no Fritzing part for this sensor so I used a reed-contact part for the schematics. As you can see the setup is simple.
The sw18010p is connected with a pull-up resistor to pin D2 of the Wemos.
Next I wrote a short program in ESP-Basic to test it.
It is very simple and straightforward and could easily be ported to Arduino code or Lua or whatever your favorite devellopment language is.
interrupt d2, [vibrated]
wait
[vibrated]
print "it moved"
delay 500
wait
Testing the IO port for a change from 1 to 0 could work. I intentionally say could as the vibration can easily be missed as it has a short timespan. Therefore an interrupt works best.
You can easily adapt this for use with an Arduino, Attiny or Raspberry PI or any other microcontroller of your liking.
I have a really good idea for a project with this, so keep coming back. In the mean time here are some ideas for which you could use this sensor:
- a box that reacts on knockin on it
- is the drawer being opened
- is the door being opened
- has my bike moved
- is somebody trying to steal my cookies
I am sure you can think of a few projects yourself. Basically anything that moves can be spied upon.
Till next time
Have fun
Luc Volders
Saturday, May 26, 2018
Saturday, May 12, 2018
Washing Machine monitor
For an index off all my stories click this text.
Like most people we have a washing machine. No problem. There is however one annoying thing.
The washing machine is on the ground floor. And my girlfriend (who operates it, how bout that division of tasks) who is a painter has her work-place on the second floor of our house.
Now the washing machine will just shut down when it has finished its task. However when she is in her work-room she can't see that. So she has no other indication wether the machine has finished its task, as to leave her work every now and then and go downstairs to have a look. Waste of time and annoying. Surely there has to be an easier way, and there is.
Washing procedures.
The first thing to do to find an easier way to check if the washing machine has finished it's job is to look how it operates. Well that is fairly simple.
When the machine is put to work the led display and all kinds of indicators are on.
When the machine finishes it shuts itself down putting all indicators off. This offers possibilities.
It is about the same as checking wether the refridgerator door is open or closed like I did in this story:
https://lucstechblog.blogspot.nl/2017/03/cheapskate.html
I just wanted to make it a bit more fancy.
Overvieuw.
The ESP8266 is what I am going to build this with. I could not use the ESP-01 as I needed an analog input for the LDR, next to more I/O pins. So I used a NodeMcu. I am going to check the display of the washing machine with an LDR. Next to that I am going to attach a pushbutton to start the monitoring and a led that indicates that monitoring has indeed started. That is all we need for the hardware.
When the washing machine has finished I want it to send a signal to my girlfriends mobile phone. I am going to program the NodeMCU in ESP-Basic and use the Maker Channel from IFTTT for sending notice to the mobile phone.
For detailed information on installing ESP-Basic and use check this page:
https://lucstechblog.blogspot.nl/2017/03/back-to-basic-basic-language-on-esp8266.html
The hardware
Not much to it. Here is a list of what you'll need:
- NodeMCU
- USB Power supply (or powerbank)
- 1 led (I choose a green one)
- 1 220 ohm delimiting resistor for the led
- 1 Push-button
- 1 10K pull-up resistor for the button
- 1 LDR
- 1 10K pull-down resistor for the LDR
So for testing purposes I put everything on a breadboard.
And here is how the prototype looks in real-life.
The software
First a timer is set that will jump to the [test] routine which checks the LDR value every second. And an interrupt is defined that checks wether the button has been pushed.
Then the software starts with building a webpage which you can look at on your computer, phone or tablet. This is not necessary however convenient for testing and debugging. You can find the webpage by looking in your router at the IP-adress of the ESP and then pointing your web-browser to that IP adress like discussed here:
https://lucstechblog.blogspot.nl/2017/03/back-to-basic-basic-language-on-esp8266.html
The [test] routine then checks every second the value of the LDR.
The if statements tests wether the LDR measurement is below a certain value AND the LED is ON. If that is the case the washmachine has finished and the monitor program is working. The alert is send to IFTTT. The LED is then set OFF so that if the test is run again, no alert is send unless the LED has been set on again by pushing the button.
Replace YOUR-PERSONAL-KEY with your own personal IFTTT key, and if you like replace wash-finished with any other name you like as a trigger. Just make sure you use the same name in the next steps where you will create the IFTTT applet.
The [change] routine tests the state of the button and if that is 0 (button pressed) the LED is set ON.
That is all.
Testing.
Start with commenting-out the IFTTT trigger in the ESP-Basic program. Otherwise you will get notifications on your phone with each test you perform. You can do that by setting a ' in front of the line you do not want to run. In this case in front of the print wget( etc etc etc line.
For testing purposes I taped the LDR to the washing machine with some dark painters tape. I carefully looked at the values that appeared on the webpage when the lights of the washing machine where on and off. I tested with different environment lightning like open and closed curtains and on and off ceiling lights.Then values are shown on the ESP's webpage which will look as follows:
That gave me the right values that the LDR would register and I put those in the Basic program at the following line:
if (value < 600) and (io(laststat,d7) = 1) then
Replace the figure 600 with the value you will find.
Now uncomment the wget line by removing the '
Create an IFTTT applet
First make sure you have an IFTTT account and are connected to the Maker Channel. If everything went well you will have your personal IFTTT key. Fill that key in at the right place in the ESP-Basic program.
Start with choosing to make a new applet.
Click on the blue +this
Now choose a service. You are presented with many possibillities bus just type in web and then webhooks will emerge.
Now choose a trigger. Not many choices at this moment but sufficient for our purpose. Click on "Receive a web request"
Complete the trigger fields. I typed Wasmachine monitor but replaced with wash-finished. Use exactly the same name as is filled in in the ESP-Basic program. Otherwise the IFTTT part will not work.
Now click on the blue +that
The IF part is done now we need to make the THAT part. Choose an action presents you again with many possibillities however type in no at the search functions and Notifications will emerge. Click on that.
Again not many choices so use the "Send a notification" action.
Fill in any text you want to be shown on your phone when the washmachine has finished. I chose the utterly original "The wasmachine has finished"
The final check
And you're done.
Autostarting the program.
Go back to the ESP-Basic editor and rename the program in default.bas and save it.
Now go to the SETTINGS page
Make sure you check, at the bottom, that default.bas is run at startup.
Real-life use.
You will have to have IFTTT installed on your phone/tablet and running
Plug the USB-Power plug in the wall and wait about a minute. The NodeMCU will by then have booted and the default.bas program will be running.
Set the washing machine ON and press the button on the breadboard.
The LED on the breadboard will go ON.
Just wait till the washmachine has finished, or shut the power down manually.
The LED on the breadboard will go OFF and you will get (when activated) an audible alert and maybe a blinking led on the phone/tablet.
On the start-screen of your phone you will see the IFTTT logo on the left upper part.
And this is what the notification screen on your phone will look like.
If you would open your webbrowser and point it to the ESP you will also find a notification on the webpage.
Additional benefit
Girlfriend Happy !!
And that is the best part.
Now I only have to put the hardware on a stripboard and then design and print a nice casing.
Till next time.
Have fun and keep your partner happy.
Luc Volders
Like most people we have a washing machine. No problem. There is however one annoying thing.
The washing machine is on the ground floor. And my girlfriend (who operates it, how bout that division of tasks) who is a painter has her work-place on the second floor of our house.
Now the washing machine will just shut down when it has finished its task. However when she is in her work-room she can't see that. So she has no other indication wether the machine has finished its task, as to leave her work every now and then and go downstairs to have a look. Waste of time and annoying. Surely there has to be an easier way, and there is.
Washing procedures.
The first thing to do to find an easier way to check if the washing machine has finished it's job is to look how it operates. Well that is fairly simple.
When the machine is put to work the led display and all kinds of indicators are on.
When the machine finishes it shuts itself down putting all indicators off. This offers possibilities.
It is about the same as checking wether the refridgerator door is open or closed like I did in this story:
https://lucstechblog.blogspot.nl/2017/03/cheapskate.html
I just wanted to make it a bit more fancy.
Overvieuw.
The ESP8266 is what I am going to build this with. I could not use the ESP-01 as I needed an analog input for the LDR, next to more I/O pins. So I used a NodeMcu. I am going to check the display of the washing machine with an LDR. Next to that I am going to attach a pushbutton to start the monitoring and a led that indicates that monitoring has indeed started. That is all we need for the hardware.
When the washing machine has finished I want it to send a signal to my girlfriends mobile phone. I am going to program the NodeMCU in ESP-Basic and use the Maker Channel from IFTTT for sending notice to the mobile phone.
For detailed information on installing ESP-Basic and use check this page:
https://lucstechblog.blogspot.nl/2017/03/back-to-basic-basic-language-on-esp8266.html
The hardware
Not much to it. Here is a list of what you'll need:
- NodeMCU
- USB Power supply (or powerbank)
- 1 led (I choose a green one)
- 1 220 ohm delimiting resistor for the led
- 1 Push-button
- 1 10K pull-up resistor for the button
- 1 LDR
- 1 10K pull-down resistor for the LDR
So for testing purposes I put everything on a breadboard.
And here is how the prototype looks in real-life.
The software
io(po,d7,0) timer 1000,[test] interrupt d1, [change] wprint |<body style="background-color:LightSkyBlue ;">| wprint |<span style="color: red;">| wprint |<h1 style="text-align:center;">Luc Volders</br>Washmachine</br>Monitor</br>| wprint "<br/>" wprint |<span style="color: black;">| wprint "LDR measures " textbox value wprint "<br/>" wprint "keypress " textbox keypr wprint "<br/><br/>" button "<h2>Off</h2>", [Off] wprint "<br/>" wait [test] value = io(ai) if (value < 600) and (io(laststat,d7) = 1) then keypr = "ready for use" print wget("maker.ifttt.com/trigger/wash-finished/with/key/YOUR-PERSONAL-KEY") io(po,d7,0) endif wait [change] if io(laststat,d1) = 0 then keypr = "running" io(po,d7,1) endif wait [Off] end
First a timer is set that will jump to the [test] routine which checks the LDR value every second. And an interrupt is defined that checks wether the button has been pushed.
Then the software starts with building a webpage which you can look at on your computer, phone or tablet. This is not necessary however convenient for testing and debugging. You can find the webpage by looking in your router at the IP-adress of the ESP and then pointing your web-browser to that IP adress like discussed here:
https://lucstechblog.blogspot.nl/2017/03/back-to-basic-basic-language-on-esp8266.html
The [test] routine then checks every second the value of the LDR.
The if statements tests wether the LDR measurement is below a certain value AND the LED is ON. If that is the case the washmachine has finished and the monitor program is working. The alert is send to IFTTT. The LED is then set OFF so that if the test is run again, no alert is send unless the LED has been set on again by pushing the button.
Replace YOUR-PERSONAL-KEY with your own personal IFTTT key, and if you like replace wash-finished with any other name you like as a trigger. Just make sure you use the same name in the next steps where you will create the IFTTT applet.
The [change] routine tests the state of the button and if that is 0 (button pressed) the LED is set ON.
That is all.
Testing.
Start with commenting-out the IFTTT trigger in the ESP-Basic program. Otherwise you will get notifications on your phone with each test you perform. You can do that by setting a ' in front of the line you do not want to run. In this case in front of the print wget( etc etc etc line.
For testing purposes I taped the LDR to the washing machine with some dark painters tape. I carefully looked at the values that appeared on the webpage when the lights of the washing machine where on and off. I tested with different environment lightning like open and closed curtains and on and off ceiling lights.Then values are shown on the ESP's webpage which will look as follows:
That gave me the right values that the LDR would register and I put those in the Basic program at the following line:
if (value < 600) and (io(laststat,d7) = 1) then
Replace the figure 600 with the value you will find.
Now uncomment the wget line by removing the '
Create an IFTTT applet
First make sure you have an IFTTT account and are connected to the Maker Channel. If everything went well you will have your personal IFTTT key. Fill that key in at the right place in the ESP-Basic program.
Start with choosing to make a new applet.
Click on the blue +this
Now choose a service. You are presented with many possibillities bus just type in web and then webhooks will emerge.
Now choose a trigger. Not many choices at this moment but sufficient for our purpose. Click on "Receive a web request"
Complete the trigger fields. I typed Wasmachine monitor but replaced with wash-finished. Use exactly the same name as is filled in in the ESP-Basic program. Otherwise the IFTTT part will not work.
Now click on the blue +that
The IF part is done now we need to make the THAT part. Choose an action presents you again with many possibillities however type in no at the search functions and Notifications will emerge. Click on that.
Again not many choices so use the "Send a notification" action.
Fill in any text you want to be shown on your phone when the washmachine has finished. I chose the utterly original "The wasmachine has finished"
The final check
And you're done.
Autostarting the program.
Go back to the ESP-Basic editor and rename the program in default.bas and save it.
Now go to the SETTINGS page
Make sure you check, at the bottom, that default.bas is run at startup.
Real-life use.
You will have to have IFTTT installed on your phone/tablet and running
Plug the USB-Power plug in the wall and wait about a minute. The NodeMCU will by then have booted and the default.bas program will be running.
Set the washing machine ON and press the button on the breadboard.
The LED on the breadboard will go ON.
Just wait till the washmachine has finished, or shut the power down manually.
The LED on the breadboard will go OFF and you will get (when activated) an audible alert and maybe a blinking led on the phone/tablet.
On the start-screen of your phone you will see the IFTTT logo on the left upper part.
And this is what the notification screen on your phone will look like.
If you would open your webbrowser and point it to the ESP you will also find a notification on the webpage.
Additional benefit
Girlfriend Happy !!
And that is the best part.
Now I only have to put the hardware on a stripboard and then design and print a nice casing.
Till next time.
Have fun and keep your partner happy.
Luc Volders
Subscribe to:
Posts (Atom)