79638939

Date: 2025-05-26 12:54:37
Score: 4.5
Natty: 5
Report link

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:

Any further clarification or advice would be greatly appreciated!

Thank you in advance for your help.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (1): appreciated
  • RegEx Blacklisted phrase (3): Thank you in advance
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Ahmed