Removed Datareading.h file and transferred sensor definitions to default.h

pull/8/head
sensorsiot 2 years ago
parent 99a29a3f1e
commit f165cfd20e

@ -11,15 +11,25 @@
#include <FDRSdefaults.h>
#include "fdrs_sensor.h"
float data1 = 42.069;
float data2 = 21.0345;
float data1;
float data2;
void setup() {
beginFDRS();
}
void loop() {
data1 = readHum();
loadFDRS(data1, HUMIDITY_T);
data2 = readTemp();
loadFDRS(data2, TEMP_T);
sendFDRS();
sleepFDRS(10); //Sleep time in seconds
}
float readTemp() {
return 42.069;
}
float readHum() {
return 21.0345;
}

@ -4,58 +4,7 @@
//
// Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA.
//
#include <FDRSdefaults.h>
#define ROLE LORA_SENSOR
#define READING_ID 1 //Unique ID for this sensor
#define GTWY_MAC 0x00 //Address of the nearest gateway
//#define USE_ESPNOW
#define USE_LORA
#define DEEP_SLEEP
//#define POWER_CTRL 14
#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE
//LoRa Configuration
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26
typedef struct __attribute__((packed)) DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
#define STATUS_T 0 // Status
#define TEMP_T 1 // Temperature
#define TEMP2_T 2 // Temperature #2
#define HUMIDITY_T 3 // Relative Humidity
#define PRESSURE_T 4 // Atmospheric Pressure
#define LIGHT_T 5 // Light (lux)
#define SOIL_T 6 // Soil Moisture
#define SOIL2_T 7 // Soil Moisture #2
#define SOILR_T 8 // Soil Resistance
#define SOILR2_T 9 // Soil Resistance #2
#define OXYGEN_T 10 // Oxygen
#define CO2_T 11 // Carbon Dioxide
#define WINDSPD_T 12 // Wind Speed
#define WINDHDG_T 13 // Wind Direction
#define RAINFALL_T 14 // Rainfall
#define MOTION_T 15 // Motion
#define VOLTAGE_T 16 // Voltage
#define VOLTAGE2_T 17 // Voltage #2
#define CURRENT_T 18 // Current
#define CURRENT2_T 19 // Current #2
#define IT_T 20 // Iterations
#include "sensor_setup.h"
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <espnow.h>
@ -69,6 +18,13 @@ typedef struct __attribute__((packed)) DataReading {
#include <LoRa.h>
#endif
typedef struct __attribute__((packed)) DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
const uint16_t espnow_size = 250 / sizeof(DataReading);
uint8_t gatewayAddress[] = {MAC_PREFIX, GTWY_MAC};
uint8_t gtwyAddress[] = {gatewayAddress[3], gatewayAddress[4], GTWY_MAC};

@ -0,0 +1,16 @@
#define READING_ID 1 //Unique ID for this sensor
#define GTWY_MAC 0x00 //Address of the nearest gateway
//#define USE_ESPNOW
#define USE_LORA
#define DEEP_SLEEP
//#define POWER_CTRL 14
//LoRa Configuration
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

@ -0,0 +1,16 @@
#define READING_ID 2 //Unique ID for this sensor
#define GTWY_MAC 0x01 //Address of the nearest gateway
#define USE_ESPNOW
//#define USE_LORA
#define DEEP_SLEEP
//#define POWER_CTRL 14
//#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE
//LoRa Configuration
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

@ -4,52 +4,7 @@
//
// Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA.
//
#define READING_ID 2 //Unique ID for this sensor
#define GTWY_MAC 0x01 //Address of the nearest gateway
#define USE_ESPNOW
//#define USE_LORA
#define DEEP_SLEEP
//#define POWER_CTRL 14
//#define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE
//LoRa Configuration
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26
typedef struct __attribute__((packed)) DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
#define STATUS_T 0 // Status
#define TEMP_T 1 // Temperature
#define TEMP2_T 2 // Temperature #2
#define HUMIDITY_T 3 // Relative Humidity
#define PRESSURE_T 4 // Atmospheric Pressure
#define LIGHT_T 5 // Light (lux)
#define SOIL_T 6 // Soil Moisture
#define SOIL2_T 7 // Soil Moisture #2
#define SOILR_T 8 // Soil Resistance
#define SOILR2_T 9 // Soil Resistance #2
#define OXYGEN_T 10 // Oxygen
#define CO2_T 11 // Carbon Dioxide
#define WINDSPD_T 12 // Wind Speed
#define WINDHDG_T 13 // Wind Direction
#define RAINFALL_T 14 // Rainfall
#define MOTION_T 15 // Motion
#define VOLTAGE_T 16 // Voltage
#define VOLTAGE2_T 17 // Voltage #2
#define CURRENT_T 18 // Current
#define CURRENT2_T 19 // Current #2
#define IT_T 20 // Iterations
#include "sensor_setup.h"
#if defined(ESP8266)
#include <ESP8266WiFi.h>
@ -64,6 +19,13 @@ typedef struct __attribute__((packed)) DataReading {
#include <LoRa.h>
#endif
typedef struct __attribute__((packed)) DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
const uint16_t espnow_size = 250 / sizeof(DataReading);
uint8_t gatewayAddress[] = {MAC_PREFIX, GTWY_MAC};
uint8_t gtwyAddress[] = {gatewayAddress[3], gatewayAddress[4], GTWY_MAC};

@ -12,7 +12,6 @@
#include <FDRSdefaults.h>
#include "fdrs_config.h"
#include "DataReading.h"
#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <espnow.h>

@ -1,29 +0,0 @@
typedef struct __attribute__((packed)) DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
//Type definitions in progress:
#define STATUS_T 0 // Status
#define TEMP_T 1 // Temperature
#define TEMP2_T 2 // Temperature #2
#define HUMIDITY_T 3 // Relative Humidity
#define PRESSURE_T 4 // Atmospheric Pressure
#define LIGHT_T 5 // Light (lux)
#define SOIL_T 6 // Soil Moisture
#define SOIL2_T 7 // Soil Moisture #2
#define OXYGEN_T 8 // Oxygen
#define CO2_T 9 // Carbon Dioxide
#define WINDSPD_T 10 // Wind Speed
#define WINDHDG_T 11 // Wind Direction
#define RAINFALL_T 12 // Rainfall
#define MOTION_T 13 // Motion
#define VOLTAGE_T 14 // Voltage
#define VOLTAGE2_T 15 // Voltage #2
#define CURRENT_T 16 // Current
#define CURRENT2_T 17 // Current #2
#define IT_T 18 // Iterations

@ -4,6 +4,13 @@
#define DBG(a)
#endif
typedef struct __attribute__((packed)) DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
const uint8_t espnow_size = 250 / sizeof(DataReading);
const uint8_t lora_size = 256 / sizeof(DataReading);
const uint8_t mac_prefix[] = {MAC_PREFIX};

@ -11,7 +11,6 @@
#include <FDRSdefaults.h>
#include "fdrs_config.h"
#include "DataReading.h"
#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <espnow.h>

@ -1,29 +0,0 @@
typedef struct __attribute__((packed)) DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
//Type definitions in progress:
#define STATUS_T 0 // Status
#define TEMP_T 1 // Temperature
#define TEMP2_T 2 // Temperature #2
#define HUMIDITY_T 3 // Relative Humidity
#define PRESSURE_T 4 // Atmospheric Pressure
#define LIGHT_T 5 // Light (lux)
#define SOIL_T 6 // Soil Moisture
#define SOIL2_T 7 // Soil Moisture #2
#define OXYGEN_T 8 // Oxygen
#define CO2_T 9 // Carbon Dioxide
#define WINDSPD_T 10 // Wind Speed
#define WINDHDG_T 11 // Wind Direction
#define RAINFALL_T 12 // Rainfall
#define MOTION_T 13 // Motion
#define VOLTAGE_T 14 // Voltage
#define VOLTAGE2_T 15 // Voltage #2
#define CURRENT_T 16 // Current
#define CURRENT2_T 17 // Current #2
#define IT_T 18 // Iterations

@ -11,9 +11,6 @@
//Actions -- Define what happens when a packet arrives at each interface:
//Current function options are: sendESPNOW(MAC), sendSerial(), sendMQTT(), bufferESPNOW(interface), bufferSerial(), and bufferLoRa(interface).
#define DEBUG
#define CREDENTIALS
#define ESPNOWG_ACT sendSerial();
#define SERIAL_ACT
#define MQTT_ACT

@ -1,3 +1,16 @@
#ifdef DEBUG
#define DBG(a) (Serial.println(a))
#else
#define DBG(a)
#endif
typedef struct __attribute__((packed)) DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
const uint8_t espnow_size = 250 / sizeof(DataReading);
const uint8_t lora_size = 256 / sizeof(DataReading);
const uint8_t mac_prefix[] = {MAC_PREFIX};

Loading…
Cancel
Save