Feather accelerometer, RF transmitter, data logging project.
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Feather accelerometer, RF transmitter, data logging proj
That is a GPIO pin that is being used as the CS pin for talking to the on-board RFM. You need to choose another GPIO pin to use as a CS pin for talking to the FRAM.
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
Bill:
Thank you for answering my questions, I greatly appreciate you taking the time to respond. Despite you providing me with most of the necessary info earlier on in our discussion, I seemed to have asked similar questions time and time again. I just wanted to say thank you for your patience, and guidance.
Thank you for answering my questions, I greatly appreciate you taking the time to respond. Despite you providing me with most of the necessary info earlier on in our discussion, I seemed to have asked similar questions time and time again. I just wanted to say thank you for your patience, and guidance.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Feather accelerometer, RF transmitter, data logging proj
No problem. That is what we are here for. :)
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
Hello:
I'm beginning to set up the two pairs of Feather M0 RFM69HCWs I have to communicate with each other. And I'm slowly reading through the product overview in order to ensure I understand what is happening while initiating the example code for client/server.
Currently I'm wondering what this bit of code does?
// Singleton instance of the radio driver
RH_RF69 rf69;
//RH_RF69 rf69(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
Thanks
I'm beginning to set up the two pairs of Feather M0 RFM69HCWs I have to communicate with each other. And I'm slowly reading through the product overview in order to ensure I understand what is happening while initiating the example code for client/server.
Currently I'm wondering what this bit of code does?
// Singleton instance of the radio driver
RH_RF69 rf69;
//RH_RF69 rf69(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
Thanks
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
Also wondering if I should be using the reliable datagram to start with or just the simple server/client?
I'm guessing the server/client non-datagram examples would technically consume less power?
What's the best way to reduce power consumption while actively listening for an incoming transmission from the client?
I'm guessing the server/client non-datagram examples would technically consume less power?
What's the best way to reduce power consumption while actively listening for an incoming transmission from the client?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Feather accelerometer, RF transmitter, data logging proj
That declares an instance of the RH_RF69 radio driver called "rf69". rf69 is used later in the code for communication over the radio module.Currently I'm wondering what this bit of code does?
// Singleton instance of the radio driver
RH_RF69 rf69;
//RH_RF69 rf69(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
Not sure about how to do that with these particular modules. I'll check with one of our RF experts.What's the best way to reduce power consumption while actively listening for an incoming transmission from the client?
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
I'm having issues with compiling my code:
perhaps you can notice something I'm not?
I will mention again that I'm not an experienced coder. I'm using the server example included in the radiohead library, and following along with an example.. Just wondering if you have any tips!
Thank you!
perhaps you can notice something I'm not?
Code: Select all
#include <SPI.h>
#include <RH_RF69.h>
#define RF69_FREQ 915.0
#if defined (ADAFRUIT_SAMD_FEATHER_M0) // Feather M0 w/Radio
#define RFM69_CS 8
#define RFM69_INT 3
#define RFM69_RST 4
#define LED 13
#endif
// Singleton instance of the radio driver
RH_RF69 rf69(RFM69_CS, RFM69_INT);
void setup()
{
Serial.begin(115200);
//while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer
pinMode(LED, OUTPUT);
pinMode(RFM69_RST, OUTPUT);
digitalWrite(RFM69_RST, LOW);
Serial.println("Feather RFM69 RX Test!");
Serial.println();
// manual reset
digitalWrite(RFM69_RST, HIGH);
delay(10);
digitalWrite(RFM69_RST, LOW);
delay(10);
voidsetup()
{
Serial.begin(9600);
if (!rf69.init())
Serial.println("init failed");
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
// No encryption
if (!rf69.setFrequency(RF69_FREQ))
Serial.println("setFrequency failed");
// If you are using a high power RF69, you *must* set a Tx power in the
// range 14 to 20 like this:
// rf69.setTxPower(14);
// The encryption key has to be the same as the one in the client
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
rf69.setEncryptionKey(key);
#if 0
// For compat with RFM69 Struct_send
rf69.setModemConfig(RH_RF69::GFSK_Rb250Fd250);
rf69.setPreambleLength(3);
uint8_t syncwords[] = { 0x2d, 0x64 };
rf69.setSyncWords(syncwords, sizeof(syncwords));
rf69.setEncryptionKey((uint8_t*)"thisIsEncryptKey");
#endif
}
void loop()
{
if (rf69.available())
{
// Should be a message for us now
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf69.recv(buf, &len))
{
// RH_RF69::printBuffer("request: ", buf, len);
Serial.print("got request: ");
Serial.println((char*)buf);
// Serial.print("RSSI: ");
// Serial.println(rf69.lastRssi(), DEC);
// Send a reply
uint8_t data[] = "And hello back to you";
rf69.send(data, sizeof(data));
rf69.waitPacketSent();
Serial.println("Sent a reply");
}
else
{
Serial.println("recv failed");
}
}
}
Thank you!
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
Okay, I may be onto something..
When calling a pin for pinmode, I should be using the number to call the pin?
based on how I defined them here:
vs.
?
Thanks!
When calling a pin for pinmode, I should be using the number to call the pin?
based on how I defined them here:
Code: Select all
#if defined (ADAFRUIT_SAMD_FEATHER_M0) // Feather M0 w/Radio
#define RFM69_CS 8
#define RFM69_INT 3
#define RFM69_RST 4
#define LED 13
#endif
Code: Select all
pinMode(13, OUTPUT);
Code: Select all
pinMode(LED, OUTPUT);
?
Thanks!
- adafruit2
- Posts: 22148
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Feather accelerometer, RF transmitter, data logging proj
"What's the best way to reduce power consumption while actively listening for an incoming transmission from the client?"
there isnt really - active listening will take power. but not as much as transmission. the only way to really gauge power is with a power monitor, there's no way to know with just software
there isnt really - active listening will take power. but not as much as transmission. the only way to really gauge power is with a power monitor, there's no way to know with just software
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
Thanks..
Now, moving onto the coding.
Now, moving onto the coding.
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
I seem to have alleviated several error messages from my intitial code, but am now running into an error that I am unsure of how to deal with.
Error returns "a function-definition is not allowed here before "{" token"
I'm currently reviewing other online sources, but also wanted to reach out here.
Thanks in advance
Code: Select all
#include <SPI.h>
#include <RH_RF69.h>
#define RF69_FREQ 915.0
#if defined (ADAFRUIT_SAMD_FEATHER_M0) // Feather M0 w/Radio
#define RFM69_CS 8
#define RFM69_INT 3
#define RFM69_RST 4
#define LED 13
#endif
// Singleton instance of the radio driver
RH_RF69 rf69(8, 3);
void setup()
{
Serial.begin(115200);
//while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer
pinMode(13, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
Serial.println("Feather RFM69 RX Test!");
Serial.println();
// manual reset
digitalWrite(4, HIGH);
delay(10);
digitalWrite(4, LOW);
delay(10);
void setup()
{
Serial.begin(9600);
if (!rf69.init())
Serial.println("init failed");
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
// No encryption
if (!rf69.setFrequency(RF69_FREQ))
Serial.println("setFrequency failed");
// If you are using a high power RF69, you *must* set a Tx power in the
// range 14 to 20 like this:
// rf69.setTxPower(14);
// The encryption key has to be the same as the one in the client
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
rf69.setEncryptionKey(key);
#if 0
// For compat with RFM69 Struct_send
rf69.setModemConfig(RH_RF69::GFSK_Rb250Fd250);
rf69.setPreambleLength(3);
uint8_t syncwords[] = { 0x2d, 0x64 };
rf69.setSyncWords(syncwords, sizeof(syncwords));
rf69.setEncryptionKey((uint8_t*)"thisIsEncryptKey");
#endif
}
void loop()
{
if (rf69.available())
{
// Should be a message for us now
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf69.recv(buf, &len))
{
// RH_RF69::printBuffer("request: ", buf, len);
Serial.print("got request: ");
Serial.println((char*)buf);
// Serial.print("RSSI: ");
// Serial.println(rf69.lastRssi(), DEC);
// Send a reply
uint8_t data[] = "And hello back to you";
rf69.send(data, sizeof(data));
rf69.waitPacketSent();
Serial.println("Sent a reply");
}
else
{
Serial.println("recv failed");
}
}
}
I'm currently reviewing other online sources, but also wanted to reach out here.
Thanks in advance
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Feather accelerometer, RF transmitter, data logging proj
Looks like you are trying to define a second 'setup()' function - starting in the middle of the first one.
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
I've simply copied/pasted an example code and am running into numerous errors.
I've followed the example from the product overview, which is different from the examples in the radiohead library, and still cannot get the code to compile..
Can you offer any suggestions to help with the debugging process?
I've followed the example from the product overview, which is different from the examples in the radiohead library, and still cannot get the code to compile..
Code: Select all
// rf69_server.pde
// -*- mode: C++ -*-
void setup() {
#include <SPI.h>
#include <RH_RF69.h>
#define RF69_FREQ 915.0
#if defined (ADAFRUIT_FEATHER_M0) // Feather M0 w/Radio
#define RFM69_CS 8
#define RFM69_INT 3
#define RFM69_RST 4
#define LED 13
#endif
// Singleton instance of the radio driver
//RH_RF69 rf69(8, 3);
Serial.begin(115200);
//while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer
pinMode(13, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
Serial.println("Feather RFM69 RX Test!");
Serial.println();
// manual reset
digitalWrite(4, HIGH);
delay(10);
digitalWrite(4, LOW);
delay(10);
}
Serial.begin(115200);
// The encryption key has to be the same as the one in the client
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
rf69.setEncryptionKey(key);
#if 0
// For compat with RFM69 Struct_send
rf69.setModemConfig(RH_RF69::GFSK_Rb250Fd250);
rf69.setPreambleLength(3);
uint8_t syncwords[] = { 0x2d, 0x64 };
rf69.setSyncWords(syncwords, sizeof(syncwords));
rf69.setEncryptionKey((uint8_t*)"thisIsEncryptKey");
#endif
}
void loop()
{
if (rf69.available())
{
// Should be a message for us now
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf69.recv(buf, &len))
{
// RH_RF69::printBuffer("request: ", buf, len);
Serial.print("got request: ");
Serial.println((char*)buf);
// Serial.print("RSSI: ");
// Serial.println(rf69.lastRssi(), DEC);
// Send a reply
uint8_t data[] = "And hello back to you";
rf69.send(data, sizeof(data));
rf69.waitPacketSent();
Serial.println("Sent a reply");
}
else
{
Serial.println("recv failed");
}
}
}
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Feather accelerometer, RF transmitter, data logging proj
You now have your #includes inside your setup() function. And a bunch of code between your setup() and your loop() that is not associated with any function at all.
You can't just paste random bits of code anywhere. Programs need to adhere to the rules of the language. The curly braces { } define the scope of functions and blocks of code.. For every '{' you need a matching '}'.
http://www.cplusplus.com/doc/tutorial/functions/
You can't just paste random bits of code anywhere. Programs need to adhere to the rules of the language. The curly braces { } define the scope of functions and blocks of code.. For every '{' you need a matching '}'.
http://www.cplusplus.com/doc/tutorial/functions/
- wahleworld
- Posts: 45
- Joined: Sun Nov 11, 2018 12:50 am
Re: Feather accelerometer, RF transmitter, data logging proj
I've tried to follow along with other examples, and have ran into countless errors.
I will start over, again, and get back to you..
So I should have my void setup() function below the libraries included?
I will start over, again, and get back to you..
So I should have my void setup() function below the libraries included?
Please be positive and constructive with your questions and comments.