Line 1... |
Line 1... |
1 |
/* |
1 |
/* |
2 |
connections arduino RF01 and RF02 |
2 |
RF02 TX sample for Arduino |
3 |
|
3 |
|
4 |
in arduino version 018 |
4 |
in arduino version 022 |
5 |
(not yet tested in more recent arduino versions) |
- |
|
6 |
|
5 |
|
7 |
tested with ATmega 328 |
6 |
tested with MLAB modules with ATmega 328 at 16MHz |
8 |
on frequency 433 |
- |
|
9 |
|
- |
|
10 |
no range test done yet, just in one room |
7 |
see RF02 library for a Band and Frequency |
11 |
*/ |
8 |
*/ |
12 |
|
9 |
|
13 |
//connections RF01: (receiving) |
10 |
//connections RF01: (RX) |
14 |
#define SDI 5 // RF01 SDI, arduino 13, ATmega PB5, cannot be changed |
11 |
// RF01 SDI, arduino 13, ATmega PB5, cannot be changed |
15 |
#define SCK 4 // RF01 SCK, arduino 12, ATmega PB4, cannot be changed |
12 |
// RF01 SCK, arduino 12, ATmega PB4, cannot be changed |
16 |
#define CS 3 // RF01 nSEL, arduino 11, ATmega PB3, cannot be changed |
13 |
// RF01 nSEL, arduino 11, ATmega PB3, cannot be changed |
17 |
#define SDO 2 // RF01 SDO, arduino 10, ATmega PB2, cannot be changed |
14 |
// RF01 SDO, arduino 10, ATmega PB2, cannot be changed |
18 |
//--------------------- // RF01 niRQ, arduino 02, ATmega PD2, cannot be changed |
15 |
// RF01 niRQ, arduino 02, ATmega PD2, cannot be changed |
19 |
//----------------------// RF01 nFFS: 1-10k Pullup too Vcc |
16 |
// RF01 nFFS: 1-10k Pullup too Vcc |
20 |
|
17 |
|
21 |
|
18 |
|
22 |
// receiving words with RF01 |
19 |
// receiving words with RF01 |
23 |
|
20 |
|
24 |
#include <RF01.h> |
21 |
#include <RF01.h> |
25 |
|
22 |
|
26 |
int serialTesting = 1; |
- |
|
27 |
|
- |
|
28 |
void setup() { |
23 |
void setup() |
29 |
|
24 |
{ |
30 |
Serial.begin(9600); |
25 |
Serial.begin(9600); |
31 |
Serial.println("\nRF02 receive"); |
26 |
Serial.println("\nRFM01 init"); |
32 |
delay(250); |
27 |
delay(250); |
33 |
|
28 |
|
34 |
rf01_prepAll(); |
29 |
rf01_prepAll(); |
35 |
|
30 |
|
36 |
delay(250); |
- |
|
37 |
Serial.println("startup"); |
31 |
Serial.println("done"); |
38 |
} |
32 |
} |
39 |
|
33 |
|
40 |
void loop() { |
34 |
void loop() |
- |
|
35 |
{ |
41 |
int n; |
36 |
int n; |
42 |
// unsigned char buf[] = { "$00\n" }; // Motor, Rudder |
37 |
char* buf = (char*) _rx_buffer; |
43 |
for(n=0;n<32;n++) rf01_data[n]='$'; |
- |
|
- |
|
38 |
|
44 |
rf01_receive(); |
39 |
rf01_rxdata(_rx_buffer, 10); |
45 |
char* buf = (char*) rf01_data; |
- |
|
46 |
buf[31]=0; |
40 |
buf[11]=0; |
47 |
//if ((buf[0]=='$')&&(buf[3]=='\n')) |
- |
|
- |
|
41 |
|
48 |
Serial.println(buf); |
42 |
Serial.println(buf); |
49 |
for(n=0;n<32;n++) {Serial.print(rf01_data[n], HEX); Serial.print(' ');} |
43 |
for(n=0;n<32;n++) {Serial.print(buf[n], HEX); Serial.print(' ');} |
50 |
Serial.println(); |
44 |
Serial.println(); |
51 |
|
- |
|
52 |
delay(10); |
- |
|
53 |
|
- |
|
54 |
} |
45 |
} |