Decreased SHT read time to 10 ms; changed baud to 19200

This commit is contained in:
Duke NUCem 2021-09-30 18:38:59 +02:00
parent b8718935f7
commit 25df18ed66
3 changed files with 6 additions and 7 deletions

View File

@ -381,10 +381,9 @@ int main(void)
if (CO2 <= sensor_config.led_co2_alert_limit1) if (CO2 <= sensor_config.led_co2_alert_limit1)
{ {
/* CO2 is OK -> BLUE */ /* CO2 is OK -> BLUE */
/* TODO: Decide if blue or green */
LL_GPIO_SetOutputPin(LED_R_GPIO_Port, LED_R_Pin); LL_GPIO_SetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
LL_GPIO_SetOutputPin(LED_G_GPIO_Port, LED_G_Pin); LL_GPIO_ResetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
LL_GPIO_ResetOutputPin(LED_B_GPIO_Port, LED_B_Pin); LL_GPIO_SetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
} else if ((sensor_config.led_co2_alert_limit1 < CO2) && (CO2 <= sensor_config.led_co2_alert_limit2)) } else if ((sensor_config.led_co2_alert_limit1 < CO2) && (CO2 <= sensor_config.led_co2_alert_limit2))
{ {
@ -603,7 +602,7 @@ static void MX_LPUART1_UART_Init(void)
/* USER CODE BEGIN LPUART1_Init 1 */ /* USER CODE BEGIN LPUART1_Init 1 */
/* USER CODE END LPUART1_Init 1 */ /* USER CODE END LPUART1_Init 1 */
LPUART_InitStruct.BaudRate = 115200; LPUART_InitStruct.BaudRate = 19200;
LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_9B; LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_9B;
LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1;
LPUART_InitStruct.Parity = LL_LPUART_PARITY_EVEN; LPUART_InitStruct.Parity = LL_LPUART_PARITY_EVEN;

View File

@ -30,7 +30,7 @@ int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity)
if (result != I2C_OK) { if (result != I2C_OK) {
return SHT4X_ERROR; return SHT4X_ERROR;
}*/ }*/
LL_mDelay(100); // 10 ms should be enough LL_mDelay(10); // 10 ms should be enough
// read out // read out
result = i2c_receive(SHT4X_I2C_ADDRESS<<1, buffer, 6); result = i2c_receive(SHT4X_I2C_ADDRESS<<1, buffer, 6);
if (result != I2C_OK) { if (result != I2C_OK) {

View File

@ -6,11 +6,11 @@ import serial
slave_address = 254 slave_address = 254
instrument = minimalmodbus.Instrument('/dev/ttyUSB0', slave_address, close_port_after_each_call=True) # port name, slave address (in decimal) instrument = minimalmodbus.Instrument('/dev/ttyUSB0', slave_address, close_port_after_each_call=True) # port name, slave address (in decimal)
instrument.serial.baudrate = 115200 instrument.serial.baudrate = 19200
instrument.serial.bytesize = 8 instrument.serial.bytesize = 8
instrument.serial.parity = serial.PARITY_EVEN instrument.serial.parity = serial.PARITY_EVEN
instrument.serial.stopbits = 1 instrument.serial.stopbits = 1
instrument.serial.timeout = 0.1 # seconds instrument.serial.timeout = 0.05 # seconds
instrument.mode = minimalmodbus.MODE_RTU # rtu or ascii mode instrument.mode = minimalmodbus.MODE_RTU # rtu or ascii mode
instrument.clear_buffers_before_each_transaction = True instrument.clear_buffers_before_each_transaction = True