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

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview