Thank you for your detailed explanation regarding the negative logic requirements of SDI-12. I have been working on establishing communication between an STM32L072 microcontroller and an ATMOS22 weather sensor using the SDI-12 protocol , but I am still encountering issues where no data is being received from the sensor.
Here is my current UART configuration:
void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 1200;
huart1.Init.WordLength = UART_WORDLENGTH_8B; // 7 data bits + 1 parity = 8 total
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_EVEN;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
// Configuration for SDI-12 inverted logic
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_TXINVERT_INIT | UART_ADVFEATURE_RXINVERT_INIT;
huart1.AdvancedInit.TxPinLevelInvert = UART_ADVFEATURE_TXINV_ENABLE;
huart1.AdvancedInit.RxPinLevelInvert = UART_ADVFEATURE_RXINV_ENABLE;
if (HAL_HalfDuplex_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
printf("UART1 initialized successfully\r\n");
}
ased on your suggestion, it seems that the idle state of the TX line should be set to low for proper SDI-12 communication. However, I am already enabling TX inversion (UART_ADVFEATURE_TXINV_ENABLE) in my configuration, which should handle the inverted logic as required by SDI-12.
My question is: Do I still need to use a buffer like SN74LVC1G240DBVT for successful communication?
From what I understand:
The SN74LVC1G240DBVT buffer is typically used for level shifting and handling the inverted logic.
Since I am already configuring the UART to invert the TX and RX signals, do I still need this buffer?
Any further clarification or advice would be greatly appreciated!
Thank you in advance for your help.