Go Down

Topic: Code to read EnOcean telegrams (Read 1 time) previous topic - next topic


This reads a TCM 120 connected to the serial port, and switches an LED on from the signals received from the wireless, batteryless transmitters.

This is the first part of my WLAN/email to EnOcean bridge I am developing.

Code: [Select]
// EnOcean reader
// Simple code to read an EnOcean telegram - does not check ID of transmitter at this stage, so will operate from ANY switch

int ledPin=13;
int packet[14];
int j;

void setup()
 Serial.println("EnOcean TCM120 reader");

void loop()

while (Serial.available())
  j=j % 14;
  if(roly(j)==165 && roly(j+1)==90) //now we have sync bytes for packet
    if((roly(j+3)==5) && (roly(j+4)==80)) digitalWrite(ledPin,HIGH); //switch is pressed ON
    if((roly(j+3)==5) && (roly(j+4)==0 )) digitalWrite(ledPin,LOW);  //switch released

void print_packet()
 int i;
 Serial.print("ORG:");   Serial.print(roly(2),HEX);
 Serial.print(" Data:"); for(i=4;i<=7;i++)  { Serial.print(roly(i),HEX); Serial.print(" "); }
 Serial.print("ID:");    for(i=8;i<=11;i++) { Serial.print(roly(i),HEX); Serial.print(" "); }
 Serial.print("ST:");    Serial.print(roly(12),HEX);
 Serial.print(" Chk:");  Serial.println(roly(13),HEX);

int roly(int n)
return packet[n%14];

Go Up