# Cygnet issue with ModbusMaster

**URL:** <https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223>\
**Category:** Firmware\
**Created:** [August 5, 2025, 4:37pm UTC](https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223 "2025-08-05T16:37:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rfadell3](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@rfadell3](https://discuss.blues.com/u/rfadell3)\
**Post date:** [August 5, 2025, 4:37pm UTC](https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223/1 "2025-08-05T16:37:00Z")

</div>

I’m running into an issue where our Cygnet is freezing when using ModbusMaster. The same code works well when testing in on the Swan (switched the platformIO board/env).

It looks like there’s a line of code in ModbusMasterTransaction() that the code is freezing on, “ \_serial-\>flush();

Any ideas what can be going wrong or how to correct it?

> int writeModbusRegister(uint16\_t regAddress, uint16\_t regValue, int regType)
> 
> {
> 
> uint8\_t result;
> 
> uint16\_t data;
> 
> int numRead = 1;
> 
> Serial.print(“Writing Modbus Register at address: 0x”);
> 
> Serial.print(regAddress, HEX);
> 
> Serial.print(" ");
> 
> Serial.print(regValue);
> 
> if (regType == 6){
> 
> ```
> result = node.writeSingleRegister(regAddress, regValue);
> 
> ```
> 
> }
> 
> else {
> 
> ```
> result = node.writeSingleCoil(regAddress, regValue);
> 
> ```
> 
> }
> 
> if (result == node.ku8MBSuccess){
> 
> ```
> Serial.print(" Response Bytes: ");
> 
> for (uint8_t i = 0; i < numRead; i++) {
> 
> Serial.print(node.getResponseBuffer(i), HEX);
> 
> Serial.print(" ");
> 
> }
> 
> Serial.println();
> 
> //Serial.print("Response Dec: ");
> 
> for (uint8_t i = 0; i < numRead; i++) {
> 
> //Serial.print(node.getResponseBuffer(i), DEC);
> 
> //Serial.print(" ");
> 
> }
> 
> //Serial.println();
> 
> data = node.getResponseBuffer(0);
> 
> //Serial.print("Input Register Value: ");
> 
> ```
> 
> }
> 
> else {
> 
> ```
> Serial.print(" Error writing input register " + String(regAddress) + ". Error code: ");
> 
> Serial.println(result, HEX);
> 
> ```
> 
> }
> 
> delay(0);
> 
> return result;
> 
> }

The process is freezing within writeSingleRegister(), then within ModbusMasterTransaction(), on

> \_serial-\>flush();

---

<div class="post-metadata">

**Author:** ![zfields](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/zfields/32/29_2.png) [@zfields](https://discuss.blues.com/u/zfields)\
**Post date:** [August 5, 2025, 5:15pm UTC](https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223/3 "2025-08-05T17:15:14Z")

</div>

How are you connecting to ModBus?

Can you share an image of your setup?

---

<div class="post-metadata">

**Author:** ![rfadell3](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@rfadell3](https://discuss.blues.com/u/rfadell3)\
**Post date:** [August 5, 2025, 8:41pm UTC](https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223/4 "2025-08-05T20:41:18Z")

</div>

![Swan RS485](https://us1.discourse-cdn.com/flex020/uploads/blues/original/2X/3/3377ffb50d20adbfd91a0d40ca5f596a434e0c5b.png)

This is the circuit schematic of the MCU and RS485 converter. I have this all on a PCB, and the Swan board is attached to female header pins. I’m just swapping the Swan with the Cygnet, using the same code, but it’s freezing in that one section.

---

<div class="post-metadata">

**Author:** ![zfields](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/zfields/32/29_2.png) [@zfields](https://discuss.blues.com/u/zfields)\
**Post date:** [August 5, 2025, 11:59pm UTC](https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223/5 "2025-08-05T23:59:54Z")

</div>

Hello @rfadell3 ,

Thanks for sharing the schematic, that definitely helped.

Unfortunately, there is no UART available on pins A4/A5 on the Cygnet. The Swan and Cygnet are only guaranteed pin-for-pin compatibility based on the [Adafruit Feather specification](https://learn.adafruit.com/adafruit-feather/feather-specification).

The Swan is a much more powerful MCU with more peripherals available than the Cygnet.

If you’re willing, we would love to better understand why you chose the Cygnet over the Swan, so we can apply it as input for making future improvements to the Swan.

~Zak

---

<div class="post-metadata">

**Author:** ![rfadell3](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@rfadell3](https://discuss.blues.com/u/rfadell3)\
**Post date:** [August 6, 2025, 2:43pm UTC](https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223/6 "2025-08-06T14:43:42Z")

</div>

Hi Zak,

Ok, so to clarify the A4/A5 pins on the Swan are UART compatible, but the same pins are not on the Cygnet? Are there any pins on the Cygnet (besides Rx/Tx) that are UART compatible? We are using the Rx/Tx pins for Notecard communication.

We primarily switched because we don’t need some of the expanded features of the Swan (2MB flash, 640KKB SRAM, etc.), but I guess we need the UART capabilities.

---

<div class="post-metadata">

**Author:** ![zfields](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/zfields/32/29_2.png) [@zfields](https://discuss.blues.com/u/zfields)\
**Post date:** [September 24, 2025, 12:43pm UTC](https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223/7 "2025-09-24T12:43:35Z")

</div>

Here’s Schematic for the Cygnet:

> **[Schematic%20Prints.pdf](https://github.com/blues/note-hardware/blob/master/Cygnet/v1.2/Schematic%20Prints.pdf)**

We do expose the LPUART through the debug port. You could tap into that, but it would far less convenient than anything on the feather connector.

~Zak

---

<div class="post-metadata">

**Author:** ![zfields](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/zfields/32/29_2.png) [@zfields](https://discuss.blues.com/u/zfields)\
**Post date:** [September 26, 2025, 6:44pm UTC](https://discuss.blues.com/t/cygnet-issue-with-modbusmaster/3223/8 "2025-09-26T18:44:34Z")

</div>

@rfadell3 I was mistaken.

There _IS_ a secondary UART. I don’t know how I missed it before…

```cpp
#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_TX[] = {
  {PA_2, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // - A2
  {PA_2_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // - A2
  {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // - TX
  {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // - SCL
  {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // - LPUART1_VCP_RX
  {PB_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // - LPUART1_VCP_TX
  {NC, NP, 0}
};
#endif

#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_RX[] = {
  {PA_3, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // - A3
  {PA_3_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // - A3
  {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // - RX
  // {PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART2)}, // - CHARGE_DETECT
  {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // - SDA
  {PB_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // - LPUART1_VCP_RX
  {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // - LPUART1_VCP_TX
  {NC, NP, 0}
};
#endif

```

[https://github.com/stm32duino/Arduino\_Core\_STM32/blob/main/variants/STM32L4xx/L433C(B-C)(T-U)\_L443CC(T-U)/PeripheralPins\_CYGNET.c](https://github.com/stm32duino/Arduino_Core_STM32/blob/main/variants/STM32L4xx/L433C(B-C)(T-U)_L443CC(T-U)/PeripheralPins_CYGNET.c)

You can access it with:

```cpp
HardwareSerial Serial2(PA3, PA2);

```

It will appear on pins `A2`(TX)/`A3`(RX) on the Feather header.

My apologies,

Zak
