Ligne 88 : |
Ligne 88 : |
| #include <RH_RF69.h> | | #include <RH_RF69.h> |
| </syntaxhighlight> | | </syntaxhighlight> |
| + | |
| + | Then, it defines the parameters for the radio module and the pinout used to wire the RFM69HCW radio module depending on the board used. |
| + | |
| + | The last line create the object {{fname|rf69}} to control the module. |
| | | |
| <syntaxhighlight lang="c"> | | <syntaxhighlight lang="c"> |
Ligne 106 : |
Ligne 110 : |
| #endif | | #endif |
| | | |
− | #if defined (__AVR_ATmega328P__) // Feather 328P w/wing | + | #if defined (__AVR_ATmega328P__) // Feather 328P w/wing (or Arduino UNO) |
| #define RFM69_INT 3 // | | #define RFM69_INT 3 // |
| #define RFM69_CS 4 // | | #define RFM69_CS 4 // |
Ligne 126 : |
Ligne 130 : |
| #define LED 13 | | #define LED 13 |
| #endif | | #endif |
− |
| |
− | /* Teensy 3.x w/wing
| |
− | #define RFM69_RST 9 // "A"
| |
− | #define RFM69_CS 10 // "B"
| |
− | #define RFM69_IRQ 4 // "C"
| |
− | #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ )
| |
− | */
| |
− |
| |
− | /* WICED Feather w/wing
| |
− | #define RFM69_RST PA4 // "A"
| |
− | #define RFM69_CS PB4 // "B"
| |
− | #define RFM69_IRQ PA15 // "C"
| |
− | #define RFM69_IRQN RFM69_IRQ
| |
− | */
| |
| | | |
| // Singleton instance of the radio driver | | // Singleton instance of the radio driver |
| RH_RF69 rf69(RFM69_CS, RFM69_INT); | | RH_RF69 rf69(RFM69_CS, RFM69_INT); |
| </syntaxhighlight> | | </syntaxhighlight> |
| + | |
| + | The {{fname|setup()}} function: |
| + | * initialize the serial connexion @ 115200 bauds |
| + | * initialze the radio module |
| | | |
| <syntaxhighlight lang="c"> | | <syntaxhighlight lang="c"> |
− | int16_t packetnum = 0; // packet counter, we increment per xmission
| + | void setup() { |
− | void setup() | |
− | { | |
| Serial.begin(115200); | | Serial.begin(115200); |
− | //while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer
| |
| | | |
| pinMode(LED, OUTPUT); | | pinMode(LED, OUTPUT); |
Ligne 176 : |
Ligne 167 : |
| } | | } |
| | | |
− | // If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the | + | // When using High Power RF69, RFM69HW then the Tx power ishighpowermodule |
− | // ishighpowermodule flag set like this: | + | // flag MUST be with to TRUE |
− | rf69.setTxPower(20, true); // range from 14-20 for power, 2nd arg must be true for 69HCW | + | rf69.setTxPower(20, true); // Power range 14-20 |
| | | |
| // The encryption key has to be the same as the one in the server | | // The encryption key has to be the same as the one in the server |
Ligne 192 : |
Ligne 183 : |
| } | | } |
| </syntaxhighlight> | | </syntaxhighlight> |
| + | |
| + | xxxx |
| | | |
| <syntaxhighlight lang="c"> | | <syntaxhighlight lang="c"> |