Added function to initialize radio module along with defines for settings limits.

This commit is contained in:
jakeg00dwin 2024-09-25 11:32:50 -07:00
parent ad48a00b03
commit 41afd00ca1
1 changed files with 34 additions and 0 deletions

View File

@ -36,6 +36,15 @@ TinyGPSPlus gps; // TinyGPS++ object to process GPS data
#define RFM95_INT 7
#define RFM95_RST 4
#define RF95_FREQ 915.0
#define RF95_MAX_DB 23
#define RF95_MIN_DB 5
RH_RF95 rf95(RFM95_CS, RMF95_INT); // Radio instance.
typedef struct NodeId{
uint8_t id;
String name;
}NodeId
// Variables
@ -43,6 +52,31 @@ static int prevHeading = -1; // Store previous heading to avoid frequent
unsigned long lastUpdate = 0; // Time tracking for updates
const int updateInterval = 500; // Update interval in milliseconds (500ms = 0.5s)
void radio_setup(void) {
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
while(!rf95.init()){}
Serial.println("radio: Initialized");
if(rf95.setFrequency(RF95_FREQ)) {
Serial.println("radio: Error could not set frequency");
while(true){} //Loop forever
}
Serial.print("radio: Frequency = ");
Serial.println(RF95_FREQ);
rf95.setTxPower(RF95_MIN_DB, false);
}
void radio_reset(void) {
digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);
}
void setup(void) {
// Initialize Serial Communication for debugging
Serial.begin(115200);