The Serial FeatherWing was designed with rapid prototyping in mind. Being fully compatible with the Adafruit ecosystem, this FeatherWing gives the user the flexibility to choose the preferred host microcontroller. The inherent modularity of the ecosystem allows the FeatherWing to be easily integrated into any project.
Würth Elektronik eiSos provides a Software Development Kit (SDK) with examples to support all WE FeatherWings. Here are the salient features of the WE FeatherWing SDK.
- The SDK is open-source and well documented.
- It uses popular open-source tool chain including an IDE.
- The examples are written in Arduino styled C/C++ for easy understanding.
- The core components of the SDK are written in pure C to enable easy porting to any microcontroller platform.
- Modular structure of the software stack makes it easy to integrate into any project.
- Install IDE: your favourite development IDE (we recommend Visual Studio Code with Platform IO extension.
- PlatformIO: is a cross-platform, cross-architecture, multiple framework professional tool for embedded software development. It provides the tool chain necessary for the software development including building, debugging, code-upload and many more. PlatformIO works well on all the modern operating systems and supports a host of development boards including the Feathers from Adafruit. Further details about PlatformIO can be found under platformio.org.
- WE SDK: This is a layer of platform-independent pure C drivers for sensors and wireless connectivity modules from Würth Elektronik eiSos. These drivers implement all the necessary functions to utilize full feature set of the sensors and wireless connectivity modules. More details on the SDK and downloads under WCS Software.
- Board files: This layer provides abstraction at a board level and provides functions to configure and control individual FeatherWings from WE.
- User application: The SDK currently implements a quick start example for each of the FeatherWings.
- Install Visual Studio Code on the platform of your choice following the instructions.
- Follow the instructions to install the PlatformIO IDE extension.
This example requires the Serial Bridge FeatherWing connected to the M0 Feather and either the Thyone FeatherWing or the Calypso Wi-Fi FeatherWing. This combination can be used to retrofit a legacy RS232/RS485 device with Wireless connectivity.
- Configuration: The following parameters need to be set-up before building the code.
#define FeatherWing CalypsoWiFiFeatherWing
#define SerialCommunicationStandard RS232- Setup: The debug as well as the selected module UART interfaces and the UART interface for the serial featherwing are initialized.
void setup() {
#if ((WE_DEBUG_PRINT_LEVEL > WE_Debug_Print_Level_Off) || \
defined(WE_APP_PRINT_ENABLED))
WE_Print_Init();
#endif
#if SerialCommunicationStandard == RS485
pinMode(12, OUTPUT);
#endif
delay(5000);
#if FeatherWing == CalypsoWiFiFeatherWing
WE_UART_RXPin11_TXPin10_Init(
115200, WE_FlowControl_NoFlowControl, WE_Parity_None,
(WE_UART_HandleRxByte_t *)&WE_UART_RXPin11_TXPin10_HandleRxByte);
// Wi-Fi settings
strcpy(calSettings.wifiSettings.SSID, WI_FI_SSID);
strcpy(calSettings.wifiSettings.securityParams.securityKey, WI_FI_PASSWORD);
calSettings.wifiSettings.securityParams.securityType =
Calypso_ATWLAN_SecurityType_WPA_WPA2;
// MQTT Settings - Mosquitto broker(non-secure for demo purposes only)
strcpy(calSettings.mqttSettings.clientID, MQTT_CLIENT_ID);
calSettings.mqttSettings.flags = Calypso_ATMQTT_CreateFlags_URL;
strcpy(calSettings.mqttSettings.serverInfo.address, MQTT_SERVER_ADDRESS);
calSettings.mqttSettings.serverInfo.port = MQTT_PORT;
calSettings.mqttSettings.connParams.protocolVersion =
Calypso_ATMQTT_ProtocolVersion_v3_1;
calSettings.mqttSettings.connParams.blockingSend = 0;
calSettings.mqttSettings.connParams.format = Calypso_DataFormat_Base64;
strcpy(calSettings.mqttSettings.userOptions.userName, "\0");
strcpy(calSettings.mqttSettings.userOptions.passWord, "\0");
// Initialize Calypso
if (!Calypso_simpleInit(&calSettings, &Calypso_EventCallback)) {
WE_APP_PRINT("Calypso init failed \r\n");
}
while (currentState != SerialFeatherWing_SM_Calypso_StartUp) {
}
// to wait for calypso auto connect
WE_Delay(1000);
Calypso_ATWLAN_SetMode_t mode;
if (!Calypso_getWLANMode(&mode)) {
WE_APP_PRINT("get wlan mode failed\r\n");
return;
} else if (mode == Calypso_ATWLAN_SetMode_Station) {
if (currentState == SerialFeatherWing_SM_Calypso_StartUp) {
currentState = SerialFeatherWing_SM_Wlan_Connect;
return;
}
}
if (!Calypso_setWLANMode(Calypso_ATWLAN_SetMode_Station)) {
WE_APP_PRINT("set wlan mode failed\r\n");
return;
}
currentState = SerialFeatherWing_SM_Wlan_Connect;
#elif FeatherWing == ThyoneWirelessFeatherWing
uint8_t serialNrThy[4] = {0};
WE_UART_RXPin0_TXPin1_Init(
115200, WE_FlowControl_NoFlowControl, WE_Parity_None,
(WE_UART_HandleRxByte_t *)&WE_UART_RXPin0_TXPin1_HandleRxByte);
SetPinMode(SETEBOS_MODE_PIN, OUTPUT);
WritePin(SETEBOS_MODE_PIN, HIGH);
if (!ThyoneI_Init(&ThyoneI_uart, &ThyoneI_pins,
ThyoneI_OperationMode_CommandMode, ThyoneRxCallback)) {
WE_APP_PRINT("Thyone init failed \r\n");
}
if (ThyoneI_GetSerialNumber(serialNrThy)) {
WE_APP_PRINT("Thyone-I default source address %02X%02X%02X%02X \r\n",
serialNrThy[3], serialNrThy[2], serialNrThy[1],
serialNrThy[0]);
}
#endif
}- In the main application, if the selected module is calypso then the data is read from the serial featherwing and sent to the MQTT broker and vice versa. Otherwise if the selected module is is thyone then data is read from the serial featherwing and sent to thyone and vice versa.
void loop() {
switch (currentState) {
#if FeatherWing == CalypsoWiFiFeatherWing
case SerialFeatherWing_SM_Wlan_Connect: {
if (!Calypso_WLANconnect()) {
WE_APP_PRINT("WiFi connect fail\r\n");
currentState = SerialFeatherWing_SM_Idle;
} else if (currentState == SerialFeatherWing_SM_Wlan_Connect) {
currentState = SerialFeatherWing_SM_Idle;
}
break;
}
case SerialFeatherWing_SM_MQTT_Connect: {
if (!Calypso_MQTTconnect()) {
WE_APP_PRINT("MQTT connect fail\r\n");
currentState = SerialFeatherWing_SM_Idle;
} else if (currentState == SerialFeatherWing_SM_MQTT_Connect) {
currentState = SerialFeatherWing_SM_Idle;
}
break;
}
case SerialFeatherWing_SM_MQTT_Subscribe: {
Calypso_ATMQTT_SubscribeTopic_t nodeCommand = {
.QoS = Calypso_ATMQTT_QoS_QoS1};
strcpy(nodeCommand.topic, MQTT_Subscribe_Topic);
if (!Calypso_subscribe(0, 1, &nodeCommand)) {
WE_APP_PRINT("MQTT subscription fail\r\n");
currentState = SerialFeatherWing_SM_Idle;
} else if (currentState == SerialFeatherWing_SM_MQTT_Subscribe) {
currentState = SerialFeatherWing_SM_Idle;
}
break;
}
#endif
case SerialFeatherWing_SM_Module_Send: {
#if FeatherWing == CalypsoWiFiFeatherWing
if (!Calypso_MQTTPublishData((char *)MQTT_Publish_Topic, 0,
RXRSbuffer, strlen(RXRSbuffer))) {
WE_APP_PRINT("Not able to send broadcast\r\n");
}
#elif FeatherWing == ThyoneWirelessFeatherWing
if (ThyoneI_TransmitBroadcast((uint8_t *)RXRSbuffer,
strlen(RXRSbuffer))) {
WE_APP_PRINT("Broadcast sent! \r\n");
}
#endif
currentState = SerialFeatherWing_SM_Idle;
break;
}
case SerialFeatherWing_SM_RS_Send: {
#if FeatherWing == CalypsoWiFiFeatherWing
#if SerialCommunicationStandard == RS232
WE_UART_RXPin11_TXPin10_Transmit((const uint8_t *)RXModulebuffer,
strlen(RXModulebuffer));
#elif SerialCommunicationStandard == RS485
digitalWrite(12, HIGH);
WE_UART_RXPin11_TXPin10_Transmit(RXModulebuffer,
strlen(RXModulebuffer));
digitalWrite(12, LOW);
#endif
#elif FeatherWing == ThyoneWirelessFeatherWing
#if SerialCommunicationStandard == RS232
WE_UART_RXPin0_TXPin1_Transmit((const uint8_t *)RXModulebuffer,
strlen(RXModulebuffer));
#elif SerialCommunicationStandard == RS485
digitalWrite(12, HIGH);
WE_UART_RXPin0_TXPin1_Transmit(RXModulebuffer,
strlen(RXModulebuffer));
digitalWrite(12, LOW);
#endif
#endif
WE_APP_PRINT("Data sent! \r\n");
currentState = SerialFeatherWing_SM_Idle;
break;
}
default:
break;
}
}The quick start examples in the SDK are written to be run on Adafruit Feather M0 express. The hardware setup is as simple as stacking up the FeatherWing on top of the M0 Feather and powering up the board.
-
Clone or download the code.
-
Open the workspace of interest with the filename
<FeatherWing>.code-workspacein Visual Studio Code. -
Build and upload the code from the PlatformIO tab as shown in the Figure below
-
After successful upload, click on Monitor in PlatformIO extension tab to view the debug logs in the serial terminal.

