Merge branch 'master' of gitlab.com:HDIoT/smart_household/wired_sensors/iaq_wired_sensor
This commit is contained in:
commit
dc3e7c8288
@ -659,6 +659,8 @@ int8_t uart_disable_interrupts(void)
|
||||
int8_t uart_enable_interrupts(void)
|
||||
{
|
||||
LL_LPUART_Enable(LPUART1);
|
||||
LL_LPUART_ClearFlag_IDLE(LPUART1);
|
||||
LL_LPUART_ClearFlag_NE(LPUART1);
|
||||
LL_LPUART_EnableIT_IDLE(LPUART1);
|
||||
LL_LPUART_EnableIT_RXNE(LPUART1);
|
||||
|
||||
|
@ -66,6 +66,8 @@ int8_t scd4x_read_measurement(uint16_t * co2, int16_t *temperature, uint16_t *re
|
||||
}*/
|
||||
|
||||
|
||||
// disable interrupts to prevent MODBUS/I2C conflict
|
||||
uart_disable_interrupts();
|
||||
// start measurement
|
||||
buffer[0] = SCD4X_READ_MEASUREMENT >> 8;
|
||||
buffer[1] = SCD4X_READ_MEASUREMENT & 0x00ff;
|
||||
@ -75,11 +77,12 @@ int8_t scd4x_read_measurement(uint16_t * co2, int16_t *temperature, uint16_t *re
|
||||
/*if (result != I2C_OK) {
|
||||
return SCD4X_ERROR;
|
||||
}*/
|
||||
uart_disable_interrupts();
|
||||
LL_mDelay(1); // 10 ms should be enough
|
||||
uart_enable_interrupts();
|
||||
LL_mDelay(1); // 10 ms should be enough
|
||||
uart_disable_interrupts();
|
||||
// read out
|
||||
result = i2c_receive(SCD4X_I2C_ADDRESS<<1, buffer, 9);
|
||||
uart_enable_interrupts();
|
||||
if (result != I2C_OK)
|
||||
{
|
||||
return SCD4X_ERROR;
|
||||
|
@ -23,6 +23,8 @@ int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity)
|
||||
uint8_t buffer[32];
|
||||
int result;
|
||||
|
||||
// disable interrupts
|
||||
uart_disable_interrupts();
|
||||
// start measurement
|
||||
buffer[0] = SHT4X_START_MEAS_HIGH_PRECISION;
|
||||
result = i2c_transmit(SHT4X_I2C_ADDRESS<<1, buffer, 1);
|
||||
@ -31,11 +33,14 @@ int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity)
|
||||
if (result != I2C_OK) {
|
||||
return SHT4X_ERROR;
|
||||
}*/
|
||||
uart_disable_interrupts();
|
||||
LL_mDelay(10); // 10 ms should be enough
|
||||
// enable interrupts while waiting
|
||||
uart_enable_interrupts();
|
||||
LL_mDelay(10); // 10 ms should be enough
|
||||
uart_disable_interrupts();
|
||||
// read out
|
||||
result = i2c_receive(SHT4X_I2C_ADDRESS<<1, buffer, 6);
|
||||
// enable interrupts again
|
||||
uart_enable_interrupts();
|
||||
if (result != I2C_OK) {
|
||||
return SHT4X_ERROR;
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -17,6 +17,8 @@ stm32l0xx_ll_lpuart.h:1233:22:LL_LPUART_SetDEAssertionTime 16 static
|
||||
stm32l0xx_ll_lpuart.h:1255:22:LL_LPUART_EnableDEMode 16 static
|
||||
stm32l0xx_ll_lpuart.h:1291:22:LL_LPUART_SetDESignalPolarity 16 static
|
||||
stm32l0xx_ll_lpuart.h:1400:26:LL_LPUART_IsActiveFlag_TXE 16 static
|
||||
stm32l0xx_ll_lpuart.h:1533:22:LL_LPUART_ClearFlag_NE 16 static
|
||||
stm32l0xx_ll_lpuart.h:1555:22:LL_LPUART_ClearFlag_IDLE 16 static
|
||||
stm32l0xx_ll_lpuart.h:1619:22:LL_LPUART_EnableIT_IDLE 16 static
|
||||
stm32l0xx_ll_lpuart.h:1631:22:LL_LPUART_EnableIT_RXNE 16 static
|
||||
stm32l0xx_ll_lpuart.h:1726:22:LL_LPUART_DisableIT_IDLE 16 static
|
||||
@ -58,6 +60,6 @@ main.c:596:13:MX_GPIO_Init 32 static
|
||||
main.c:639:6:LPUART1_TX_Buffer 24 static,ignoring_inline_asm
|
||||
main.c:650:8:uart_disable_interrupts 8 static
|
||||
main.c:659:8:uart_enable_interrupts 8 static
|
||||
main.c:668:8:modbus_slave_callback 32 static
|
||||
main.c:787:8:modbus_transmit_function 16 static
|
||||
main.c:799:6:Error_Handler 8 static,ignoring_inline_asm
|
||||
main.c:670:8:modbus_slave_callback 32 static
|
||||
main.c:789:8:modbus_transmit_function 16 static
|
||||
main.c:801:6:Error_Handler 8 static,ignoring_inline_asm
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -61,8 +61,8 @@ all: main-build
|
||||
main-build: iaq_wired_sensor.elf secondary-outputs
|
||||
|
||||
# Tool invocations
|
||||
iaq_wired_sensor.elf: $(OBJS) $(USER_OBJS) /home/mrs/Personal/HDIoT/Smart_Household/iaq_wired_sensor/fw/STM32L011F4UX_FLASH.ld makefile objects.list $(OPTIONAL_TOOL_DEPS)
|
||||
arm-none-eabi-gcc -o "iaq_wired_sensor.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m0plus -T"/home/mrs/Personal/HDIoT/Smart_Household/iaq_wired_sensor/fw/STM32L011F4UX_FLASH.ld" --specs=nosys.specs -Wl,-Map="iaq_wired_sensor.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
|
||||
iaq_wired_sensor.elf: $(OBJS) $(USER_OBJS) /home/dooku/projekty/hdiot/iaq_wired_sensor/fw_old/STM32L011F4UX_FLASH.ld makefile objects.list $(OPTIONAL_TOOL_DEPS)
|
||||
arm-none-eabi-gcc -o "iaq_wired_sensor.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m0plus -T"/home/dooku/projekty/hdiot/iaq_wired_sensor/fw_old/STM32L011F4UX_FLASH.ld" --specs=nosys.specs -Wl,-Map="iaq_wired_sensor.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
|
||||
@echo 'Finished building target: $@'
|
||||
@echo ' '
|
||||
|
||||
|
@ -36,8 +36,8 @@ while True:
|
||||
T_SCD4x_signed = instrument.read_register(T_SCD4x_signed_addr, 1, functioncode=4, signed=True)
|
||||
with open(f'measurement_device_{slave_address}.csv', 'a+') as f:
|
||||
f.write(f'{time():.1f} {CO2} {T_SHT4x} {RH_SHT4x} {T_SCD4x} {RH_SCD4x} {T_SHT4x_signed} {T_SCD4x_signed}\n')
|
||||
except minimalmodbus.NoResponseError:
|
||||
except minimalmodbus.NoResponseError as e:
|
||||
with open('measure.log', 'a+') as logfile:
|
||||
logfile.write(f'Read error for device {slave_address} at {time()}\n')
|
||||
logfile.write(f'Read error for device {slave_address} at {time()} ({str(e)})\n')
|
||||
continue
|
||||
sleep(10)
|
||||
|
@ -4,10 +4,10 @@ from sys import exit
|
||||
import minimalmodbus
|
||||
import serial
|
||||
|
||||
slave_address = 254
|
||||
slave_address = 252
|
||||
instrument = minimalmodbus.Instrument('/dev/rs485', slave_address, close_port_after_each_call=True) # port name, slave address (in decimal)
|
||||
|
||||
instrument.serial.baudrate = 19200
|
||||
instrument.serial.baudrate = 115200
|
||||
instrument.serial.bytesize = 8
|
||||
instrument.serial.parity = serial.PARITY_EVEN
|
||||
instrument.serial.stopbits = 1
|
||||
|
Loading…
Reference in New Issue
Block a user