Difference between revisions of "Blog 11"

From BitWizard WIKI
Jump to: navigation, search
(Created page with " == CHARLEY BETA! == == Clock based On/off system == My new system I am going to make is a system that on special times turns light on or off. I want to use this as some a...")
 
(Clock based On/off system)
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
== Clock based On/off system ==
 
== Clock based On/off system ==
  
My new system I am going to make is a system that on special times turns light on or off.  
+
In this post I am going to work with crontab. What I am going to show is how you can make it possible to turn a light on or off on special times.  
I want to use this as some anti-criminal system. So, that when I am on vacation still the lights are on at night or day. So the house doesn't look like a house that is asking for crackers or criminals.  
+
I made this as some anti-criminal technique. So, that when I am away the lights are still on at night or day in the house. With that the house doesn't look like a house that has nobody in it.  
  
For this system I am of course going to try it with shorter times otherwise I have to wait 8 hours for a lamp to get on or off.
+
For this system I am of course going to try if it works with shorter times otherwise I have to wait 8 hours for a lamp to get on or off.
  
 
So when I start the code I plan it 1 minute in the future.  
 
So when I start the code I plan it 1 minute in the future.  
  
I already made a lamp go on and off in [[blog 02]]. so I am going to use that same technique for turning on and of the lamp.  
+
I already made a lamp go on and off in [[blog 02]]. So I am going to use that same way for turning on and off the lamp.  
  
Crontab is more manually
+
Working with crontab has to all be done manually:
  Crontab -e  
+
  crontab -e  
has to be done to open
+
has to be done to open crontab for editing
and have to put this in to make it work
+
 
 +
I then have to put this in to make it work to turn the light on at 13:19 and turn the light off at 13:20:
 
   
 
   
 
  #  mm hh dom mon dow command  
 
  #  mm hh dom mon dow command  
Line 24: Line 25:
  
 
To read a certain part:
 
To read a certain part:
  crontab -l |grep -v bin/gpio  
+
  crontab -l |grep bin/gpio
 +
( With -v you can also let the other parts without bin/gpio appearing.
  
 
For the people who don't understand:
 
For the people who don't understand:
*1 Minute 0-59
+
*1 (mm)Minute 0-59  
*2 Hour 0-23 (0 = midnight)
+
*2 (hh)Hour 0-23 (0 = midnight)
*3 Day 1-31
+
*3 (dom)Day 1-31
*4 Month 1-12
+
*4 (mon)Month 1-12
*5 Weekday 0-6 (0 = Sunday)  
+
*5 (dow)Weekday 0-6 (0 = Sunday)  
  
 
So the text from my is now saying:
 
So the text from my is now saying:
 
  gpio write 3 1 at 13:19
 
  gpio write 3 1 at 13:19
 
  gpio write 3 0 at 13:20
 
  gpio write 3 0 at 13:20
 +
 +
To manually change it in the command line:
  
 
  ( echo "#  mm hh dom mon dow command" ; echo '19 13 * * * /usr/local/bin/gpio write 3 1' ;  echo '20 13 * * * /usr/local/bin/gpio write 3 0' ) |  crontab  
 
  ( echo "#  mm hh dom mon dow command" ; echo '19 13 * * * /usr/local/bin/gpio write 3 1' ;  echo '20 13 * * * /usr/local/bin/gpio write 3 0' ) |  crontab  
  
 
( You can of course also use it as alarm clock, then you only have to change the command to the location of the audio file you want to play.)
 
( You can of course also use it as alarm clock, then you only have to change the command to the location of the audio file you want to play.)
 +
 +
[[File:DSC05964.JPG|300px|thumb|none|]]
  
 
== manual Display Alarm ==
 
== manual Display Alarm ==

Latest revision as of 11:27, 26 October 2015

CHARLEY BETA!

Clock based On/off system

In this post I am going to work with crontab. What I am going to show is how you can make it possible to turn a light on or off on special times. I made this as some anti-criminal technique. So, that when I am away the lights are still on at night or day in the house. With that the house doesn't look like a house that has nobody in it.

For this system I am of course going to try if it works with shorter times otherwise I have to wait 8 hours for a lamp to get on or off.

So when I start the code I plan it 1 minute in the future.

I already made a lamp go on and off in blog 02. So I am going to use that same way for turning on and off the lamp.

Working with crontab has to all be done manually:

crontab -e 

has to be done to open crontab for editing

I then have to put this in to make it work to turn the light on at 13:19 and turn the light off at 13:20:

#  mm hh dom mon dow command 
19 13 * * * /usr/local/bin/gpio write 3 1 
20 13 * * * /usr/local/bin/gpio write 3 0 

To read a certain part:

crontab -l |grep bin/gpio 

( With -v you can also let the other parts without bin/gpio appearing.

For the people who don't understand:

  • 1 (mm)Minute 0-59
  • 2 (hh)Hour 0-23 (0 = midnight)
  • 3 (dom)Day 1-31
  • 4 (mon)Month 1-12
  • 5 (dow)Weekday 0-6 (0 = Sunday)

So the text from my is now saying:

gpio write 3 1 at 13:19
gpio write 3 0 at 13:20

To manually change it in the command line:

( echo "#  mm hh dom mon dow command" ; echo '19 13 * * * /usr/local/bin/gpio write 3 1' ;  echo '20 13 * * * /usr/local/bin/gpio write 3 0' ) |  crontab 

( You can of course also use it as alarm clock, then you only have to change the command to the location of the audio file you want to play.)

DSC05964.JPG

manual Display Alarm