Sunteți pe pagina 1din 3

Application Note EnOcean NEST simple usage example OP-AN-023

Device: openPicus FLYPORT and EnOcean Nest IDE version: 2.2 External Libs: EnOcean_ESP3, tools OpenPicus Free IDE Connections: -

Description
This app is a simple example of how to use the EnOcean NEST to interface Flyport modules with the EnOcean sensors and actuators.

The provided firmware contains libraries able to send and receive the EnOcean radio packets.

Brief introduction
EnOcean NEST can be used with both FLYPORT Wi-Fi or FLYPORT Ethernet modules. EnOcean is a wireless standard for Home Automation devices. The main advantage of this technology is the installation it's very easy (no wires and no masonry works needed). EnOcean pushes technology and environmental responsibility to the limits. EnOcean modules combine micro-energy converters with ultra low power electronics and reliable wireless communications. This enables EnOcean customers to create self-powered wireless sensor solutions that are fundamental for efficiently managing energy in buildings and industrial applications (please refer to www.enocean.com for further reference). This expansion board is a great tool to create Smart Building automation based on Flyport programmable modules. Create a low cost Internet gateway for EnOcean devices to access your home using a Smartphone or a Tablet. Onboard is the 868Mhz EnOcean transceiver TCM-310 connected to Flyport using UART port. The source code available let's you send/receive EnOcean telegrams to/from the devices.

EnOcean libraries
The libraries needed by EnOcean NEST are EnOcean_ESP3 and tools. EnOcean_ESP3 library performs the validation of data with CRC8 calculation, in both receive and transmit directions.

Command
UARTSendPacket ( int port, UINT8 *buf) getPacket ( UINT8 *pBuffer, UINT32 length)

Description
Function to send the provided radio telegram over the air. UART port to use packet to send Function to process the received radio telegram. The buffer that contains the data to process and validate The length of data

www.openpicus.com

Application Note OP-AN-023

rev.1.0 19.09.2012

Page

Every radio telegram have a ESP3 packet type. To help with the hex code of the different types the following enumeration is defined inside EnOcean_ESP3.h: typedef enum { RADIO = 0x01, RESPONSE = 0x02, RADIO_SUB_TEL =0x03, EVENT =0x04, COMMON_COMMAND = 0x05, SMART_ACK_COMMAND = 0x06, REMOTE_MAN_COMMAND = 0x07 }ESP3_PACKET_TYPE;

tools library is responsible of some advanced UART write functions.

EnOcean Nest firmware


The provided firmware example handles UART2 initialization to setup the EnOcean transceiver serial signals with Flyport pins, and baudrate. With the pressure of a button connected between expansion connector pin 5 (p9 of Flyport module) and GND it is possible to send a test radio telegram: if( IOButtonState(p9) == pressed) // p9 is Expansion connector pin 5 { /************************************************************************************* * UARTSendPacket information and usage: * Sync Byte (0x55) is automatically sent, not needed by this function * datalengthH, datalengthL, optionalDataLength, * Packet Type (RADIO, RADIO_SUB_TEL, etc... see EnOcean_ESP3.h: ESP3_PACKET_TYPE) * CRC8Header Byte is automatically calculated and sent, not needed by this function * data packets * optional data packets * CRC8Data Byte is automatically calculated and sent, not needed by this function ************************************************************************************/ UARTWrite(1, "\r\nsending..."); UINT8 testPacketSim[18] ={ 0x00, 0x07, 0x07, (UINT8)((ESP3_PACKET_TYPE)RADIO), 0xf6, 0x10, 0x00, 0x22, 0x3d, 0x0d, 0x30, 0x01, 0xff, 0xff, 0xff, 0xff, 0x39, 0x00}; result = UARTSendPacket(2,testPacketSim); UARTDebug("\r\n result= ", result); }

The receive is continuously checked by the condition if(UARTBufferSize(2)>1) { vTaskDelay(20); char receivedPacket[257]; toRead = 0; toRead = UARTBufferSize(2); UARTDebug32("\r\n Byte to read= ",toRead);

www.openpicus.com

Application Note OP-AN-023

rev.1.0 19.09.2012

Page

UARTRead(2,receivedPacket,toRead); result = getPacket((UINT8*)(receivedPacket), toRead); UARTDebug("\r\n return = ", result); UARTWrite(1,"\r\n"); IOPut(p19, toggle); IOPut(p21, toggle); UARTFlush(2); }

www.openpicus.com

Application Note OP-AN-023

rev.1.0 19.09.2012

Page

S-ar putea să vă placă și