Go Down

Topic: 433mhz weather station protocol? (Read 15774 times) previous topic - next topic

eXtr3am

Jun 04, 2011, 11:25 am Last Edit: Jun 04, 2011, 11:27 am by eXtr3am Reason: 1
I'm trying to receive a current temperature and humidity from remote weather station sensor using 433mhz receiver (EMAX EM-RX433-01). This receiver has 3 pins: GND, POWER and DATA. I connected power to 5v, GND to the ground and I'm receiving DATA in a following format:

Quote

1111111111101111100011111111111111111111000111111111111100011100001111111111111111111000011111111111111111110000
1111111111111111100011111111111111111111000011111111111110000111000011111111111111111100011111111111111111110000
1111111111111100100001111111111111111111000011111111111110000110000111111111111111111100011111111111111111111000
1111111111111111110001111111111111111111100011111111111110000000000111111111111111111100011111111111111011111000
1111111111111111100001111111111111101111100011111111111110001111000111111101111111111110001111111111111111111000
1111111111111111110001111111111111111111110001111111111110000111000011111110111111111110001111111111111111111100
1111111111111111110000111111111111111111100001111111111111000111000011111111111111111110001111111111111111111100
1001111111111011111000111111111111111111110001111111111111000110000011111111111111111110000111111111111101111100
1111111111110011111000111111111111111111110000111111111111100011000001111100111111111111000111111111111111111100
1111111111111011111100011111111111111111110001111111111111100011100001111111111111111111000111111111111111111110
1111111111111101111000011111111111111111110000111111111111100001100001111111011111111111000111011111111111111110
1111111111111111111100011111111111111111110000111111111111110000100001111111111111111111000111111111111100111110
0111111111111111111100011111111111111111111000111111110111110011100001111111111111111111000011111111111110111111
0111111111111100111100011111111111111101111000111111111111110000110000111111111111111111100011111111111111111111
0111111111111110111110001111111111111111111000011111111111110001110001100011111111111111100011111111111111111110
0111111111111111111100001111111111111111111100011111111111110000110000111111111111111111100001111111111111111111
0011111110011110011110001111111111001111110000111100011111111011000000111111110001111111111100011111100111111000
0011111110011110011111100011111000111111001111110001111100011111100001111000111111111110000111100011111100011111
0011111001111111111110001111111111100111111000111110001111111011100000111111111001111111111110001111111111100011
1000111111001111001111100001111111111100011111000111110001111110001100001111100111111111110001111111110011111100
0011100111111111111001100011111110011110011111000111111001111110001100001111100011111111111000111110001111110001
1100011111100111111000111110001111111111100011011100111111000111110000111110011111111111100011111111111001111110
0001100011111111111000110111111110001111111111100011111111111000111110000111110001111111111100011111111111000111
0001111100011111100011100011111000111111111111000111111100111111000110111000111111111110011100011111100111110011
0000111110001111100011100011111000111111111110000111110011111100011111000111111001111110001101100011111111111000
1111000111110011111100000011100111111111111000110011111110011111100011011000111101111110001100011111100011111001
1000111111111110001111110001111100011111111111000111111111110001111100001111100111111000111100011110001111111111
1000111111000111110001111110001111111111100011100011111001111110001110001111100011111000111100011110001111111111
0001111100111111000111110000111110001111100011111000111111111110000111110001111100011111100111111000111111111110
1100011111100111111000111111001111111111110011100001111100111111000110000111101111100011111100011111000111111111
0000111111111100111111000001111001111110001111100011100011111111000011000011110001111110011111100011111111111000
1100011110001111111111100001111000111111001111110001110011111111111000000111000111110001111110001111100011111000
1110000111111111110001111100011111000111111001111110001111111111100011100001111000111110001111100001111111111100
1100001111001111111111110001111111111100111111000011110001111111111100000110001111001111110001101110001111100011
1110111000111111111101111000011100011111100011111000111111111110001111100011100011111111111000100110001111110011
1110011100111111111110001111110011111100011111100011111000111110000111110001111111111100111111000011110001111110
1111100011111111111000111100011110001111110001111100011111111111000111110001110001111111111100110011111111100011
1000001111000111111111110001111111111100111111000111110001111110001110000011100011111111111111100011110011111100
1111000011111111111001111110001110011111111111000111111000111110001111110011100011111111111000110110001111110011
1100001111000011111000111110000111111111100011111100011111000111110000111100001111111111100111110001111001111110
1111100011111111111000111110001110001111111111100011111111111001111110000101110001110111111100111001111111001111
0001101100011111100111111110111000111111111111111110011100011111000111111000111111111110011111110011100111111111
0001111110001111100011111111011000111111111110001111100001111100111111000000111001111110001111100001111111111000
1111000111110001111110011111100011111111111000111110001110011111100011111000011111111111001111111001100011111111
1000110001111110001111110011111100011111111111000110000111110001111100011111000011111001111111111110001111111111
0011110111000111111001111110000111111111100111111111111000111111111110001111100011111000111111111110001111111111
0011111000011111000111110001101110011111100011111000011111111110001111110000011100011111100111111000111111111110
1111110011100011111000111111000111111111110011111111011000111111111110001110001111100011111100011111000111111111
0001110000111100011111000111110000111110001111111111100011111111111110001111110001111100011111100011111111111001
1011111110001111111111100011111000111111001111111111100001111111111000011111000111110001111100011111100011111000
1111001100011111110011111100011011000111111001111110000111111111100011000111111000111110001111110001011111111100
1101111110001111111111110011110001111000111111000111110001111111111100011110000111000111111001111110001111100011
1111111000011111111111111111111100011111100111111000110001111110001111000011100011111111111000111110001111110011
1111111100011111111111001111110001111100011111100111111000111110001111110001100011111100111111000111110001111110
1111100011001111111001111101111110001111100011111100011001111111001111000011100001111111111100111110001111001111
0001111100001111111111000111111001110001111110011111100011111000111111101110000111111111111111111111000111111001
1110001110001111100011111111111000111111111110001111100001111100111111100111000011111111110011111100001111000111
1001111110001111100011111100011100011111001111110001111100011111100111111000110001111110001111111111100011111000
1111000110001111110001111111111100011111111111001111111001110011111100011111000011110011110001111111101100011111
0111111000001110001111111101001110011111111111111111111000111111111111110001110001111111111111111111100011111111
1111111111000111111111111111111110001111111111111111111100011111111111111001110000111111111111111111100011111111
1111111111000111111111111111111110001111111111111111111100011111111111111000110000111111111111111111100011111111
1111101111000111111111111111001110001111111111111111111000011111111111110000111000011111111111111111110001111111
1111100111000011111111111111011110001111111111111111111100011111111111111000111000011111111111111111110001111111
1111111111100011111111111111111110001111111111111111111110001111111111111110000000011111111111111111110001111111
1111111111100011111111111111111111000111111111111111111110001111111111111100011100011100111111111111111000111111
1111111111100011111111111111101111000111111111111111001110001111111111111100001100011111111111111111111000111111
1111111111110001111111111111111111000011111111111111111110001111111111111110001100001110111111111111111000111111
1111110111110001111111111111100111000011111111111111100111000111111111111110000100001111111111111111111000111111
1111111111110001111111111111111111100011111111111111111111001111001111111110000010001111111111111111111100111111
1111111001110001111111111111111111100011111111111111111111000111111111111110001110001111111111111111111100011111
1111111111111000111111111111111111100011111111111111111111000011111111111111000111000111111111111111111100011111
1111111111111000111111111111111001110001111111111111111111100011111111111110000110000111111111111111111100001111
1111111110111000111111111111111111110001111111111111111111100011111111111111000011000111111111111111111100001111
1111111111111000111111111111111101110001111111111111110111100011111111111111000111000011101111111111111110001111
1111111111111100011111111111111111110000111111111111111111110001111111111111100011000011111111111111111110001111


Actual signal from the weather station is n the middle of this log. When transmitter transmits nothing, I receive a data looking like this: "11111111111111000011111111111111111110000111111111".
I have spent a lot of time reading forums and trying to understand what kind of a protocol it is and how to read it in my arduino. Maybe anyone knows how to decode this in a readable format?

robtillaart

I don't know the format but I like the image of the bits, looks like a heavy rainstorm ;)


It is not clear how you got these samples, how your code looks like, so it is impossible to make an interpretation from here.
that said:
- you identified a repeating [no info?] pattern, so you should be able to strip that
- you need to add timestamps to individual samples, makes analyzing better possible
- I think your samples are not the bits, the data looks a bit oversampled. I think that ~3 zero bits = LOW and ~3 one bits = HIGH.

Q: please post the link to the datasheet of the weatherstation (or any other info you have)
Q: please post your code
Rob Tillaart

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

eXtr3am

This rainstorm makes me crazy   :) :smiley-roll:

-This repeating pattern is always changing a bit, there are random 1/0  sometimes. Do you mean strip it when no signal is received or strip from incoming stream?
-The whole stream is received immediately. Each bit is received in: 1/16mhz = 62,5 nanoseconds
-You are right, but curently I have no ideas how to receive not oversampled data without noise.

A:Unfortunatelly I have no any datasheets for this station, because it's a quite cheap one: "Precision Weather Station" http://reviews.argos.co.uk/1493-en_gb/2554114/reviews.htm

A:Code is quite simple
Quote

void setup() {
  Serial.begin(57600);
  pinMode(40, INPUT);
}

