add back in bme280 readings
=== WiFi Connection Test === "); === NODE 001 === "); "); "); "); "); ");
This commit is contained in:
parent
51cf876486
commit
b1625e69d4
1 changed files with 20 additions and 5 deletions
25
node1.c
25
node1.c
|
|
@ -1,22 +1,29 @@
|
|||
#include "bme280.h"
|
||||
#include "pico/cyw43_arch.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include <hardware/watchdog.h>
|
||||
#include <pico/time.h>
|
||||
#include <pico/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* Simple WiFi Connection Test
|
||||
* Just connect to WiFi and poll every 5 seconds to check connection status
|
||||
*/
|
||||
#define SENSOR_READING_INTERVAL_US (1000000 * 10) // 10 seconds
|
||||
|
||||
static bme280_config bem_config;
|
||||
static bme280_reading current_bem280_reading;
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
watchdog_enable(120000, 1); // 120 second watchdog
|
||||
|
||||
printf("\n=== WiFi Connection Test ===\n");
|
||||
printf("\n=== NODE 001 ===\n");
|
||||
printf("Initializing board...\n");
|
||||
sleep_ms(2000);
|
||||
|
||||
|
||||
printf("Initializing BME280...\n");
|
||||
bme280_init(&bem_config, i2c1, 14, 15);
|
||||
sleep_ms(1000);
|
||||
|
||||
printf("Initializing CYW43...\n");
|
||||
if (cyw43_arch_init()) {
|
||||
printf("FATAL: Failed to initialize CYW43\n");
|
||||
|
|
@ -50,12 +57,20 @@ int main() {
|
|||
|
||||
// Poll every 5 seconds
|
||||
absolute_time_t last_check = get_absolute_time();
|
||||
absolute_time_t last_sensor_reading = get_absolute_time();
|
||||
|
||||
while (1) {
|
||||
watchdog_update();
|
||||
cyw43_arch_poll();
|
||||
|
||||
absolute_time_t now = get_absolute_time();
|
||||
|
||||
if (absolute_time_diff_us(last_sensor_reading, now) >= SENSOR_READING_INTERVAL_US) {
|
||||
last_sensor_reading = now;
|
||||
printf("Making BME280 Reading\n");
|
||||
current_bem280_reading = bme280_read(&bem_config);
|
||||
}
|
||||
|
||||
if (absolute_time_diff_us(last_check, now) >= 5000000) {
|
||||
last_check = now;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue