/Designs/duckweed_collector/SW/RF01/RF01.pde
1,22 → 1,19
/*
connections arduino RF01 and RF02
RF02 TX sample for Arduino
 
in arduino version 018
(not yet tested in more recent arduino versions)
in arduino version 022
 
tested with ATmega 328
on frequency 433
 
no range test done yet, just in one room
tested with MLAB modules with ATmega 328 at 16MHz
see RF02 library for a Band and Frequency
*/
 
//connections RF01: (receiving)
#define SDI 5 // RF01 SDI, arduino 13, ATmega PB5, cannot be changed
#define SCK 4 // RF01 SCK, arduino 12, ATmega PB4, cannot be changed
#define CS 3 // RF01 nSEL, arduino 11, ATmega PB3, cannot be changed
#define SDO 2 // RF01 SDO, arduino 10, ATmega PB2, cannot be changed
//--------------------- // RF01 niRQ, arduino 02, ATmega PD2, cannot be changed
//----------------------// RF01 nFFS: 1-10k Pullup too Vcc
//connections RF01: (RX)
// RF01 SDI, arduino 13, ATmega PB5, cannot be changed
// RF01 SCK, arduino 12, ATmega PB4, cannot be changed
// RF01 nSEL, arduino 11, ATmega PB3, cannot be changed
// RF01 SDO, arduino 10, ATmega PB2, cannot be changed
// RF01 niRQ, arduino 02, ATmega PD2, cannot be changed
// RF01 nFFS: 1-10k Pullup too Vcc
 
 
// receiving words with RF01
23,32 → 20,26
 
#include <RF01.h>
 
int serialTesting = 1;
 
void setup() {
void setup()
{
Serial.begin(9600);
Serial.println("\nRF02 receive");
Serial.println("\nRFM01 init");
delay(250);
 
rf01_prepAll();
 
delay(250);
Serial.println("startup");
Serial.println("done");
}
 
void loop() {
void loop()
{
int n;
// unsigned char buf[] = { "$00\n" }; // Motor, Rudder
for(n=0;n<32;n++) rf01_data[n]='$';
rf01_receive();
char* buf = (char*) rf01_data;
buf[31]=0;
//if ((buf[0]=='$')&&(buf[3]=='\n'))
char* buf = (char*) _rx_buffer;
 
rf01_rxdata(_rx_buffer, 10);
buf[11]=0;
 
Serial.println(buf);
for(n=0;n<32;n++) {Serial.print(rf01_data[n], HEX); Serial.print(' ');}
for(n=0;n<32;n++) {Serial.print(buf[n], HEX); Serial.print(' ');}
Serial.println();
 
delay(10);
}