void loop() {
  int sensorValue = digitalRead(40);
  Serial.print(sensorValue, DEC);
}

wildbill

Looks like you're using a mega, rather than trying to read the data bit by bit on a digital input, where getting the timing right will be tricky, how about trying one of the other serial ports?

robtillaart

Quote
Each bit is received in: 1/16mhz = 62,5 nanoseconds


Very unlikely as the code (e.g. serial.print(val, DEC)) takes far more time to execute. 57600 baud means 5760 chars per second can be send, so the time between the above samples is at best in the order of 1/5760 sec ~~ 174 microseconds. Further the digitalRead also takes some time ....

based upon my assumption that the three -sometimes 4- zeros form one logical LOW => one real bit is in the order of 3.25 x 1/5760 == 0.00053 second. So the signal could be a 2Khz signal (which is quite a reasonable number).  Below code to sample at this frequency  (not compiled or tested)

Code: [Select]

void setup()
{
  Serial.begin(115200);  // as fast as possible
  pinMode(40, INPUT);
}

unsigned long last = 0;

void loop()
{
  unsigned long t = micros();
  if (t - last >= 500)
  {
    last = t + t - last - 500;                    //  the t- last - 500 is to prevent drifting ...
    int sensorValue = digitalRead(40);
    Serial.print(sensorValue, DEC);
  }
}

Can you test this code and look if the pulses make  more sense?

Rob Tillaart

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

eXtr3am

2wildbill: yes, I'm using mega. Good idea! I'll definitely try it soon.

2robtillaart: result is more convenient now, but still there are random 1/0 sometimes...

Quote

1011111110101111101111110011111100111111001111110111111101111111011111110101111
0011111100111111001111110011111101111111011111110111111101011111011111100011111
0011111101111111011111110111111101111111010111110111111101111111011111100101111
0011111101111111011111110111111101111111011111110111111001011110011111101111111
0111111101011111011111110111111101111110010111100111111011111110111111101011111
0111111101111111011111110101111001111110111111101111111010111110111111001111110
0111111011111110111111101111111011111110101111101111110011111100111111010111110
1111111011111110111111001011111011111100111111011111110101111101111111011111110
1111111010111100111111001111110111111101011111011111110111111101111110010111100
1111110111111101111111010111110111111101111110011111101101111011111110111111101
1111110111111101111111011111110111111001011110011111101111111011111110101111101
1111110111111101111111010111110111111011111110111111101011111011111110111111101
1111110101111011111110111111101111111010111110111111101111111011110100101110110
1111110111101101111010110111101110110010110110110110101111011011011010110101101
1111101101011010111100111110110111101011011011011111100111110101101101101011010
1111110101101011011110111101101101101101111011011111010111101011011110111101011
1101101011110110110110101110110110110111101101111111011011110111101101011011001
1110101101101101101100101101010110110110110101101111010101100111010110111101010
1101101111011010110110110111001111111011011001111111011011110111101101011111101
1011011011011011110110101101101111010110111101101110010101111011110110110111101
0101101101101011011101111110010111101111011001111111011110110101101101101101101
0111101101101101101101011101011011010110111101111011001101101111011110110110111
1110001111110110110101101111010111100101011110111101001011011011011011010110110
1101011110110101111001011110111101111011110101101111010110110110110101011110011
0110110111110110110101101111011110110101011011011011011011110110101101101111011
1101011010110101111011010111101111100110111101101101101111001111110010110110101
1110001111010110111101111011011011110110110101101100101101101110111101111011011
1101011111101111011011011110111111001011011010111110110110101111011010110110101
1110011011110110110110110110110111001011011011011110111101101010111101111010110
1111011111110101111011011011011110101111101101101011011110101111011010111100111
0110110111101101101011011010011110101101111011110110111101110111101011011011011
1101011110110110101101111010101101001110111101101111011110101011110110110110110
1101101110110110110110111100111111101101111011110110101111010110110101111011011
1110111011101111011011011110111111001110111101111010110111101101101101101101011
0110111101101011110011101100111111101111011010110110111101011110110110111101111
1110111111101111111010111110111111101111111011111101111111011111110111111101111
1110101111101111111011111110111111001111110111111101111111011111110101111101111
1100111111011111110101111101111111011111110111111101111111011111110111111101111
1101111111011111110111111101111111011111110111111001111110011111101111111011111
0101111111011111110101111101111110111111101111111011111110111111101111101011111


robtillaart


now there becomes a repeating pattern of  0111111 = 0x7F = 127 visible. This is a typical value.

And it looks like almost every 8-th bit is a zero.

The most used parts of the ascii table for tekst are in hex:
0x41 - 0x5A (uppercase)
0x61 - 0x7A (lowercase)  // I see a lot of 0110xxxx0110xxxx in the stream that could mean lower case ascii

Now you have to write a program that read the bitstream at every position and convert the bits to char's and try to print them
you need to try to sync with 0x7F's

But first you have to get the sample speed right, you need to write a sketch that gets the timing better. Connect the signal to IRQ line ( don't know the MEGA iRQ PIN's) and trigger on CHANGING in the "idle" mode.

(code not tested)
Code: [Select]

void setup()
{
  Serial.begin(115200);
  attachInterrupt(0, IRQ, CHANGE);
}

void loop()
{}

volatile unsigned long t = 0;
void IRQ()
{
  unsigned long interval = micros() - t;
  t = micros();
  Serial.println(interval, DEC);  // ok print statements in IRQ is not advised but as the IRQ's are expected approx every 500 microseconds it might work.
}

During the idle time this code should give a short interval (one LOW ) and a long interval (7 HIGH's).  If you have those two values you should be able to calculate the bitrate of the device pretty precise.


Rob Tillaart

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

eXtr3am

I was playing a bit with serial connection but without success: I'm receiving a lot of 255 and 253 bytes in the idle mode and random numbers while receiving... can't guess a correct baud rate.
EM-RX433-01 board is using CHMC S23 S358F chip, but I can't find data sheet for it.

eXtr3am

Great! Thanks! :) That's what I was searching for. I'll try it to find out a bitrate

eXtr3am

Output is pretty weird  :smiley-roll-sweat:
Quote

668
1276
1064
6956
672
1156
1308
6376
672
1292
676
3844
668
288
512
592
1852
668
1316
668
508
4294966784
620
192
640
1812
672
1292
956
508
3564
668
1324
908
1084
668
1284
892
3116
668
1808
668
1816
672
896
588
1856
672
292
908
1128
668
980
580
512
512
1696
672
1304
896
3060
672
1900
672
4800
668
1292
908
4116
672
1772
672
1376
668
1308
668
3816
672
280
1108
672
4294966780
624
4294966912
1648
736
892
3104
672
1864
672
3780
672
856
704
512
524
7692
668
1316
948
2672
668
1208
684
2608
672
556
912
508
3572
672
1304
668
512
4294966784
4294966892
620
992
508
1916
688
1088
668
1092
916
9060
672
1876
672
516
508
1748
668
512
1780
672
300
824
2232
672
244
512
596
1888
672
540
512
508
4294966784
4294966892
656
808
2076
672
1288
984

robtillaart

There are only a few numbers under 500, so I consider that noise
There are a few very large values, => ignored too.

It looks like the basic bit width is around 512 micros()

I interpret the values between 512-700 as the times between 2 bytes. When the weather station has clocked out one byte they wait a little longer than one bit before sending the next byte.

Now the step is to write a sketch that accepts 8 bits clocked out to be samples every 512 micros() and that sketch needs to synchronize on the first LOW.

Rob
Rob Tillaart

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

willnue

I would search the net for whatever brand/model of sensor you are using and "radio protocol" to see if some of the work has been done for you already. For example if you have a Oregon Scientific sensor theses articles describe the various protocols:

Decoding data of Oregon Scientific radio frequency sensors...
http://alyer.frihost.net/thn128decoding.htm

Oregon Scientific RF Protocol Description
http://wmrx00.sourceforge.net/Arduino/OregonScientific-RF-Protocols.pdf

If you are on Windows you might also find the entire Weather Station Data Logger project of Interest. The have written quite a bit of code for receiving signals from various sensors, which might be helpful to you to look at.
http://wmrx00.sourceforge.net/

I spent some time working on the eavesdropping on the 433Mhz sensors, but the range never amounted to what I needed in my environment, so I went with a wired solution instead.

Hope it helps,
willnue

Gadget999

i think the protocol is OOK

On
Off
and then some data

see if you can find an on and then off followed by data

hope this helps

adis


Decoding data of Oregon Scientific radio frequency sensors...
http://alyer.frihost.net/thn128decoding.htm

It's the best way to start. I wrote a decoder several months ago and used the wave like the one displayed in figure 1 to interpret 1's and 0's.
Then I made a small change in temperature and looked at the wave again to guess where in the stream the data is stored. The protocol I decoded was totaly different from the one Oregon Scientific uses.

Until I saw that page, I wasted a lot of time trying to read the radio receiver and writing the state to serial.

MarkT

There are lots of problems with decoding an unknown RF packet format if you want to recreate it over the air:

The things that you need to identify are:

carrier frequency
modulation type
deviation (if FM)
baud rate
manchester coding, whitening, bit-stuffing or other clock-recovery feature present.
preamble and header, CRC algorithm

I'm wondering how you know your rx433 unit is actually picking up the correct signal and not some other 433MHz device?
[ I won't respond to messages, use the forum please ]

Go Up