That's the part I don't understand and am trying to learn more as to how these function. It obviously is some kind of timing function. Here's my code. The first one is the hive node. My base has 3 tabs, the main sketch is "Hive_base_7", the is a display control tab, "display_cntrl" and the tab that reads the network, "readHive" I couldn't post the complete code as it exceeded the max length to I've just put the function that reads the network
Thanks
Hive node
// Hive 1 transmitter, reads BME280 for temp and pressure and battery voltage
// added RF24nework
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24Network.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C
RF24 radio(7, 8); // 10, 9 CE, CSN
RF24Network network(radio); // Include the radio in the network
const uint16_t this_node = 01; // Address of this node in Octal format ( 04,031, etc)
const uint16_t base_node = 00; // Address of base node
float c_Temp = 0; // temp in C' from BMP280
int batt_In = A0; // Battery circuit divider input
float batt_V = 0; // battery voltage
float batt_Map = 0;
long int start_delay = 0; // start of delay time
long int write_time = 5000; // time between writes to base
struct dataStruct {
float f_Temp;
float H1_Prss;
float H1_Humd;
float H1_Batt;
}myDataStructure;
void setup() {
Serial.begin(9600);
Serial.println(F("Bee Hive 1"));
// Initialise NRF24L01
radio.begin();
radio.setDataRate(RF24_1MBPS);
radio.setChannel(124);
radio.setPALevel(RF24_PA_MIN);
// Open a writing and reading pipe on each radio, with opposite addresses
// radio.openWritingPipe(this_node);
// radio.openReadingPipe(1, base_node);
radio.stopListening();
network.begin(124,this_node); //(channel, node address)
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
} // end if (!bmp.begin())
start_delay = millis();
} // end void setup
void loop() {
network.update();
/* if(!network.available()){
Serial.println("N0 network");
}
*/
// Read BME280
c_Temp = bme.readTemperature(); // read temp from BME280
myDataStructure.f_Temp = (c_Temp * 9/5) + 32; // calculate F'
myDataStructure.H1_Prss = (bme.readPressure() / 3389.39);
myDataStructure.H1_Humd = bme.readHumidity();
batt_V = analogRead(batt_In); // read battery voltage
// batt_Map = (map(batt_V, 0, 1025, 0, 500));
myDataStructure.H1_Batt = batt_Map / 100;
if(millis() > (start_delay + write_time)){
RF24NetworkHeader header(base_node); // (Address where the data is going)
network.write(header, &myDataStructure, sizeof(myDataStructure)); // send string to base
batt_Map ++;
Serial.print("Temperature = ");
Serial.print(myDataStructure.f_Temp);
Serial.println("*F");
Serial.print("Pressure = ");
Serial.print(myDataStructure.H1_Prss);
Serial.println(" inHg");
Serial.print("Humidity = ");
Serial.print(myDataStructure.H1_Humd);
Serial.println("%");
Serial.print("Battery = ");
Serial.print(myDataStructure.H1_Batt);
Serial.println(" V");
Serial.println();
start_delay = millis();
} // end if(millis() >
} // end void loop
Read Hive Node
void readHive()
{
if(network.available()){
network.read(header, &myDataStructure,sizeof(myDataStructure));
showParsedData(); // Send data to serial monitor
} // end if(network.available())
/* if(!network.available()){
Serial.println("N0 network");
}
*/
} // end void readHive
void showParsedData() { // print to serial monitor
// Write the results to the serial port
Serial.print(myDataStructure.f_Temp); Serial.print(",");
Serial.print(myDataStructure.H1_Prss); Serial.print(",");
Serial.print(myDataStructure.H1_Humd); Serial.print(",");
Serial.println(myDataStructure.H1_Batt);
// convert temp reading to string for display printing
dtostrf(myDataStructure.f_Temp, 5, 2, temp_str);
strcat(temp_str, " 'F"); // add units to end of string
// convert Humidity reading to string for display printing
dtostrf(myDataStructure.H1_Humd, 5, 2, humd_str);
strcat(humd_str, " %RH"); // add units to end of string
// convert Pressure reading to string for display printing
dtostrf(myDataStructure.H1_Prss, 5, 2, prss_str);
strcat(prss_str, " InHg"); // add units to end of string
// convert Battery reading to string for display printing
dtostrf(myDataStructure.H1_Batt, 5, 2, batt_str);
strcat(batt_str, " V"); // add units to end of string
} // end showparsedData