-- Setting PIN1 to triggers on interrupt when alarm triggers
gpio.mode(1,gpio.INT)
gpio.trig(1,'down',function(level)
print('Time is passing')
-- If not reloaded it will be triggered only once
ds3231.reloadAlarms()
end)
ds3231.setAlarm(2,ds3231.EVERYMINUTE)
-- Don't forget to release it after use
ds3231 = nil
package.loaded["ds3231"]=nil
```
####See also
**-** []()
<aid="ds3231_reloadAlarms"></a>
## reloadAlarms()
####Description
Reload an already triggered alarm. Otherwise it will never be triggered again.
Alarms have to be reloaded both to let them triggers.
####Syntax
reloadAlarms()
####Parameters
nil
####Returns
nil
####Example
```lua
ds3231=require("ds3231")
ds3231.init(3, 4)
-- Setting PIN1 to triggers on interrupt when alarm triggers
gpio.mode(1,gpio.INT)
gpio.trig(1,'down',function(level)
print('Time is passing')
-- If not reloaded it will be triggered only once
ds3231.reloadAlarms()
end)
ds3231.setAlarm(2,ds3231.EVERYMINUTE)
-- Don't forget to release it after use
ds3231 = nil
package.loaded["ds3231"]=nil
```
####See also
**-** []()
<aid="ds3231_enableAlarm"></a>
## enableAlarm()
####Description
Enable an already setted alarm with the previous matching conditions. It reload alarms internally.
####Syntax
enableAlarm(alarmId)
####Parameters
alarmId: 1-2
####Returns
nil
####Example
```lua
ds3231=require("ds3231")
ds3231.init(3, 4)
-- Trigger on x:20:15
ds3231.setAlarm(1,ds3231.MINUTE,15,20)
if badThing == 1 then
ds3231.disableAlarm(1)
end
if goodThing == 1 then
ds3231.enableAlarm(1)
end
-- Don't forget to release it after use
ds3231 = nil
package.loaded["ds3231"]=nil
```
####See also
**-** []()
<aid="ds3231_disableAlarm"></a>
## disableAlarm()
####Description
Disable an already setted alarm with the previous matching conditions.
if _alarmId_ is not 1 or 2 it disables both alarms.
**Warning**: `disableAlarm()` prevent alarms to trigger interrupt over SQW pin but alarm itself will triggers at the matching conditions as it could be seen on _status byte_.
####Syntax
disableAlarm(alarmId)
####Parameters
alarmId: 0-2
####Returns
nil
####Example
```lua
ds3231=require("ds3231")
ds3231.init(3, 4)
-- Trigger on x:20:15
ds3231.setAlarm(1,ds3231.MINUTE,15,20)
if badThing == 1 then
ds3231.disableAlarm(1)
end
if goodThing == 1 then
ds3231.enableAlarm(1)
end
-- Don't forget to release it after use
ds3231 = nil
package.loaded["ds3231"]=nil
```
####See also
**-** []()
<aid="ds3231_getBytes"></a>
## getBytes()
####Description
Get bytes of control, for debug purpose, and status of DS3231. To see what they means check the [Datasheet](http://datasheets.maximintegrated.com/en/ds/DS3231.pdf)
####Syntax
getBytes()
####Parameters
nil
####Returns
control: integer. Control 0-255
status: integer. Status 0-143 (bit 6-5-4 unused)
####Example
```lua
ds3231=require("ds3231")
ds3231.init(3, 4)
control,status = ds3231.getBytes()
print('Control byte: '..control)
print('Status byte: '..status)
-- Don't forget to release it after use
ds3231 = nil
package.loaded["ds3231"]=nil
```
####See also
**-** []()
<aid="ds3231_resetStopFlag"></a>
## resetStopFlag()
####Description
Stop flag on status byte means that the oscillator either is stopped or was stopped for some period and may be used to judge the validity of the timekeeping data.
When setted to 1 this flag keeps that values until changed to 0.
Call `resetStopFlag()` if you need to check validity of time data after that.