[CC1101] Updated examples

pull/38/head
jgromes 2019-06-02 14:09:10 +02:00
rodzic b3f228e207
commit 554f894adf
7 zmienionych plików z 140 dodań i 30 usunięć

Wyświetl plik

@ -1,15 +1,30 @@
/*
RadioLib CC1101 Receive Example
This example receives packets using CC1101 FSK radio
module.
This example receives packets using CC1101 FSK radio module.
To successfully receive data, the following settings have to be the same
on both transmitter and receiver:
- carrier frequency
- bit rate
- frequency deviation
- sync word
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// CC1101 is in slot A on the shield
CC1101 cc = RadioShield.ModuleA;
// CC1101 has the following connections:
// NSS pin: 10
// GDO0 pin: 2
// GDO2 pin: 3
CC1101 cc = new Module(10, 2, 3);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//CC1101 cc = RadioShield.ModuleA;
void setup() {
Serial.begin(9600);
@ -67,5 +82,10 @@ void loop() {
// packet was received, but is malformed
Serial.println(F("CRC error!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
}

Wyświetl plik

@ -6,13 +6,23 @@
destination node. After setting node address, this node
will automatically filter out any packets that do not
contain either node address or broadcast addresses.
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// CC1101 is in slot A on the shield
CC1101 cc = RadioShield.ModuleA;
// CC1101 has the following connections:
// NSS pin: 10
// GDO0 pin: 2
// GDO2 pin: 3
CC1101 cc = new Module(10, 2, 3);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//CC1101 cc = RadioShield.ModuleA;
void setup() {
Serial.begin(9600);
@ -102,5 +112,10 @@ void loop() {
// packet was received, but is malformed
Serial.println(F("CRC error!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
}

Wyświetl plik

@ -4,13 +4,30 @@
This example listens for FSK transmissions and tries to
receive them. Once a packet is received, an interrupt is
triggered.
To successfully receive data, the following settings have to be the same
on both transmitter and receiver:
- carrier frequency
- bit rate
- frequency deviation
- sync word
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// CC1101 module is in slot A on the shield
CC1101 cc = RadioShield.ModuleA;
// CC1101 has the following connections:
// NSS pin: 10
// GDO0 pin: 2
// GDO2 pin: 3
CC1101 cc = new Module(10, 2, 3);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//CC1101 cc = RadioShield.ModuleA;
void setup() {
Serial.begin(9600);
@ -113,6 +130,16 @@ void loop() {
// of the last received packet, lower is better
Serial.print(F("[CC1101] LQI:\t\t"));
Serial.println(cc.getLQI());
} else if (state == ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println(F("CRC error!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
// we're ready to receive more packets,

Wyświetl plik

@ -10,20 +10,23 @@
- allowed frequency deviation
- output power during transmission
- sync word
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// CC1101 module is in slot A on the shield
CC1101 cc1 = RadioShield.ModuleA;
// CC1101 has the following connections:
// NSS pin: 10
// GDO0 pin: 2
// GDO2 pin: 3
CC1101 cc1 = new Module(10, 2, 3);
// if you're not using RadioShield, you can specify
// the connection yourself
// NSS pin: 6
// DIO0 pin: 4
// DIO1 pin: 5
CC1101 cc2 = new Module(6, 4, 5);
// or using RadioShield
// https://github.com/jgromes/RadioShield
CC1101 cc2 = RadioShield.ModuleB;
void setup() {
Serial.begin(9600);

Wyświetl plik

@ -2,13 +2,27 @@
RadioLib CC1101 Transmit Example
This example transmits packets using CC1101 FSK radio module.
Each packet contains up to 64 bytes of data, in the form of:
- Arduino String
- null-terminated char array (C-string)
- arbitrary binary data (byte array)
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// CC1101 is in slot A on the shield
CC1101 cc = RadioShield.ModuleA;
// CC1101 has the following connections:
// NSS pin: 10
// GDO0 pin: 2
// GDO2 pin: 3
CC1101 cc = new Module(10, 2, 3);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//CC1101 cc = RadioShield.ModuleA;
void setup() {
Serial.begin(9600);
@ -50,6 +64,11 @@ void loop() {
// the supplied packet was longer than 255 bytes
Serial.println(F(" too long!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait for a second before transmitting again

Wyświetl plik

@ -6,13 +6,23 @@
destination node. After setting node address, this node
will automatically filter out any packets that do not
contain either node address or broadcast addresses.
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// CC1101 is in slot A on the shield
CC1101 cc = RadioShield.ModuleA;
// CC1101 has the following connections:
// NSS pin: 10
// GDO0 pin: 2
// GDO2 pin: 3
CC1101 cc = new Module(10, 2, 3);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//CC1101 cc = RadioShield.ModuleA;
void setup() {
Serial.begin(9600);
@ -86,6 +96,11 @@ void loop() {
// the supplied packet was longer than 255 bytes
Serial.println(F(" too long!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait for a second before transmitting again

Wyświetl plik

@ -1,19 +1,29 @@
/*
RadioLib CC1101 Transmit with Interrupts Example
This example transmits FSK packets with one second delays
between them. Each packet contains up to 64 bytes
of data, in the form of:
This example transmits packets using CC1101 FSK radio module.
Once a packet is transmitted, an interrupt is triggered.
Each packet contains up to 64 bytes of data, in the form of:
- Arduino String
- null-terminated char array (C-string)
- arbitrary binary data (byte array)
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// CC1101 module is in slot A on the shield
CC1101 cc = RadioShield.ModuleA;
// CC1101 has the following connections:
// NSS pin: 10
// GDO0 pin: 2
// GDO2 pin: 3
CC1101 cc = new Module(10, 2, 3);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//CC1101 cc = RadioShield.ModuleA;
void setup() {
Serial.begin(9600);
@ -34,7 +44,7 @@ void setup() {
while (true);
}
// set the function that will be called
// set the function that will be called
// when packet transmission is finished
cc.setGdo0Action(setFlag);
@ -51,10 +61,11 @@ void setup() {
0x78, 0xAB, 0xCD, 0xEF};
state = cc.transmit(byteArr, 8);
*/
if (state != ERR_NONE) {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
}
@ -69,7 +80,7 @@ void setFlag(void) {
void loop() {
// check if the previous transmission finished
if(transmittedFlag) {
Serial.println(F("[CC1101] Packet transmission finished!"));
Serial.println(F("packet transmission finished!"));
// wait one second before next transmission
delay(1000);
@ -80,14 +91,14 @@ void loop() {
// you can transmit C-string or Arduino string up to
// 64 characters long
int state = cc.startTransmit("Hello World!");
// you can also transmit byte array up to 256 bytes long
/*
byte byteArr[] = {0x01, 0x23, 0x45, 0x56,
0x78, 0xAB, 0xCD, 0xEF};
int state = cc.transmit(byteArr, 8);
*/
if (state != ERR_NONE) {
Serial.print(F("failed, code "));
Serial.println(state);