ZB 15: Set time from Meshlium
his program shows how to set RTC time from Meshlium settings

Required Materials

1 x Waspmote 1 x Battery 1 x MiniUSB wire 1 x XBee-ZigBee module

Notes

- The battery has to be connected. - This example can be executed in Waspmote v12

Code

1
/*
2
* ------ [ZB_15] - send packets --------
3
*
4
* Explanation: This program shows how to set RTC time from Meshlium
5
* settings
6
*
7
* Copyright (C) 2015 Libelium Comunicaciones Distribuidas S.L.
8
* http://www.libelium.com
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the GNU General Public License
21
* along with this program. If not, see .
22
*
23
* Version: 0.1
24
* Design: David Gascón
25
* Implementation: Yuri Carmona
26
*/
27
28
#include <WaspXBeeZB.h>
29
30
// Destination MAC address
31
//////////////////////////////////////////
32
char MESHLIUM_ADDRESS[] = "0013A2004098FB30";
33
//////////////////////////////////////////
34
35
// define variable
36
uint8_t error;
37
38
39
40
void setup()
41
{
42
// init USB port
43
USB.ON();
44
USB.println(F("Setting RTC time from Meshlium settings"));
45
46
// init RTC
47
RTC.ON();
48
49
// init XBee
50
xbeeZB.ON();
51
52
}
53
54
55
void loop()
56
{
57
// set RTC time
58
error = xbeeZB.setRTCfromMeshlium(MESHLIUM_ADDRESS);
59
60
// check flag
61
if( error == 0 )
62
{
63
USB.print(F("SET RTC ok. "));
64
}
65
else
66
{
67
USB.print(F("SET RTC error. "));
68
}
69
70
USB.print(F("RTC Time:"));
71
USB.println(RTC.getTime());
72
73
delay(5000);
74
}
Copied!

Output

1
H#
2
Setting RTC time from Meshlium settings
3
SET RTC ok. RTC Time:Tue, 16/10/18, 10:32:08
Copied!
Last modified 2yr ago