• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


[Partially Supported] TFA / Conrad Weather
What about making this into a github pull-request?
 
Reply
(01-21-2019, 08:29 PM)curlymo Wrote: What about making this into a github pull-request?

Please no. I have looked at various pull requests, but have no idea how this works. I am not a programmer and my english is not good enough. Can anyone help and start a pull request? If any information is missing I will gladly deliver it.
 
Reply
You're not a programmer but did fix a protocol written in C and posted it on an english forum Surprised
 
Reply
Hello, I am not sure if this question fits here, but it is strongly connected to the discussed protocol :Smile
I am having trouble decyphering temperature and humidity from my weather station. It is supposed to use the TFA code. I do not use pilight but I have been able to extract the binary piece from the stream:
[ 1.,  1.,  1.,  0.,  0.,  0.,  0.,  1.,  1.,  0.,  0.,  0.,  0., 1.,  0.,  0.,  0.,  1.,  1.,  0.,  0.,  1.,  0.,  0.,  0.,  1.,
        0.,  1.,  0.,  1.,  1.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.,  1.]
My timing stream has a pattern like this: 6-pair header starting with [610 16000 ...], then 40 bits that can be translated to the binary array above. A list of timings for one signal can be found here: pastebin.com/J5CyHX3P

I tried the temperature/humidity conversion from the Wiki on TFA, starting at each digit, I tried reversing the temperature digits but I do not get any humidity or temperature that matches the displayed values of the weather station. I would REALLY appreciate any hint on what else I could try. Thanks!
 
Reply
I would start providing information garthered using pilight in a new topic following the topic rules.
 
Reply
Hello I would like to build my own Sensor using the TFA protocol  which reports to pilight.
Is there a checksum implemented in pilight which prevents to change the values (Temp, etc.).

pilight does not recognize the value if temp,humid, etc is changed.
There must be a checksum, can somebody help me with that ?


Code:
#include <RFControl.h>
#include <string.h>
#include <math.h>

const int PIN_LED = 11;
  byte txPin = 10; // digital pin for RF transmitter
// byte houseCode = 15; // from 1 to 15
// byte channelCode = 4; // from 1 to 4
  long myTimer = 0;
  long myTimeout = 10000;
  double t = 18.55;
  int h = 71;

int crccheck (char  binary[], int size, int refvalue)
{
  int crc=0;
  Serial.print("\nCRC-Ckecking:");
  for(int i=0;i<size;i++) {
              int value = binary[i] - '0';
              
                if (value !=2 && value !=3 && value !=4) {  
                                                              Serial.print(value);
                                      if( value != (crc&1))
                                        {
                                            crc = (crc>>1) ^ 12;
                                        } else
                                         {
                                          crc = (crc>>1);
                                         }
                                    }
              }
    //crc ^= binToDec(binary, 34, 37);
    //if (crc != binToDec(binary, 38, 41)) {
    //int ycrc = crc ^ 0b0000;
     Serial.print("\nCRC RAW:");
     Serial.print(crc);
          crc ^= refvalue;
        Serial.print("\nCRC Check Test:");
         Serial.println(crc);
      return crc ;
    
}



void decimaltobyte(int n,char *array, int size){
                                                 for (int i = size-1; i >= 0; i--) {
                                                                                    int k = n >> i;
                                                                                  
                                                                                    if ((k & 1) > 0)
                                                                                        {
                                                                                          strcat(array, "21");
                                                                                        }
                                                                                    else
                                                                                    {
                                                                                     strcat(array, "20");
                                                                                    }
                                                                                }
                                            }

String CompressedTimingsConstructor( double tempC,int humidity){
                                  char myarray[100]="";
                                  int TempFahrenheit=round( ((tempC *9/5)+90+32)*10 );
                                  unsigned int Temp= (((TempFahrenheit & 0b000000001111)<< 8) + ((TempFahrenheit & 0b000011110000) ) + ((TempFahrenheit & 0b111100000000)>>8)) ;
                                  Serial.print("tempdata:");
                                  Serial.println((Temp));
                                  int Zerofill= 0b00;
                                  int id = 0b0000011000; ///24
                                  int Channel = 0b00 ;//3
                                  int Hum=((humidity & 0b00001111)<<4) + ((humidity  & 0b11110000)>>4);
                                  int Bat=0b00;
                                  //int Checksum=0b0010;
                                    decimaltobyte(id, myarray,10);  //L:10
                                    decimaltobyte(Channel,myarray,2);//L:2
                                    decimaltobyte(Zerofill, myarray,2); //L:2
                                    decimaltobyte(Temp, myarray,12);//L:12
                                    decimaltobyte(Hum, myarray,8);//L:8
                                    decimaltobyte(Bat, myarray,4);//L:4
                                    int crc_check=crccheck (myarray, ((34*2)), Bat);
                                    decimaltobyte(crc_check,myarray,4);
                                    strcat(myarray,"23");
                                  // Serial.print("MYCompressed:");
                                  // Serial.println(myarray);
                                   String s=myarray;
                                   return s;
                                    }



  
  
  
  

char compressTimings3[] = {"20202020202121202020202020202020212020202021202121202120202120202121202020202020212023"}; //working -"000001100000000010000101101001001100000010" L:42


/
//Dostmann TFA -Basic
/*

    498 1992 - Low
    498 4233  - High
           ID : 00011000 | Channel : 00 | Temp : 011000010010 | Hum : 00111001 | Bat : 00
                00011000             10          111000110110         00110110         0 13

*/


unsigned long buckets[] = {1992, 4233, 498,8466};
// unsigned long buckets[] = {2000, 4300, 500,8500}; //not working
    
  void setup() {
  
  pinMode(PIN_LED, OUTPUT);
  Serial.begin(9600);
  
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
  //RFControl::startReceiving(0);

// mySwitch.enableTransmit(10);
  digitalWrite(PIN_LED,LOW);
  
// sender.setup(txPin, houseCode, channelCode);
}



void loop() {


  if (millis() > myTimeout + myTimer ) {
                                            myTimer = millis();
          

                                                                                            
                                               String tempstring=CompressedTimingsConstructor(t,h);
                                               int sizeString=tempstring.length()+1;
                                               char compressTimings[sizeString];
                                               //copy to compressTimings
                                               tempstring.toCharArray(compressTimings,(sizeString));
                                              
                                               Serial.print("\ntempstring:");
                                               Serial.println((tempstring));
                                              
                                              Serial.print("Size of tempstring:");
                                              Serial.println(sizeString);
                                              
                                                                                              Serial.print("\n compressTimings:");
                                                                                              Serial.println(compressTimings);
                                                                                              Serial.print("Temp:");
                                                                                              Serial.println(t);
                                                                                              Serial.print("Hum:");
                                                                                              Serial.println(h);
                                                                                              RFControl::sendByCompressedTimings (txPin, buckets , compressTimings, 8);

      
  
   }
 
Reply
Functions in RFControl libary to see which the main Program uses:


Code:
void listenBeforeTalk()
{
 // listen before talk
 unsigned long waited = 0;
 if(interruptPin != -1) {
     waited += 500;
     hw_delayMicroseconds(500);
   while(state > STATUS_RECORDING_0 && state != STATUS_RECORDING_END) {
     //wait till no rf message is in the air
     waited += 5;
     hw_delayMicroseconds(3); // 5 - some micros for other stuff
     // don't wait longer than 5sec
     if(waited > 5000000) {
       break;
     }
     // some delay between the message in air and the new message send
     // there could be additional repeats following so wait some more time
     if(state <= STATUS_RECORDING_0 || state == STATUS_RECORDING_END) {
       waited += 1000000;
       hw_delayMicroseconds(1000000);
     }
   }
   // stop receiving while sending, this method preserves the recording state
   hw_detachInterrupt(interruptPin);  
 }
 // this prevents loosing the data in the receiving buffer, after sending
 if(data1_ready || data2_ready) {
   state = STATUS_RECORDING_END;
 }
 // Serial.print(waited);
 // Serial.print(" ");
}

void afterTalk()
{
 // enable reciving again
 if(interruptPin != -1) {
   hw_attachInterrupt(interruptPin, handleInterrupt);
 }
}


void RFControl::sendByCompressedTimings(int transmitterPin,unsigned long* buckets, char* compressTimings, unsigned int repeats) {
 listenBeforeTalk();
 unsigned int timings_size = strlen(compressTimings);
 hw_pinMode(transmitterPin, OUTPUT);
 for(unsigned int i = 0; i < repeats; i++) {
   hw_digitalWrite(transmitterPin, LOW);
   int state = LOW;
   for(unsigned int j = 0; j < timings_size; j++) {
     state = !state;
     hw_digitalWrite(transmitterPin, state);
     unsigned int index = compressTimings[j] - '0';
     hw_delayMicroseconds(buckets[index]);
   }
 }
 hw_digitalWrite(transmitterPin, LOW);
 afterTalk();
}
 
Reply
Have you checked the source of the pilight protocol? Maybe that helps, since you are a developer yourself.
 
Reply
(03-23-2020, 06:29 PM)curlymo Wrote: Have you checked the source of the pilight protocol? Maybe that helps, since you are a developer yourself.

Yes i checked, but your code ist next level for me.  I reached a dead end for me. Perhaps you can help me with this last part.


In the pilight CodeI found in tfa.c:


Code:
for(i=0;i<34;i++) {

if(binary[i] != (crc&1)) {

crc = (crc>>1) ^ 12;

} else {

crc = (crc>>1);

}

}

crc ^= binToDec(binary, 34, 37);

if (crc != binToDec(binary, 38, 41)) {

return; // incorrect checksum

}



Working Raw Signal: 000001100000000010000101101001001100000010

CRC check of 34 bits = 4
|0000011000000000100001011010010011 |0000 0010


0b0100 XOR 0b0000 = 0b0100
0000011000000000100001011010010011 |0000| 0010


Extract CRC Value = 0b0010
00000110000000001000010110100100110000 |0010|
00000110000000001000010110100100110000 0100

Comparing both Values CRC:

0b0100 != 0010 = true;

crc ^= binToDec(binary, 34, 37);
if (crc != binToDec(binary, 38, 41)) return "error":
 
Reply
An would you like to explain :
For the TFA protocol I found
000001100000000010000101101001001100000010 - Length 42, for 2 Singal Pulses = 84 + Footer (2 Pulses)=86

498 1992 = Two Pulses Low Signal 
Are 498 and 1992 the pulse length =  AVG_PULSE_LENGTH * SomeFactor ?
498 4233  = Two Pulses High Signal.


MIN_PULSE_LENGTH
MAX_PULSE_LENGTH
 AVG_PULSE_LENGTH 235
 RAW_LENGTH 88                  //This seems  to clear (Signalpulse + Footer)

#define MIN_RAW_LENGTH 76 // SOENS, NC7104-675, GT-WT-01 (Signalpulse + Footer)

#define MED_RAW_LENGTH 86 // TFA Number of Pulses

#define MAX_RAW_LENGTH
#define PULSE_MULTIPLIER 13
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Fully Supported] KlikAanKlikUit Motion Sensor koen01 37 14,776 03-26-2020, 02:46 PM
Last Post: Gisto
  inFactory Weather Sensors porst17 1 319 12-26-2019, 06:43 PM
Last Post: porst17
Lightbulb [Fully Supported] Kaku Door sensor (AMST-606) geerttttt 53 28,003 10-19-2019, 06:26 PM
Last Post: curlymo
  Bresser 3Ch weather sensors Harald654 13 5,786 02-15-2019, 01:06 PM
Last Post: saak2820
  [Fully Supported] DHT22 IcedEarth 86 36,215 11-18-2018, 09:33 AM
Last Post: curlymo
  Weather Station Globaltronics GT-WT-01 Prutsky 13 8,338 04-09-2018, 07:34 PM
Last Post: NevelS
  [Fully Supported] Arctech Old Martin 111 41,295 03-27-2018, 04:43 PM
Last Post: genfersee
  [Fully Supported] Clarus Switches Marcin 69 28,992 01-30-2018, 07:10 PM
Last Post: Niek
  [Fully Supported] Remote Control Socket (RC101-U/RC201) Sean 18 12,565 01-04-2018, 06:18 AM
Last Post: ettman8
  [Fully Supported] LM75 and LM76 temperature sensor horst_dieter 64 28,445 11-19-2017, 08:54 PM
Last Post: edepi

Forum Jump:


Browsing: 1 Guest(s)