- This commit updates the build process to use a custom toolchain and configuration, enabling compilation of multiple project components. - The primary goal of this commit is to provide a detailed overview and documentation for a zigbee weather station project, including firmware information and sensor component descriptions. - Updated configuration file with new constants and definitions. - The MAIN GOAL of these changes is to implement a comprehensive sensor system for environmental monitoring, including temperature, humidity, pressure, wind speed, and direction. - Main goal of the changes: Define a new header file with function prototypes and external variable declarations. - Added new functionality to initialize and read data from an anemometer sensor, introducing its necessary setup and calculation logic. - Added header file for anemometer sensor with function prototypes. - Initial implementation of BME280 sensor functionality. - Added function prototype for the BME280 initialization and data reading functions. - Initializes and configures a rain gauge sensor with GPIO interrupt setup. - Added function prototypes to the rain gauge sensor header file. - This commit adds a new C function to initialize and read data from a wind vane sensor. - Updated header file with new function prototype definitions. - This commit adds a new function `send_zigbee_data` to send various Zigbee data types. - Added Zigbee communication header file with function prototype for sending data.
64 lines
1.7 KiB
C
64 lines
1.7 KiB
C
#include <ioCC2530.h>
|
|
#include "hal_types.h"
|
|
#include "hal_timer.h"
|
|
#include "ZComDef.h"
|
|
#include "OSAL.h"
|
|
#include "ZStack.h"
|
|
#include "bme280.h"
|
|
#include "wind_vane.h"
|
|
#include "rain_gauge.h"
|
|
#include "anemometer.h"
|
|
#include "zigbee_comm.h"
|
|
#include "config.h"
|
|
|
|
// Global variables to store sensor data
|
|
uint8 zcl_temp_humidity_data[6]; // For temperature, humidity, pressure
|
|
uint8 zcl_wind_data[2]; // For wind speed, wind direction
|
|
|
|
// Initialize all sensors
|
|
void init_sensors() {
|
|
BME280_init();
|
|
WindVane_init();
|
|
RainGauge_init();
|
|
Anemometer_init();
|
|
}
|
|
|
|
// Read sensor data and store it
|
|
void read_sensor_data() {
|
|
int32 temperature, humidity, pressure;
|
|
BME280_readData(&temperature, &humidity, &pressure);
|
|
|
|
// Store BME280 data
|
|
zcl_temp_humidity_data[0] = (uint8)(temperature >> 8);
|
|
zcl_temp_humidity_data[1] = (uint8)(temperature & 0xFF);
|
|
zcl_temp_humidity_data[2] = (uint8)(humidity >> 8);
|
|
zcl_temp_humidity_data[3] = (uint8)(humidity & 0xFF);
|
|
zcl_temp_humidity_data[4] = (uint8)(pressure >> 8);
|
|
zcl_temp_humidity_data[5] = (uint8)(pressure & 0xFF);
|
|
|
|
// Read and store wind data
|
|
zcl_wind_data[0] = WindVane_read(); // Wind direction
|
|
zcl_wind_data[1] = Anemometer_read(); // Wind speed
|
|
|
|
// Read rain gauge data
|
|
RainGauge_read();
|
|
}
|
|
|
|
// Main application loop
|
|
void main_loop() {
|
|
while (1) {
|
|
read_sensor_data(); // Read all sensor data
|
|
send_zigbee_data(); // Send collected data over Zigbee
|
|
|
|
osal_delay(60000); // Delay for 1 minute (60000ms)
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
hal_init(); // Initialize the CC2530 hardware
|
|
init_sensors(); // Initialize all sensors
|
|
main_loop(); // Enter main loop
|
|
|
|
return 0;
|
|
}
|