With a focus on efficiency and connectivity, our EnOcean transceiver gateway module opens the door to a brighter, more connected future for your IoT projects.
A
A
Hardware Overview
How does it work?
EnOcean 4 Click is based on the TCM515U, a transceiver gateway module that operates at 902MHz radio band from EnOcean. Its fully integrated radio capability enables communications with other devices by using an onboard PCB antenna, so no additional antennas are needed for testing this device. The TCM515U can work in three functional modes: Telegram Reception, Telegram Transmission, Low Power Sleep. In receive mode, TCM515U processes received radio telegrams and verifies correct frame structure and check sum. In transmit mode, TCM515U receives radio telegrams for transmission from the external host via its
ESP3 interface. TCM515U can be set into a low power sleep mode for a defined period of time , after expiry of the requested sleep period, TCM515U will automatically wake-up and transition back to receive mode. Each TMC515U module contains it own EnOcean Unique Radio ID (EURID) which can be used during transmission for data authentication. Beside this feature, its also possible setting for each module Base ID or Broadcast ID depending from the application that you are designing. Another important feature is SLF (Security Level Format) which specifies the parameters of the encryption, authentication and rolling code algorithms
used for communication with a specific device, which eanbles TCM515U to encrypt and decrypt telegrams using AES128 based on a 16 byte security key. The TCM 515U provides a transparent radio link between EnOcean radio devices and an external host connected via UART interface using the standardized EnOcean Serial Protocol V3 (ESP3) communication protocol. The default interface speed for this module of the ESP3 (UART) interface is 57600. Additionally, it is possible to change the default ESP3 interface speed at power up from 57600 Bit per second to 460800 Bit per second by setting the TURBO pin to LOW.
Features overview
Development board
Fusion for STM32 v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different 32-bit ARM® Cortex®-M based MCUs from STMicroelectronics, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, Fusion for STM32 v8 provides a fluid and immersive working experience, allowing
access anywhere and under any circumstances at any time. Each part of the Fusion for STM32 v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.
Communication options such as USB-UART, USB HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. Fusion for STM32 v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU
Type
8th Generation
Architecture
ARM Cortex-M3
MCU Memory (KB)
1024
Silicon Vendor
STMicroelectronics
Pin count
144
RAM (Bytes)
131072
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic
Step by step
Project assembly
Track your results in real time
Application Output via UART Mode
1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.
2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.
3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.
4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.
Software Support
Library Description
This library contains API for EnOcean 4 Click driver.
Key functions:
enocean4_response_handler_set
- Handler Set function.enocean4_process
- Response Proccesing function.enocean4_response_ready
- Response Ready Check function.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file
* \brief Enocean4 Click example
*
* # Description
* This example reads and processes data from EnOcean 4 clicks.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and configures the click board.
*
* ## Application Task
* In the receiver mode, it waits for a telegram, then replies to it with the certain message.
* In the transmitter mode, first it sends the telegram with the certain message,
* then waits for a response.
*
* ## Additional Function
* - resp_message - Displays the response message on the USB UART.
* - packet_type - Displays the packet type message on the USB UART.
* - make_response - Driver handler function which stores data in the response buffer.
* - log_response - Displays a response on the USB UART.
* - send_telegram - Allows user to send a telegram to the determined destination.
* - check_response - Waits until response is ready, then displays it on the USB UART.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "enocean4.h"
#include "string.h"
// ------------------------------------------------------------------ VARIABLES
#define DEMO_APP_RECEIVER
// #define DEMO_APP_TRANSMITTER
#define DEMO_MESSAGE "MikroE"
#define DEMO_ANSWER "EnOcean 4"
enocean4_packet_t response;
enocean4_packet_t message;
uint8_t response_size_cnt;
uint8_t rsp_check;
uint8_t device_mode;
static enocean4_t enocean4;
static log_t logger;
// ------------------------------------------------------- ADDITIONAL FUNCTIONS
void resp_message( uint8_t resp_byte )
{
switch ( resp_byte )
{
case ENOCEAN4_RET_OK :
{
log_printf( &logger, "OK\r\n" );
break;
}
case ENOCEAN4_RET_ERROR :
{
log_printf( &logger, "ERROR\r\n" );
break;
}
case ENOCEAN4_RET_NOT_SUPPORTED :
{
log_printf( &logger, "NOT SUPPORTED\r\n" );
break;
}
case ENOCEAN4_RET_WRONG_PARAM :
{
log_printf( &logger, "WRONG PARAM\r\n" );
break;
}
case ENOCEAN4_RET_OP_DENIED :
{
log_printf( &logger, "OPERATION DENIED\r\n" );
break;
}
case ENOCEAN4_RET_LOCK_SET :
{
log_printf( &logger, "LOCK SET\r\n" );
break;
}
case ENOCEAN4_RET_BUFF_TO_SMALL :
{
log_printf( &logger, "BUFFER TO SMALL\r\n" );
break;
}
case ENOCEAN4_RET_NO_FREE_BUFF :
{
log_printf( &logger, "NO FREE BUFFER\r\n" );
break;
}
default :
{
log_printf( &logger, "0x%.2X\r\n", ( uint16_t ) resp_byte );
break;
}
}
}
void packet_type( )
{
switch ( response.packet_type )
{
case ENOCEAN4_PACK_TYPE_RADIO_ERP1 :
{
log_printf( &logger, "RADIO TELEGRAM : " );
break;
}
case ENOCEAN4_PACK_TYPE_RESPONSE :
{
log_printf( &logger, "RESPONSE : " );
break;
}
case ENOCEAN4_PACK_TYPE_RADIO_SUB_TEL :
{
log_printf( &logger, "RADIO SUBTELEGRAM : " );
break;
}
case ENOCEAN4_PACK_TYPE_EVENT :
{
log_printf( &logger, "EVENT : " );
break;
}
case ENOCEAN4_PACK_TYPE_COMMON_CMD :
{
log_printf( &logger, "COMMON COMMAND : " );
break;
}
case ENOCEAN4_PACK_TYPE_SMART_ACK_CMD :
{
log_printf( &logger, "SMART ACK COMMAND : " );
break;
}
case ENOCEAN4_PACK_TYPE_REMOTE_MAN_CMD :
{
log_printf( &logger, "REMOTE MAN COMMAND : " );
break;
}
case ENOCEAN4_PACK_TYPE_RADIO_MSG :
{
log_printf( &logger, "RADIO MESSAGE : " );
break;
}
case ENOCEAN4_PACK_TYPE_RADIO_ERP2 :
{
log_printf( &logger, "RADIO TELEGRAM ERP2 : " );
break;
}
case ENOCEAN4_PACK_TYPE_RADIO_802_15_4 :
{
log_printf( &logger, "802_15_4_RAW PACKET : " );
break;
}
case ENOCEAN4_PACK_TYPE_CMD_2_4 :
{
log_printf( &logger, "2.4 GHz COMMAND : " );
break;
}
default :
{
log_printf( &logger, "MSC - MESSAGE : " );
break;
}
}
}
void make_response( enocean4_packet_t *rsp, uint8_t *rsp_length_size )
{
uint16_t rsp_cnt;
for ( rsp_cnt = 0; rsp_cnt < rsp->data_length; rsp_cnt++ )
{
response.data_buff[ rsp_cnt ] = rsp->data_buff[ rsp_cnt ];
}
response.data_length = rsp->data_length;
response.opt_length = rsp->opt_length;
response.packet_type = rsp->packet_type;
response_size_cnt = *rsp_length_size;
}
void log_response( )
{
uint16_t rsp_cnt;
if ( rsp_check == 1 )
{
if ( ( response.packet_type == ENOCEAN4_PACK_TYPE_RESPONSE ) && ( response.data_length == 1 ) )
{
packet_type( );
resp_message( response.data_buff[ 0 ] );
return;
}
packet_type( );
rsp_check = 0;
}
if ( response.packet_type == ENOCEAN4_PACK_TYPE_RADIO_ERP1 )
{
for ( rsp_cnt = 1; rsp_cnt < response.data_length - 12; rsp_cnt++ )
{
log_printf( &logger, "%c", ( uint16_t ) response.data_buff[ rsp_cnt ] );
}
}
else
{
for ( rsp_cnt = 0; rsp_cnt < response.data_length; rsp_cnt++ )
{
log_printf( &logger, "0x%.2X ", ( uint16_t ) response.data_buff[ rsp_cnt ] );
}
}
if ( response_size_cnt == 0 )
{
log_printf( &logger, "\r\n" );
rsp_check = 1;
}
}
void send_telegram ( char *telegram, uint8_t tel_type )
{
uint16_t tel_length;
uint16_t tel_idx;
char *chr_ptr;
tel_length = 0;
chr_ptr = telegram;
while ( *chr_ptr != 0 )
{
tel_length++;
chr_ptr++;
}
// Packet Header
if ( tel_type == ENOCEAN4_RORG_ADT )
{
message.opt_length = 7;
}
else
{
message.opt_length = 0;
}
message.data_length = 6 + tel_length;
message.packet_type = ENOCEAN4_PACK_TYPE_RADIO_ERP1;
message.data_buff[ 0 ] = tel_type;
// Telegram Data
chr_ptr = telegram;
for ( tel_idx = 0; tel_idx < tel_length; tel_idx++ )
{
message.data_buff[ tel_idx + 1 ] = *chr_ptr;
chr_ptr++;
}
// Sender ID
message.data_buff[ tel_length + 1 ] = 0x04;
message.data_buff[ tel_length + 2 ] = 0x10;
message.data_buff[ tel_length + 3 ] = 0x0B;
message.data_buff[ tel_length + 4 ] = 0x8B;
// Status
message.data_buff[ tel_length + 5 ] = 0x00;
// Number of sub telegram
message.data_buff[ tel_length + 6 ] = 0x03;
// Destination ID
message.data_buff[ tel_length + 7 ] = 0x04;
message.data_buff[ tel_length + 8 ] = 0x10;
message.data_buff[ tel_length + 9 ] = 0x0B;
message.data_buff[ tel_length + 10 ] = 0x81;
// dBm
message.data_buff[ tel_length + 11 ] = 0xFF;
// Security Level
message.data_buff[ tel_length + 12 ] = 0x00;
enocean4_send_packet( &enocean4, &message );
}
void check_response( )
{
uint8_t response_ready;
enocean4_uart_isr( &enocean4 );
response_ready = enocean4_response_ready( &enocean4 );
while ( response_ready != ENOCEAN4_RESPONSE_READY )
{
enocean4_uart_isr( &enocean4 );
response_ready = enocean4_response_ready( &enocean4 );
Delay_1ms( );
}
enocean4_process( &enocean4 );
log_response( );
}
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
enocean4_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
enocean4_cfg_setup( &cfg );
ENOCEAN4_MAP_MIKROBUS( cfg, MIKROBUS_1 );
enocean4_init( &enocean4, &cfg );
Delay_ms ( 500 );
enocean4_response_handler_set( &enocean4, &make_response );
Delay_ms ( 300 );
rsp_check = 1;
enocean4_reset( &enocean4 );
log_printf( &logger, "** EnOcean 4 initialization done **\r\n" );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 500 );
// Clearing RX buffer
{
uint8_t tmp_buf[ 100 ];
enocean4_generic_read( &enocean4, tmp_buf, 100 );
}
log_printf( &logger, "Device version reading...\r\n" );
message.data_length = 0x0001;
message.opt_length = 0x00;
message.packet_type = ENOCEAN4_PACK_TYPE_COMMON_CMD;
message.data_buff[ 0 ] = ENOCEAN4_CMD_CO_RD_VERSION;
enocean4_send_packet( &enocean4, &message );
check_response( );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 500 );
log_printf( &logger, "Add filter to filter list...\r\n" );
message.data_length = 0x0007;
message.opt_length = 0x00;
message.packet_type = ENOCEAN4_PACK_TYPE_COMMON_CMD;
message.data_buff[ 0 ] = ENOCEAN4_CMD_CO_WR_FILTER_ADD;
message.data_buff[ 1 ] = ENOCEAN4_FILTER_TYPE_RORG;
message.data_buff[ 2 ] = 0x00;
message.data_buff[ 3 ] = 0x00;
message.data_buff[ 4 ] = 0x00;
message.data_buff[ 5 ] = ENOCEAN4_RORG_ADT;
message.data_buff[ 6 ] = ENOCEAN4_APPLY_RADIO_INTER;
enocean4_send_packet( &enocean4, &message );
check_response( );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 500 );
log_printf( &logger, "Supplied filters reading...\r\n" );
message.data_length = 0x0001;
message.opt_length = 0x00;
message.packet_type = ENOCEAN4_PACK_TYPE_COMMON_CMD;
message.data_buff[ 0 ] = ENOCEAN4_CMD_CO_RD_FILTER;
enocean4_send_packet( &enocean4, &message );
check_response( );
log_printf( &logger, "***********************************\r\n" );
log_printf( &logger, "Ready to exchange telegrams\r\n" );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 500 );
}
void application_task ( void )
{
#ifdef DEMO_APP_RECEIVER
log_printf( &logger, "Waiting for a telegram...\r\n" );
check_response( );
log_printf( &logger, "***********************************\r\n" );
log_printf( &logger, "Replying to the received telegram...\r\n" );
send_telegram( DEMO_ANSWER, ENOCEAN4_RORG_ADT );
check_response( );
log_printf( &logger, "***********************************\r\n" );
#endif
#ifdef DEMO_APP_TRANSMITTER
log_printf( &logger, "Sending a telegram...\r\n" );
send_telegram( DEMO_MESSAGE, ENOCEAN4_RORG_ADT );
check_response( );
log_printf( &logger, "***********************************\r\n" );
log_printf( &logger, "Waiting for a response...\r\n" );
check_response( );
log_printf( &logger, "***********************************\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END