blob: 61c86d9df21531ba498799a9351917b70b852c55 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/// @dir radioBlip
/// Send out a radio packet every minute, consuming as little power as possible.
// 2010-08-29 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#define RF69_COMPAT 0 // define this to use the RF69 driver i.s.o. RF12
#include <JeeLib.h>
static long payload;
// this must be added since we're using the watchdog for low-power waiting
ISR(WDT_vect) { Sleepy::watchdogEvent(); }
void setup() {
cli();
CLKPR = bit(CLKPCE);
#if defined(__AVR_ATtiny84__)
CLKPR = 0; // div 1, i.e. speed up to 8 MHz
#else
CLKPR = 1; // div 2, i.e. slow down to 8 MHz
#endif
sei();
#if defined(__AVR_ATtiny84__)
// power up the radio on JMv3
bitSet(DDRB, 0);
bitClear(PORTB, 0);
#endif
rf12_initialize(23, RF12_868MHZ, 212, 1615);
// rf12_initialize(23, RF12_868MHZ, 212, 1592);
// see http://tools.jeelabs.org/rfm12b
#if !RF69_COMPAT
rf12_control(0xC040); // set low-battery level to 2.2V i.s.o. 3.1V
#endif
}
void loop() {
++payload;
rf12_sendNow(0, &payload, sizeof payload);
// set the sync mode to 2 if the fuses are still the Arduino default
// mode 3 (full powerdown) can only be used with 258 CK startup fuses
rf12_sendWait(2);
rf12_sleep(RF12_SLEEP);
Sleepy::loseSomeTime(1000);
rf12_sleep(RF12_WAKEUP);
}
|