Show Posts
|
|
Pages: [1]
|
|
2
|
Forum 2005-2010 (read only) / Bugs & Suggestions / Code to read EnOcean telegrams
|
on: November 30, 2007, 09:26:17 am
|
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. // 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.begin(9600); pinMode(ledPin,OUTPUT); digitalWrite(ledPin,HIGH); delay(250); digitalWrite(ledPin,LOW); Serial.println("EnOcean TCM120 reader"); } void loop() { while (Serial.available()) { packet[j++]=Serial.read(); j=j % 14; if(roly(j)==165 && roly(j+1)==90) //now we have sync bytes for packet { print_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]; }
|
|
|
|
|
3
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: can't print a float value???
|
on: February 06, 2007, 07:34:34 am
|
|
Thanks, but this is still a little confusing, so you are saying that printf is not available - although I have used it with integers?
But floating point is not available either? - but it is listed as an available data type.
I would really like to be able to use sprintf with strings at least. I want to do some base64 encoding in the module to be able to send emails, so some string manipulation will be important!
Is there any documentation of what is and is not available from standard 'C'?
|
|
|
|
|
4
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: can't print a float value???
|
on: February 05, 2007, 06:05:58 pm
|
|
I've seen a the same and similar problems, trying to use sprintf(dest,"%f %s",floatvalue,stringvalue);
Thinking that underneath the Arduino extensions there is C, I thought this would work, but does not?
Am I missing something simple (or being stupid) here?
Simon
|
|
|
|
|
5
|
Forum 2005-2010 (read only) / Development / Email and web server
|
on: November 29, 2007, 04:54:13 am
|
|
Hi,
I am developing a system to connect to WiFi using a ConnectOne iWiFi Socket device - I just wonder if anyone has any experience with this - or any modem drivers?
This device is a serial to WiFi module, and has email client etc built-in. I'm making a device to take in measurements from wireless and batteryless sensors using EnOcean STM 110 modules to monitor things like pond temperature, water flow and level and other sensors around the house, recieve them using an EnOcean TCM 120 connected to Arduino, then send email alerts using the ConnectOne module.
Biggest problem seems to be the fact I'll need two serial ports - one for the EnOcean receiver, and one for the WiFi module. Any easy way of creating two 19,200bps serial ports on the board?
|
|
|
|
|
7
|
Forum 2005-2010 (read only) / Interfacing / Re: Libelium GPRS module for Arduino power PROBLEMS!!!
|
on: June 03, 2009, 08:20:35 am
|
The peak currents of over 2A required by GSM modules are very short, the average currents when offline should be under a couple of milliamps or so. A capacitor should do it, providing it can supply the peak current for the 477uS required... www.tdc.co.uk have a webshop with Cinterion modules and boxed modems, the boxed modems (called 'terminals') are easier to power from ordinary 12V power supplied.
|
|
|
|
|
8
|
Forum 2005-2010 (read only) / Interfacing / Interfacing to EnOcean
|
on: June 03, 2009, 08:43:58 am
|
|
Thought I'd share this code that reads data from an EnOcean TCM120 so you can read data from the EnOcean wireless (and batteryless) sensors. Great for remote control and monitoring applications!
// 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]; //used as a rotational buffer int j=0;
void setup() { Serial.begin(9600); pinMode(ledPin,OUTPUT); digitalWrite(ledPin,HIGH); delay(250); digitalWrite(ledPin,LOW); Serial.println("EnOcean TCM120 reader"); //send_packet(0xAB,0x48,0,0,0,0,0,0,0,0); } void loop() { while (Serial.available()) { // Serial.print(packet[j],HEX); Serial.print(" "); packet[j++]=Serial.read(); j=j % 14; if((roly(j)==0xA5) && (roly(j+1)==0x5A)) { print_packet(j); if(roly(j+2)==0x0B) //now we have sync bytes for receive 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 j) { int i,ch=0; Serial.print("ORG:"); Serial.print(roly(j+3),HEX); Serial.print(" Data:"); for(i=j+4;i<=j+7;i++) { Serial.print(roly(i),HEX); Serial.print(" "); } Serial.print("ID:"); for(i=j+8;i<=j+11;i++) { Serial.print(roly(i),HEX); Serial.print(" "); } Serial.print("ST:"); Serial.print(roly(j+12),HEX); Serial.print(" Chk:"); Serial.print(roly(j+13),HEX); for(i=2;i<13;i++) ch=ch+roly(j+i); if((ch%0x100)==roly(j+13)) Serial.println(" OK"); else { Serial.print(" "); Serial.print(ch,HEX); Serial.println(" Error"); } }
void send_packet(int typ,int cmd,int D3,int D2,int D1,int D0,int D_3,int D_2,int D_1,int D_0) //not tested { Serial.print(0xA5,BYTE); Serial.print(0x5A,BYTE); Serial.print(typ,BYTE); Serial.print(cmd,BYTE); Serial.print(D3,BYTE); Serial.print(D2,BYTE); Serial.print(D1,BYTE); Serial.print(D0,BYTE); Serial.print(D_3,BYTE); Serial.print(D_2,BYTE); Serial.print(D_1,BYTE); Serial.print(D_0,BYTE); Serial.print(0,BYTE); Serial.print(0xff & (typ+cmd+D3+D2+D1+D0+D_3+D_2+D_1+D_0)); }
int roly(int n) { return packet[n%14]; }
|
|
|
|
|