Skip to content

Commit

Permalink
Validated Sht30
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabramz committed Mar 14, 2024
1 parent d85e8d3 commit 19d517a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions Core/Src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "timer.h"
#include <stdbool.h>
#include <string.h>
#include <stdio.h>

osThreadId_t temp_monitor_handle;
const osThreadAttr_t temp_monitor_attributes = {
Expand All @@ -33,22 +34,25 @@ void vTempMonitor(void* pv_params)
fault_data_t fault_data = { .id = ONBOARD_TEMP_FAULT, .severity = DEFCON4 };
can_msg_t temp_msg = { .id = CANID_TEMP_SENSOR, .len = 4, .data = { 0 } };

//mpu_t *mpu = (mpu_t *)pv_params;
mpu_t *mpu = (mpu_t *)pv_params;

for (;;) {
/* Take measurement */
// serial_print("Temp Sensor Task\r\n");
uint16_t temp = 0;
uint16_t humidity = 0;
//if (read_temp_sensor(mpu, &temp, &humidity)) {
// fault_data.diag = "Failed to get temp";
// queue_fault(&fault_data);
//}
if (read_temp_sensor(mpu, &temp, &humidity)) {
//printf("FAILED TO READ");
fault_data.diag = "Failed to get temp";
queue_fault(&fault_data);
}

/* Run values through LPF of sample size */
sensor_data.temperature = (sensor_data.temperature + temp) / num_samples;
sensor_data.humidity = (sensor_data.humidity + humidity) / num_samples;

printf("%d\n", temp);

/* Publish to Onboard Temp Queue */
osMessageQueuePut(onboard_temp_queue, &sensor_data, 0U, 0U);

Expand Down
2 changes: 1 addition & 1 deletion Core/Src/mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mpu_t* init_mpu(I2C_HandleTypeDef* hi2c, ADC_HandleTypeDef* accel_adc1,
mpu->temp_sensor = malloc(sizeof(sht30_t));
assert(mpu->temp_sensor);
mpu->temp_sensor->i2c_handle = hi2c;
//assert(!sht30_init(mpu->temp_sensor)); /* This is always connected */
assert(!sht30_init(mpu->temp_sensor)); /* This is always connected */

/* Initialize the IMU */
mpu->imu = malloc(sizeof(lsm6dso_t));
Expand Down

0 comments on commit 19d517a

Please sign in to comment.