From b6e90912967d95d2832accebedc768131acd6911 Mon Sep 17 00:00:00 2001 From: franchioping Date: Fri, 27 Jun 2025 18:02:35 +0100 Subject: [PATCH] test --- recv/recv.ino | 6 +++--- sens/sens.ino | 50 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/recv/recv.ino b/recv/recv.ino index 30b2037..a19ad24 100644 --- a/recv/recv.ino +++ b/recv/recv.ino @@ -116,7 +116,7 @@ void loop() { */ char* data_string = (char*) malloc(radio.DATALEN+1); if(data_string != NULL){ - memcpy(data_string, radio, radio.DATALEN); + memcpy(data_string, radio.DATA, radio.DATALEN); data_string[radio.DATALEN] = '\0'; Serial.println(data_string); @@ -137,9 +137,9 @@ void loop() { uptime is included to help with data analasys */ theData = *(transData*) radio.DATA; - Serial.print(" temperature="); + Serial.print(" temperature:"); Serial.print(theData.temperature); - Serial.print(" pressure="); + Serial.print(" pressure:"); Serial.print(theData.pressure); Serial.print(" time="); Serial.print(theData.time); diff --git a/sens/sens.ino b/sens/sens.ino index bd5a7d7..b4475c1 100644 --- a/sens/sens.ino +++ b/sens/sens.ino @@ -2,8 +2,15 @@ #include #include + +#define CJKIT_VERSION 2 +#include + #define DALLASPIN 4 +OneWire ds(DALLASPIN); + + #define NODEID 2 #define NETWORKID 100 #define GATEWAYID 1 //as a rule of thumb the gateway ID should always be 1 @@ -11,10 +18,11 @@ #define INIT_RETRIES 10 +const uint32_t RADIO_FREQUENCY = 433000000; // Hz + RFM69 radio; void init_radio_failsafe(); -OneWire ds(DALLASPIN); void init_temperature_failsafe(); bool init_temperature(); float get_temperature(); @@ -52,6 +60,10 @@ void(* resetFunc) (void) = 0; void setup() { Serial.begin(9600); + + + pinMode(5, OUTPUT); // set pin to input + init_pressure_failsafe(); @@ -62,7 +74,7 @@ void setup() { void loop() { - /* + /*ss Load all of our data into the struct, Don't allocate/free everytime for performace */ @@ -83,7 +95,11 @@ void loop() { */ Serial.print("SENDING..."); radio.send(GATEWAYID, (const void *)&TransmissionData, sizeof(TransmissionData)); + digitalWrite(5, HIGH); + delay(10); + digitalWrite(5, LOW); Serial.println("SENT!"); + delay(40); } @@ -136,6 +152,7 @@ float get_pressure(){ */ + float get_temperature(){ int16_t temp; @@ -217,6 +234,7 @@ bool init_temperature() return true; } + void init_temperature_failsafe(){ /* Temperature sensor sometimes doesnt like to work (when it's pushed around and doen't make contact) @@ -239,6 +257,8 @@ void init_temperature_failsafe(){ /* RF69 (Communication) */ void init_radio_failsafe(){ + + /* Set Chip-Select pin for the radio. The RF69 uses the SPI interface for communication so each chip requires its own chip-select @@ -247,29 +267,20 @@ void init_radio_failsafe(){ /* Set the Interrupt pin for the radio - Connected to DIO0 (Digital IO 0). - This pin is programmed as an interrupt for receive data by the RFM69 library + This pin is programmed as an interrupt for recieving data by the RFM69 library All other interrupts are programatically disabled so we only need to set this one - BUUUT we don't actually need it at all, since were just sending without ACKs (acknowledgements) there's no need to receive data */ radio.setIrq(3); - bool sucess = false; - for(int i = 0; i < INIT_RETRIES; i++){ - sucess = radio.initialize(FREQUENCY,NODEID,NETWORKID); - if(sucess){ - Serial.print("RF69 initialized succesfully on attempt "); - Serial.println(i); - break; - } - delay(50); - } - - + /* + Initializes radio and returns 1 if it is successful + */ + bool sucess = radio.initialize(FREQUENCY,NODEID,NETWORKID); radio.setHighPower(); - - + Serial.print("RADIO INITIALIZE: "); + Serial.println(sucess); } @@ -277,3 +288,6 @@ void init_radio_failsafe(){ + + +