get pms5003 working
", readings_index); "); "); "); "); ", "); ", "); "); "); "); "); "); "); "); "); "); "); ", link_status); ", link_status); "); ", readings[reading_i].pm1, readings[reading_i].pm2_5, readings[reading_i].pm10); ", reading_i);
This commit is contained in:
parent
9dd4ee4163
commit
0e513dc79a
2 changed files with 34 additions and 24 deletions
40
node1.c
40
node1.c
|
|
@ -101,6 +101,7 @@ int main() {
|
|||
|
||||
if (absolute_time_diff_us(last_sensor_reading, now) >=
|
||||
SENSOR_READING_INTERVAL_US) {
|
||||
printf("Sensor reading: %d\n", readings_index);
|
||||
last_sensor_reading = now;
|
||||
printf("Making BME280 Reading\n");
|
||||
current_bem280_reading = bme280_read(&bem_config);
|
||||
|
|
@ -117,18 +118,21 @@ int main() {
|
|||
pms5003_warmup(&pms_config);
|
||||
}
|
||||
|
||||
// if (readings_index == 4) {
|
||||
// printf("Starting reads on PMSS5003\n");
|
||||
// pms5003_start_reading(&pms_config);
|
||||
// }
|
||||
if (readings_index == 4) {
|
||||
printf("Starting reads on PMSS5003\n");
|
||||
pms5003_start_reading(&pms_config);
|
||||
}
|
||||
|
||||
// if (readings_index == 6) {
|
||||
// printf("Finished reading PMSS5003\n");
|
||||
// current_pms5003_reading = pms5003_finish_reading(&pms_config);
|
||||
// snprintf(msg_to_send, sizeof(msg_to_send), "M02,%.2f,%.2f,%2f\n",
|
||||
// current_pms5003_reading.pm1, current_pms5003_reading.pm2_5,
|
||||
// current_pms5003_reading.pm10);
|
||||
// }
|
||||
if (readings_index == 6) {
|
||||
printf("Finished reading PMSS5003\n");
|
||||
current_pms5003_reading = pms5003_finish_reading(&pms_config);
|
||||
snprintf(msg_to_send, sizeof(msg_to_send), "M02,%.2f,%.2f,%2f\n",
|
||||
current_pms5003_reading.pm1, current_pms5003_reading.pm2_5,
|
||||
current_pms5003_reading.pm10);
|
||||
printf(
|
||||
"Sending particle matter readings to backend server...\n");
|
||||
send_msg(msg_to_send);
|
||||
}
|
||||
|
||||
readings_index++;
|
||||
if (readings_index >= 10) {
|
||||
|
|
@ -142,27 +146,27 @@ int main() {
|
|||
// Check connection status
|
||||
int link_status = cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_STA);
|
||||
|
||||
printf("[WiFi Status Check]\n");
|
||||
printf(" Link Status: ");
|
||||
// printf("[WiFi Status Check]\n");
|
||||
// printf(" Link Status: ");
|
||||
switch (link_status) {
|
||||
case CYW43_LINK_DOWN:
|
||||
printf("DOWN\n");
|
||||
// printf("DOWN\n");
|
||||
gpio_put(WIFI_STATUS_LED_PIN, false);
|
||||
break;
|
||||
case CYW43_LINK_JOIN:
|
||||
printf("JOINING\n");
|
||||
// printf("JOINING\n");
|
||||
gpio_put(WIFI_STATUS_LED_PIN, false);
|
||||
break;
|
||||
case CYW43_LINK_NOIP:
|
||||
printf("NO IP\n");
|
||||
// printf("NO IP\n");
|
||||
gpio_put(WIFI_STATUS_LED_PIN, false);
|
||||
break;
|
||||
case CYW43_LINK_UP:
|
||||
printf("UP\n");
|
||||
// printf("UP\n");
|
||||
gpio_put(WIFI_STATUS_LED_PIN, true);
|
||||
break;
|
||||
default:
|
||||
printf("UNKNOWN (%d)\n", link_status);
|
||||
// printf("UNKNOWN (%d)\n", link_status);
|
||||
gpio_put(WIFI_STATUS_LED_PIN, false);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue