Pages: 1 2 3 [4] 5   Go Down
Author Topic: 433 MHz RF - Temperature and humidity sensor  (Read 31382 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just for clarity, I'm not saying that the sensor only reads up to 25.5, only that it's simple to read, if it is in the range 0 to 25.5 becuase it occupies the eight bits between 16 and 23 as a straight forward .1 degree scale.

The bits between 12 and 15 are also included which allows readings greater than 25.5 and less than 0, it's just that I haven't worked out how to deal with that yet.
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi andriej,

Have you got any further in trying to work out the CRC? I came across an interesting article here but to have a chance of calculating the Polynomial I need several consecutive readings that vary by only one bit between them. I had a look at all your results but cannot find enough samples to do this yet. I'm still trying though.
Logged


Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

I didn't manage to do it yet. I also couldn't get the two libraries to work on same receiver unfortunately.
I can get the receiver on separate arduino and run it for sereral hours to get readings one by one with values, so they may vary a little. I'll do this today right after work.
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I also couldn't get the two libraries to work on same receiver unfortunately.
If your receiver has 2 outputs did you try connecting one to the weather sensor receive interrupt pin and the other to the remote interrupt pin and see if they work side by side?
I can get the receiver on separate arduino and run it for sereral hours to get readings one by one with values, so they may vary a little. I'll do this today right after work.
Thanks, but no hurry. I'm working all weekend so may or may not have time to play.
Logged


Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code works - the third interrupt gets data. But - again - strange thing happens...
It reads the code only when sensor is very,very near the Mega.
On Uno it read without problems from outside.

I have no clue why it could happen now...
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code works - the third interrupt gets data. But - again - strange thing happens...
It reads the code only when sensor is very,very near the Mega.
On Uno it read without problems from outside.

I have no clue why it could happen now...
I can only guess the Mega is generating RF noise that interferes badly at 433Mhz. I'm not sure if you could test this by laying the Mega in a biscuit tin lined with something to prevent Mega shorting out and and lay the lid on top. Run the wires to the receiver outside of the tin.  This wont stop all noise but may eliminate radiated RF. Beyond this you may need RF chokes but this is not my field and someone else may have better suggestions.
Logged


Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got tired of wondering why it didn't work and I wired one of my nodes (used in room anyway) to weather station. Same scheme - DATA (pin2), GND-GND.
It works even better than on the receiver module (as it now gets a lot more readings).

It's getting readings ATM and will do overnight, but before that I saw same-readings with different CRC (only once happened so far):
Code:
001110100101011000111001001000010 100100110 - Battery=1 Channel=1 Temperature=35.6F Humidity=88%
0011101001010110001110010010000101 00000100 - Battery=1 Channel=1 Temperature=35.6F Humidity=88%

You can see the station and the receiver itself in left top corner here:
« Last Edit: February 23, 2013, 02:15:02 pm by andriej » Logged

Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, so after almost all-night logging I've put up to the google doc (at the bottom, below arduino code): https://docs.google.com/document/d/121ZH3omAZsdhFi3GSB-YdnasMjIQSGIcaS7QW6KsACA/edit?usp=sharing
all the values that didn't duplicate one by another (signal is so strong, that your code puts up like 5-6 readings at the time).

Also - strange thing (or we don't know everything). A lot of readings shows 'battery=0', but weather station doesn't report battery as 'low' (the indicator doesnt show up). Maybe the 'low batt' bit is hidden somewhere else?
« Last Edit: February 25, 2013, 05:11:36 am by andriej » Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the extra data buy after looking for several readings that only alter by 1 bit in the data (not CRC) I cannot find what I'm looking for. It could take weeks to collect enough data to get the value I need and a long time sorting the data to find them.
Only idea I can think of is a little drastic if your not into soldering and that's to de-solder the temperature sensor so the temperature will never change and only humidity values will alter.
As to the battery indicator bit, yes this probably could be wrong. Does the base station have several degrees of battery power indication (like bars on a mobile phone battery indicator) or is it a simple good/bad indication? Powering the sensor from a bench PSU would allow accurate voltage adjustments and the battery indicator on the base station could be noted as the power is slowly decreased and the data captured. This would help narrow down the battery bit(s).
Logged


Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I might try desoldering as I don't have problems with understanding it and there are no SMD elements. I just wonder how will sensor act without the temperature. :-)

How much data do you guess you need of the humidity only?

I might also look for some old AA batteries to test the indicator. I don't have laboratory PSU, only one running 3.3V but might to try get voltage down with resistor or sth.
Weather station only shows 'low' battery (if its good, nothing shows up).

Regards
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I might try desoldering as I don't have problems with understanding it and there are no SMD elements. I just wonder how will sensor act without the temperature. :-)
I would expect it to be a fixed temperature value

How much data do you guess you need of the humidity only?
I'm looking for readings that differ by only 1 bit each (See http://fredboboss.free.fr/tx29/tx29_crc.php) so I have a chance of working out the polynom (Assuming it's standard CRC). So for example the humidity values would need to be something like 80%, 81%, 82%, 84% & 88% and no other bits in the reading apart from CRC can be different.

I might also look for some old AA batteries to test the indicator. I don't have laboratory PSU, only one running 3.3V but might to try get voltage down with resistor or sth.
Weather station only shows 'low' battery (if its good, nothing shows up).
Okay then, maybe there is only 1 bit dedicated to battery or if it is 2 bits then it ignores all but low condition. Just breadboard a simple variable resistor through the PSU or swap out resistors sounds good.
Logged


Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have removed the temperature sensor and it was indeed fixed value.
I've got some readings, made some operations to get them.
They're as always in fille at bottom: https://docs.google.com/document/d/121ZH3omAZsdhFi3GSB-YdnasMjIQSGIcaS7QW6KsACA/edit?usp=sharing

The most interesting part I've got:
Code:
00 01110110 01 01 011011100000 00000101 00000100 80%
00 01110110 01 01 011011100000 00010101 00000001 81% [latest reading]
00 01110110 01 01 011011100000 00010101 10001001 81% [earlier reading - before the dryer stuff]
00 01110110 01 01 011011100000 00100101 00001110 82%
00 01110110 01 01 011011100000 00110101 00001011 83% [earlier reading]
00 01110110 01 01 011011100000 01000101 00000011 84%
00 01110110 01 01 011011100000 01010101 00000110 85%
00 01110110 01 01 011011100000 01100101 00001001 86%
[missing                                         87%]
00 01110110 01 01 011011100000 10000101 00001010 88%
00 01110110 01 01 011011100000 10010101 00001111 89%
00 01110110 01 01 011011100000 10100101 00000000 90%

Also might be interesting for you:
Code:
00 01110110 01 01 011011100000 10100101 00000000 - Battery=1 Channel=1 Temperature=-67.0F Humidity=90%
00 01110110 01 01 011011100000 11000101 00001101 - Battery=1 Channel=1 Temperature=-67.0F Humidity=92%
00 01110110 01 01 011011100000 11100101 00000111 - Battery=1 Channel=1 Temperature=-67.0F Humidity=94%
00 01110110 01 01 011011100000 11110101 00000010 - Battery=1 Channel=1 Temperature=-67.0F Humidity=95%
00 01110110 01 01 011011100000 00000110 00000001 - Battery=1 Channel=1 Temperature=-67.0F Humidity=96%
00 01110110 01 01 011011100000 00100110 00001011 - Battery=1 Channel=1 Temperature=-67.0F Humidity=98%
00 01110110 01 01 011011100000 00110110 00001110 - Battery=1 Channel=1 Temperature=-67.0F Humidity=99%

Hope it helps somehow. I havent tried the battery operations yet.
« Last Edit: February 26, 2013, 05:04:32 am by andriej » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm in the same case the sensor, but this analysis is not appropriate.
Tell me which direction to go?
The application record from the sensor.

* Wave6.wav (240.16 KB - downloaded 24 times.)
* Wave3.wav (130.17 KB - downloaded 21 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I fit the data constants, like allanayr, but it looks like 36-bit

exmpl: 001111001000000011111101111100101011
« Last Edit: April 28, 2013, 12:31:26 pm by Vitaliy86 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

all work:
Code:
//Riva’s working code:
// Unknown 433Mhz weather sensor decoder. Untested in the real world.
// http://arduino.cc/forum/index.php/topic,142871.msg1106336.html#msg1106336

// __           ___       ___    ___
//   |         |  |      |  |   |  |
//   |_________|  |______|  |___|  |
//
//   |  Sync      |    1    |  0   |
//   |  8320us    | 4500us  | 2530us

// Defines
#define DataBits0 4                                       // Number of data0 bits to expect
#define DataBits1 32                                      // Number of data1 bits to expect
#define allDataBits 36                                    // Number of data sum 0+1 bits to expect
// isrFlags bit numbers
#define F_HAVE_DATA 1                                     // 0=Nothing in read buffer, 1=Data in read buffer
#define F_GOOD_DATA 2                                     // 0=Unverified data, 1=Verified (2 consecutive matching reads)
#define F_CARRY_BIT 3                                     // Bit used to carry over bit shift from one long to the other
#define F_STATE 7                                         // 0=Sync mode, 1=Data mode

// Constants
const unsigned long sync_MIN = 4300;                      // Minimum Sync time in micro seconds
const unsigned long sync_MAX = 4700;

const unsigned long bit1_MIN = 2300;
const unsigned long bit1_MAX = 2700;

const unsigned long bit0_MIN = 1330;
const unsigned long bit0_MAX = 1730;

const unsigned long glitch_Length = 300;                  // Anything below this value is a glitch and will be ignored.

// Interrupt variables
unsigned long fall_Time = 0;                              // Placeholder for microsecond time when last falling edge occured.
unsigned long rise_Time = 0;                              // Placeholder for microsecond time when last rising edge occured.
byte bit_Count = 0;                                       // Bit counter for received bits.
unsigned long build_Buffer[] = {0,0};                     // Placeholder last data packet being received.
volatile unsigned long read_Buffer[] = {0,0};             // Placeholder last full data packet read.
volatile byte isrFlags = 0;                               // Various flag bits

void PinChangeISR0(){                                     // Pin 2 (Interrupt 0) service routine
  unsigned long Time = micros();                          // Get current time
  if (digitalRead(2) == LOW) {
// Falling edge
    if (Time > (rise_Time + glitch_Length)) {
// Not a glitch
      Time = micros() - fall_Time;                        // Subtract last falling edge to get pulse time.
      if (bitRead(build_Buffer[1],31) == 1)
        bitSet(isrFlags, F_CARRY_BIT);
      else
        bitClear(isrFlags, F_CARRY_BIT);

      if (bitRead(isrFlags, F_STATE) == 1) {
// Looking for Data
        if ((Time > bit0_MIN) && (Time < bit0_MAX)) {
// 0 bit
          build_Buffer[1] = build_Buffer[1] << 1;
          build_Buffer[0] = build_Buffer[0] << 1;
          if (bitRead(isrFlags,F_CARRY_BIT) == 1)
            bitSet(build_Buffer[0],0);
          bit_Count++;
        }
        else if ((Time > bit1_MIN) && (Time < bit1_MAX)) {
// 1 bit
          build_Buffer[1] = build_Buffer[1] << 1;
          bitSet(build_Buffer[1],0);
          build_Buffer[0] = build_Buffer[0] << 1;
          if (bitRead(isrFlags,F_CARRY_BIT) == 1)
            bitSet(build_Buffer[0],0);
          bit_Count++;
        }
        else {
// Not a 0 or 1 bit so restart data build and check if it's a sync?
          bit_Count = 0;
          build_Buffer[0] = 0;
          build_Buffer[1] = 0;
          bitClear(isrFlags, F_GOOD_DATA);                // Signal data reads dont' match
          bitClear(isrFlags, F_STATE);                    // Set looking for Sync mode
          if ((Time > sync_MIN) && (Time < sync_MAX)) {
            // Sync length okay
            bitSet(isrFlags, F_STATE);                    // Set data mode
          }
        }
        if (bit_Count >= allDataBits) {
// All bits arrived
          bitClear(isrFlags, F_GOOD_DATA);                // Assume data reads don't match
          if (build_Buffer[0] == read_Buffer[0]) {
            if (build_Buffer[1] == read_Buffer[1])
              bitSet(isrFlags, F_GOOD_DATA);              // Set data reads match
          }
          read_Buffer[0] = build_Buffer[0];
          read_Buffer[1] = build_Buffer[1];
          bitSet(isrFlags, F_HAVE_DATA);                  // Set data available
          bitClear(isrFlags, F_STATE);                    // Set looking for Sync mode
digitalWrite(13,HIGH); // Used for debugging
          build_Buffer[0] = 0;
          build_Buffer[1] = 0;
          bit_Count = 0;
        }
      }
      else {
// Looking for sync
        if ((Time > sync_MIN) && (Time < sync_MAX)) {
// Sync length okay
          build_Buffer[0] = 0;
          build_Buffer[1] = 0;
          bit_Count = 0;
          bitSet(isrFlags, F_STATE);                      // Set data mode
digitalWrite(13,LOW); // Used for debugging
        }
      }
      fall_Time = micros();                               // Store fall time
    }
  }
  else {
// Rising edge
    if (Time > (fall_Time + glitch_Length)) {
      // Not a glitch
      rise_Time = Time;                                   // Store rise time
    }
  }
}


void setup() {
pinMode(13,OUTPUT); // Used for debugging
  Serial.begin(9600);
  pinMode(2,INPUT);
  Serial.println(F("ISR Pin 2 Configured For Input."));
  attachInterrupt(0,PinChangeISR0,CHANGE);
  Serial.println(F("Pin 2 ISR Function Attached. Here we go."));
}

void loop() {
  unsigned long myData0 = 0;
  unsigned long myData1 = 0;
  if (bitRead(isrFlags,F_GOOD_DATA) == 1)
 {
    // We have at least 2 consecutive matching reads
    myData0 = read_Buffer[0]; // Read the data spread over 2x 32 variables
    myData1 = read_Buffer[1];
    bitClear(isrFlags,F_HAVE_DATA); // Flag we have read the data
    dec2binLong(myData0,DataBits0);
    dec2binLong(myData1,DataBits1);

    Serial.print(" - Battery=");
    byte H = (myData1 >> 26) & 0x3;   // Get Battery
    Serial.print(H);
   
    Serial.print(" Channel=");
    H = ((myData1 >> 24) & 0x3) + 1;        // Get Channel
    Serial.print(H);
   
    Serial.print(" Temperature=");
    byte ML = (myData1 >> 12) & 0xF0; // Get MMMM
     Serial.print(" (M=");
     Serial.print(ML);
    H = (myData1 >> 12) & 0xF;        // Get LLLL
     Serial.print(" L=");
     Serial.print(H);
    ML = ML | H;                      // OR MMMM & LLLL nibbles together
    H = (myData1 >> 20) & 0xF;        // Get HHHH
     Serial.print(" H=");
     Serial.print(H);
     Serial.print(" T= ");
    int Temperature = (H << 8) | ML;  // Combine HHHH MMMMLLLL
     Serial.print( Temperature);
     Serial.print(") ");
    //Temperature = Temperature -900;   // Remove Constant offset
    // Temperature = Temperature*3; //F
    Serial.print(Temperature/10.0,1);   
    Serial.print("C Humidity=");
    H = (myData1 >> 0) & 0xF0;        // Get HHHH
     Serial.print(" (H=");
     Serial.print(H);
    ML = (myData1 >> 0) & 0xF;       // Get LLLL
     Serial.print(" L=");
     Serial.print(ML);
     Serial.print(") ");
    ML = ML | H;                      // OR HHHH & LLLL nibbles together
    Serial.print(ML);
    Serial.println("%");
  }
  delay(100);
}

void dec2binLong(unsigned long myNum, byte NumberOfBits) {
  if (NumberOfBits <= 32){
    myNum = myNum << (32 - NumberOfBits);
    for (int i=0; i<NumberOfBits; i++) {
      if (bitRead(myNum,31) == 1)
      Serial.print("1");
      else
      Serial.print("0");
      myNum = myNum << 1;
    }
  }
}
Logged

Pages: 1 2 3 [4] 5   Go Up
Jump to: