Pages: [1]   Go Down
Author Topic: Arduino Temperature Sensor receiver  (Read 3032 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The last past years a lot of people have used an arduino to receive and process RF433 Temperature sensors.
At home I have some cresta temperature sensors which I would like to use within my domotica system.
On the internet there are a lot of codes available which handle the different brands of sensors.

About the cresta system there is little information available, so I have to adjust a know script to handle these
sensors. The problem I face is that I don't know how to correctly receive an decode the message send by the
sensor.

The information which is know to this point is:

Pulse widths: http://jeelabs.org/?s=cresta
Used protocol: http://members.upc.nl/m.beukelaar/Crestaprotocol.pdf

I hope someone here is able to get me started to receive the signal with my arduino and velleman RF433 receiver...

Regards,

Peter
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12482
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Do you receive any signal with the Velleman RF433 ?
Has it a signal strength pin ?
URL/datasheet?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Datasheet velleman rx433 receiver: http://www.designnotes.com/Merchant2/merchant.mvc?Screen=PROD&Product_Code=RX433&Category_Code=secd

I am able to receive kaku signals with scripts from other websites..

Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12482
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what are kaku signals?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

kaku = Klik aan Klik uit

Link: http://www.klikaanklikuit.nl/
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In my attempt to receive the cresta sensor I am now able to receive some signals. For this I use the script below found elsewhere. I adapted te script a little for this use.
As can be seen below I can receive a KAKU signal which has 50 edges. Next to these signals I see a repeating signal with around 130 edges, which I believe is a temp Sensor.

The problem I need some help with is to display not the time between the edges, but the signal it self binairy.

Used code:
Code:
//RF TEST MODULE
//connect RSSI pin receiver to DIO8 and DATA pin receiver to DIO2


#include <avr/interrupt.h>

#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

//#define debug

#define BUFSIZE 150
#define NUMBUF  2
#define TRIGGERPIN 12
#define INTERESTING_LOW_SIGNAL 450

volatile uint16_t buffer[NUMBUF][BUFSIZE+1]; //In eerste veld het aantal gevonden edges opslaan

volatile short unsigned int bufIndex,bufFree,bufIn, bufOut;
volatile byte nextPulse;
volatile unsigned int prevTime;
volatile boolean listening=false;


ISR(TIMER1_OVF_vect) {
  stopTimer();
  //Serial.println("Timer overflow");
}

ISR(TIMER1_CAPT_vect) {
  unsigned int newTime=ICR1, duration; //gemeten tijd opslaan

    if (nextPulse) {     
    //wachten op een '0' (neergaande flank)
    cbi(TCCR1B,ICES1);
    nextPulse=0;
  }
  else {     
    //wachten op een '1' (opgaande flank)
    sbi(TCCR1B,ICES1);
    nextPulse=1;
  }

  //Pas beginnen met opslaan als het signaal lange tijd laag is geweest. Abuse de bufIndex van de opslagarray hiervoor.
  duration=newTime-prevTime;
  if (bufIndex>=1 && bufFree>0) {
    buffer[bufIn][bufIndex]=duration;

    //Was afgelopen puls een lange 0?
    if (nextPulse==0 && duration>=INTERESTING_LOW_SIGNAL) {
      //Ja. We hebben een signaal ontvangen!
      buffer[bufIn][0]=bufIndex;//Aantal edges opslaan
      bufIn=(bufIn+1)%NUMBUF; //Volgende buffer gebruiken
      bufFree--; //Aantal vrije buffers--
      bufIndex=1; //En meteen weer door!
      newTime=TCNT1=0; //Time-out timer resetten       
    }
    else {
      //Nee. Maar is de buffer nu vol?
      if (bufIndex==BUFSIZE) {
        //Ja. Hm. Dan hebben we niets meer aan de data in deze buffer
        bufIndex=0; //Buffer resetten, en wachten op een nieuwe lange 0.           
        return;
      }
    }
    bufIndex++;
  }
  else if (duration>=300 && nextPulse==0 && bufFree>0) {
    bufIndex=1; //vanaf nu opslaan     
    newTime=TCNT1=0; //Time-out timer resetten
  }
  prevTime=newTime;
}

void setup() { 
  Serial.begin(115200);
  Serial.println("Receiver ready");
  #ifdef debug
  Serial.println("Debug mode active");
  #endif
 
  bufIndex=0;
  bufFree=NUMBUF;
  bufIn=0;
  bufOut=0;

  //Zet interrupts. Zie 14.11

  TCCR1A=0;   //Normal mode (timer)

  TCCR1B=0<<ICES1 | 1<<CS12 | 0<<CS11 | 0<<CS10 | 1<<ICNC1;  //Pre-scaler: 256, noise canceler, interrupt on edge: faling

  TIMSK1=0<<ICIE1;  //Disable timer event interrupt

  pinMode(TRIGGERPIN,INPUT);
  pinMode(13,OUTPUT);

  digitalWrite(TRIGGERPIN,LOW);   //externe pull-up gebruikt; disable interne pull-up

  attachInterrupt(0,startTimer,FALLING); //start de timer als er een goed signaal op RSSI-uitgang is.
}

void loop() { 
  while(bufFree<NUMBUF) {

    //Outputformaat: <buffer> <#edges> <data[0]> <data[1]> <data[2]> ... LF
    if (buffer[bufOut][0] <= 45) {
      #ifdef debug
      Serial.println("Signal invalid, less than 45 edges");
      #endif
    bufOut=(bufOut+1)%NUMBUF;
    bufFree++;
    } else {
    #ifdef debug
    if (buffer[bufOut][0] >= 45 && buffer[bufOut][0] <= 55) {
    Serial.print("Type: KAKU");
    }
    if (buffer[bufOut][0] >= 125 && buffer[bufOut][0] <= 140) {
    Serial.print("Type: Sensor");
    }
    if (buffer[bufOut][0] <= 45) {
    Serial.print("Type: unknown");
    }
    if (buffer[bufOut][0] >= 140) {
    Serial.print("Type: unknown");
    }
    if (buffer[bufOut][0] >= 55 && buffer[bufOut][0] <= 125) {
    Serial.print("Type: unknown");
    }
    #endif
    //Serial.print("Buffer:");
    //Serial.print(bufOut,DEC);
    Serial.print(" ");
    Serial.print("Edges:");
    Serial.print(buffer[bufOut][0], DEC);
    Serial.print(" ");
    Serial.print("DATA:");
    for (int i=1;i<=buffer[bufOut][0];i++) {
      //if (buffer[bufOut][i] >= 45) {
      //Serial.print("0");
      //} else {
      //Serial.print("1");
      //}
      Serial.print(buffer[bufOut][i],DEC);
      Serial.print("|");
    }
     Serial.println("");
    bufOut=(bufOut+1)%NUMBUF;
    bufFree++;
  }
  }
}

void startTimer() {
  //disable interrupts
  cli();

  detachInterrupt(0); //stop luisteren op RSSI-uitgang

  //De timer begint te lopen vanaf het moment dat er een '1' binnenkomt.
  //Het wachten is nu op een '0' (neergaande flank)
  nextPulse=0;
  cbi(TCCR1B,ICES1);

  // reset TCNT1
  TCNT1 = 0;

  //Enable timer interrupt; start timer
  TIMSK1=1<<ICIE1 | 1<<TOIE1;

  //geef aan dat er eerst gewacht moet worden op een lange 0.
  bufIndex=0;

  prevTime=0;

  //clear eventuele openstaande interrupts.
  TIFR1=0xff;

  listening=true;

  digitalWrite(13,HIGH); //ledje aan

  //enable interrupts
  sei();
}

void stopTimer() { 
  TIMSK1=0; //Disable timer interrupt; Stop edge timer, stop overflow interrupt
  listening=false; 
  digitalWrite(13,LOW); //ledje uit
  attachInterrupt(0,startTimer, FALLING); //start de timer als er een signaal is.
}


Received signal:
Code:
Edges:119 DATA:78|15922|8|47|14|45|16|49|12|119|3|169|14|48|13|75|47|75|16|43|18|41|51|70|52|40|21|69|53|69|53|39|22|69|23|38|53|39|22|39|22|38|23|69|23|38|23|38|23|37|24|37|54|37|24|67|25|37|24|36|25|36|25|36|56|66|55|67|25|36|25|36|55|36|25|36|25|67|25|35|56|66|56|66|57|65|56|66|57|34|26|35|27|34|27|65|56|66|26|35|56|66|57|64|57|35|27|64|27|34|27|34|27|34|58|33|27|10|3427|
 Edges:137 DATA:1173|70|52|69|53|68|24|36|25|36|55|37|24|36|25|37|24|37|24|37|24|67|55|36|26|36|24|36|25|36|25|66|56|66|26|35|26|35|56|66|57|34|27|64|57|66|56|35|26|36|25|66|56|35|26|35|26|35|26|65|27|34|27|34|27|34|27|34|58|33|27|65|27|34|27|34|27|34|27|34|58|64|57|65|27|34|27|34|57|34|27|34|28|63|28|34|58|63|58|64|59|63|59|63|59|33|27|34|28|33|28|63|59|63|28|33|28|33|28|33|59|63|28|33|59|32|29|32|29|32|29|62|60|32|29|8|3405|
 Edges:133 DATA:78|67|55|67|55|67|25|35|26|35|56|36|25|36|25|36|25|36|25|35|26|67|55|36|25|35|26|36|25|35|26|65|58|64|27|34|27|34|58|64|58|33|28|64|58|64|57|34|27|65|57|35|26|34|28|33|28|33|27|64|29|32|29|32|29|32|28|33|59|33|28|63|29|32|29|32|29|32|28|33|59|63|58|64|28|33|28|33|59|32|29|33|28|63|28|33|59|62|60|63|59|63|59|63|59|32|29|32|29|32|29|62|60|62|29|32|60|32|29|32|29|62|60|62|60|62|60|62|60|31|30|7|12827|
 Edges:51 DATA:24|28|51|29|51|29|50|30|50|29|51|30|50|30|50|30|49|31|49|31|49|30|50|29|51|30|50|69|11|28|52|67|13|27|53|67|13|27|53|66|14|26|54|26|53|27|53|67|13|27|611|
 Edges:51 DATA:38119|26|53|27|53|27|53|26|54|26|54|26|54|26|53|27|53|27|53|27|53|27|53|26|53|27|53|66|15|25|55|64|16|24|55|65|15|25|55|66|14|26|54|26|54|26|53|66|14|26|613|
 Edges:51 DATA:24|26|54|26|54|26|53|26|54|26|54|26|54|25|55|25|55|25|54|26|54|26|54|25|55|25|55|65|15|25|55|64|16|24|56|64|16|24|55|66|15|25|54|26|54|26|54|65|15|25|613|
 Edges:51 DATA:38119|25|54|25|55|26|54|25|54|26|55|24|55|25|55|26|54|25|55|25|55|25|54|26|55|24|55|65|15|24|57|63|17|23|56|64|16|24|56|64|16|25|55|25|55|24|56|64|16|24|614|
 Edges:51 DATA:24|25|55|24|56|25|55|24|55|25|55|25|55|24|56|25|55|24|56|24|55|25|55|64|16|24|56|64|16|24|56|63|17|23|57|63|17|23|57|64|16|64|16|63|17|64|16|63|17|23|615|
 Edges:51 DATA:38119|23|56|24|56|24|56|23|56|24|56|24|56|24|56|24|56|23|57|23|56|25|55|64|16|23|57|64|16|23|57|63|17|23|57|63|17|23|57|63|17|63|17|63|17|63|17|63|17|23|615|
 Edges:51 DATA:24|23|56|24|56|24|55|24|56|24|56|24|56|24|56|24|56|23|57|23|56|24|56|64|17|22|58|62|17|23|58|62|17|23|58|62|17|23|57|64|15|64|17|63|17|63|16|64|17|23|13310|

Regards, Peter
Logged

Pages: [1]   Go Up
Jump to: