/* Test RFBee - by Ariel Rocholl, March 2011 An example of a transmitting RFBee from www.SeeedStudio.com being monitored with a RF Explorer Spectrum Analyzer from www.rf-explorer.com Requirements: You will need a Seeeduino Stalker v2.0b to connect a RFBee into it. Alternatively, you can do the same with an Arduino compatible board but will have to connect the RFBee with RX/TX of the CPU using a XBee 2mm connector. For Stalker 2.0b, be sure to use "Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328" or go to this thread http://www.seeedstudio.com/forum/viewtopic.php?f=4&t=1840&p=6159#p6159 for more info, if you select standard Arduino at 16Mhz the baud speed will be half the one expected, and therefore the RFBee and Stalker won't talk each other. If you use a different board than a Stalker 2.0b or use a different bootloader, be sure to select the right board at right speed for the 9600bauds to work. How does it work: Upload the script in the stalker with a RFBee unit, and check with your RF Explorer how signal is detected in either 915Mhz or 868Mhz depending on your RFExplorer unit. Uncomment code below based on that. Power off the unit completely so both ATMegas (stalker and RFBee) resets at the same time. Power the unit back, it will start transmission after led blinks 6 times. RFExplorer will show transmitter power and frequency. Play with antenna orientation till you get the best power response. This example code is in the public domain, license under Creative Commons Attribution-NonCommercial-ShareAlike License 3.0 Any question or comment go to http://groups.google.com/group/rf-explorer */ const int pin_SW1 = 2; const int pin_SW2 = 3; void setup() { // initialize digital pins pinMode(8, OUTPUT); // Pin 8 has an LED connected on stalker v2.0b pinMode(pin_SW1, INPUT); pinMode(pin_SW2, INPUT); digitalWrite(pin_SW1,HIGH); //Enable internall pullup digitalWrite(pin_SW2,HIGH); //Enable internall pullup //flash led to signal the board started up for (int nInd=0; nInd<6; nInd++) { digitalWrite(8, HIGH); // set the LED on delay(50); // wait for a second digitalWrite(8, LOW); // set the LED off delay(50); // wait for a second } Serial.begin(9600); //be sure to select Arduino board with "Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328" //Start control mode Serial.print("+++\r"); delay(40); //Read firmware version (should be 1.1) Serial.print("ATFV\r"); delay(10); //Read HW version (should be 1.0) Serial.print("ATHV\r"); delay(10); //Read current baud setting (should be 0=9600bps) Serial.print("ATBD\r"); delay(10); //If pin_SW1 is connected to GND when booting, then use low speed GFSK, otherwise high speed FSK //IMPORTANT: change it to values commented out below if you are using a 868M RFExplorer if (digitalRead(pin_SW1)==HIGH) { Serial.print("ATCF0\r"); //default 915 Mhz, 76,8 Kbps, 2-FSK //Serial.print("ATCF3\r"); //default 868 Mhz, 76,8 Kbps, 2-FSK delay(10); } else { Serial.print("ATCF1\r"); //915 Mhz, 4.8 Kbps, GFSK, sensitivity //Serial.print("ATCF4\r"); //868 Mhz, 4.8 Kbps, GFSK, sensitivity delay(10); } //Go back to data mode Serial.print("ATO0\r"); } void loop() { //Transmit 0 or 1 based on pin_SW1 switch status if (digitalRead(pin_SW1)==HIGH) { if (digitalRead(pin_SW2)==HIGH) { digitalWrite(8, HIGH); //set the LED on Serial.write(byte(0xFF)); //Send all 1 } else { digitalWrite(8, LOW); //alternate led so we dim it Serial.write(byte(0x55)); //Send alternate 0 and 1 digitalWrite(8, HIGH); //alternate led so we dim it } } else { digitalWrite(8, LOW); //set the LED off Serial.write(byte(0x00)); //Send all 0 } }