Wireless temp sensor

Hi,

I'm still an arduino beginner, so this may either be a long shot or else a really basic question.. hopefully someone can point me in the right direction :slight_smile:

I recently bought a very cheap ($12) indoor/outdoor thermometer, which didnt work right from the get go. This afternoon I took it apart and was interested to see that the wireless receiver element was a seperate board with only three pins, kindly named GND, Data and VDD.

It looks like this:

I've hooked up GND to ground, VDD to 3.3v on the arduino (unit was powered by two AA batteries) and Data to pin 7 on my arduino.

Using the following code, I can see it's receiving 'data' from the wireless sensor outside:

int pin = 7;
unsigned long duration;
unsigned long durationlow;


void setup() {
  Serial.begin(9600);
 
  pinMode(pin, INPUT);

}

void loop() {
  int sensorValue = digitalRead(pin);
  duration = pulseIn(pin, HIGH);
  durationlow = pulseIn(pin, LOW);
  if(duration != 0)
{  Serial.print("High: ");
    Serial.println(duration, DEC);
    Serial.print("Low: ");
        Serial.println(durationlow, DEC);
 
}

}

This is what I receive:

High: 173
Low: 112
High: 348
Low: 31717
High: 456
Low: 181
High: 190
Low: 838
High: 896
Low: 831
High: 784
Low: 878
High: 896
Low: 873
High: 883
Low: 826
High: 400
Low: 751
High: 416
Low: 747
High: 406
Low: 761
High: 947
Low: 780
High: 889
Low: 850
High: 858
Low: 871
High: 886
Low: 946
High: 817
Low: 1022
High: 428
Low: 700
High: 417
Low: 727
High: 155
Low: 4091
High: 119
Low: 0
High: 187
Low: 1053551
High: 52
Low: 0

Is there any way I can convert this stream of data back to a number? For what it's worth, I know that the value transmitted is around 37 degrees because that's the temperature outside at the moment.

Apologies if this is a ridiculous question, I seriously have no idea what's possible with the arduino....

Cheers

Tom

You need a few samples at different temps to find a pattern. I can see a BCD 3 7 in that pattern shown in the high pulses but it might be coincidence without seeing another reading also in the 30s.

Look for groups of 4 or 8 that would match the binary values and also count 2 bits for the 100s and negative. Then shave off the start and stop bits which should be obvious because they don't fit the normal 800/400 pattern. Also try looking at it as sending both MSB and LSB first. There's a definite pattern there that should become obvious with more samples.

Here's the breakdown on what I'm seing based on 37 and that single sample. The top 3 bits would hold the 100s and negative value.
It should be obvious with a different reading if this is correct.

/START
High: 173
Low: 112
High: 348
Low: 31717
High: 456
Low: 181
High: 190
Low: 838
start/
/3 extra data bits
High: 896      0
Low: 831
High: 784      0
Low: 878
High: 896      0
Low: 873
/7 place-4 bit BCD 0111
High: 883      0
Low: 826
High: 400      1
Low: 751
High: 416      1
Low: 747
High: 406      1
Low: 761
/3 extra data bits
High: 947      0
Low: 780
High: 889      0
Low: 850
High: 858      0
Low: 871
/3 place-4 bit BCD 0011
High: 886      0
Low: 946
High: 817      0
Low: 1022
High: 428      1
Low: 700
High: 417      1
Low: 727
/STOP
High: 155
Low: 4091
High: 119
Low: 0
High: 187
Low: 1053551
High: 52
Low: 0
stop/

Savitch that's brilliant, I'm trying to repeat your process to look through more data (I have loads, one example below). Forgot to mention the thermometer read out I can see on other device that receives actually has a decimal place, for the below I believe it was 37.9....

High: 167
Low: 26126747
High: 527
Low: 576
High: 2475
Low: 1209
High: 587
Low: 1177
High: 625
Low: 1131
High: 658
Low: 1143
High: 630
Low: 597
High: 274
Low: 831
High: 542
Low: 656
High: 609
Low: 638
High: 641
Low: 1141
High: 638
Low: 1119
High: 682
Low: 592
High: 631
Low: 563
High: 639
Low: 1139
High: 544
Low: 842
High: 594
Low: 741
High: 474
Low: 1582
High: 604
Low: 1136
High: 631
Low: 1122
High: 646
Low: 1169
High: 605
Low: 616
High: 340
Low: 723
High: 575
Low: 841
High: 602
Low: 686
High: 634
Low: 1181
High: 619
Low: 1162
High: 672
Low: 560
High: 647
Low: 1146
High: 619
Low: 439
High: 329
Low: 1021
High: 553
Low: 1088
High: 547
Low: 1176
High: 691
Low: 1112
High: 638
Low: 1109
High: 656
Low: 551
High: 633
Low: 1136
High: 539
Low: 670
High: 617
Low: 643
High: 609
Low: 653
High: 659
Low: 1176
High: 624
Low: 1132
High: 678
Low: 554
High: 657
Low: 569
High: 635
Low: 1161
High: 507
Low: 793
High: 574
Low: 1057
High: 497
Low: 1206
High: 661
Low: 1132
High: 629
Low: 1132
High: 652
Low: 1147
High: 594
Low: 591
High: 392
Low: 719
High: 548
Low: 819
High: 603
Low: 692
High: 566
Low: 622
High: 570
Low: 576
High: 599
Low: 1125
High: 671
Low: 551
High: 654
Low: 1111
High: 549
Low: 716
High: 588
Low: 679
High: 582
Low: 672
High: 597
Low: 541
High: 652
Low: 557
High: 653
Low: 1130
High: 594
Low: 1159
High: 7313
Low: 754
High: 581
Low: 705
High: 586
Low: 670
High: 578
Low: 640
High: 529
Low: 568
High: 596
Low: 1125
High: 643
Low: 580
High: 622
Low: 1168
High: 459
Low: 4505
High: 579
Low: 642
High: 551
Low: 1204
High: 664
Low: 1135
High: 637
Low: 1139
High: 650
Low: 1112
High: 622
Low: 566
High: 282
Low: 929
High: 527
Low: 631
High: 2486
Low: 1205
High: 650
Low: 1118
High: 608
Low: 1112
High: 661
Low: 1099
High: 620
Low: 562
High: 159
Low: 17877
High: 220
Low: 516
High: 416
Low: 0

Quick question - provided I work out how to decifer the preamble, do you know of any libraries for the arduino that can interpret the data? or is this beyond the arduino?

Appreciate your help with this mate, it's fascinating for me......

cheers

Please post whatever details you can about the unit concerned... stuff we can use to try to track down a source? Hard to get enthusiastic about the work of writing code for a "one off" situation? It may well be that someone (China? :slight_smile: ) has created modules that different retailers are putting in different pretty housings, so markings on the pcbs of interest as well as the "outer" markings.

Also you said it didn't work, as supplied... what were the problems there?

That last one is the same method but it looks like the bits are carried on the low pulse so divide up the long and short low pulses to figure out the 1 and 0. Find the numbers in BCD then the rest will fall in place as some sequence of 4,7 or 8.

This is similar to how an IR remote is decoded so if you search for that you will probably find examples of what to do.

Please post whatever details you can about the unit concerned... stuff we can use to try to track down a source? Hard to get enthusiastic about the work of writing code for a "one off" situation? It may well be that someone (China? Smiley ) has created modules that different retailers are putting in different pretty housings, so markings on the pcbs of interest as well as the "outer" markings.

Totally agree - sorry I didnt include more info at the beginning of the thread but to be honest as I said, I wasn't sure if I was asking a very basic question or a more difficult one (which it appears to be... :/)

Anyways, I've taken some more photos (below) that will hopefully give you some more info - for what it's worth I've seen many of the cheaper indoor/outdoor temp stations with the same transmitter as below which would make me think they are quite common. Interesting too that the send/receive are both breakout boards so quite likely found in other things.

I've googled all the numbers on the PCB of the receiver without any luck, perhaps someone here recognises them?

I've also just noted there's a TX/Reset button inside the transmitter, so I'm going to use that to see if I can't capture some decent data.

Cheers.


Transmitter module, branded Sontax (although I believe they're a Australian chinese goods importer, so probably oz specific)


Transmitter front


Transmitter back


Slightly skanky but working receiver... yes, it's bloody hot here, 41 degrees outside :frowning:


Shell from the broken receiver that I pulled the receiver module from.

OK, apologies for replying to myself here, but have made some more progress, perhaps someone can help me here?

Using the code found here Arduino Playground - InfraredReceivers I have managed to capture the data more accurately and using gnuplot I can get the following:

Output can be found here at the, the temp should read 34.0 degrees.

Source file for gnuplot is here: http://www.tom-george.com/wirelesstemp/take2.dat

If anyone can point me in the right direction for next steps I'd be very appreciative!

Cheers

Not sure if the code will be helpful, but something similar was posted on Practical Arduino:

As for what's being sent, why not just hook up the Arduino board to the transmitter pins.. since the Transmitter outputs TTL (from the looks of the RF kits), you should be able to hook up your RX on the Arduino, and just use Hypertrm or something of the sorts to read it.

Take the chip off the board, and just hook up the "data" to the TX on board. (yes the TX) And don't forget your grounds.. Then, just read data being output, and compare.

This will make sure you're not reading any random noise, which is what you get if you try reading without checksums, parity.. blah blah. :stuck_out_tongue:

Thanks CaptainObvious - been trying to make some sense of the code in the project you linked to, to be honest, will need to learn a little more c coding to get a full understanding.

I just started playing around with using the software serial library trying to read out data received from the receiver data pin (I will get to disassembling the transmitter but that will have to come second as my wife uses the outside temp reading all the time and would kill me if I break it :slight_smile: )

Is there value in using the software serial library? if so, any idea what would be a good baud rate to chose? I started with 1200 and can see data when I push the sync button on the transmitter however not really sure how to output/capture the data for analysis - seems the softwareserial read() method pulls a character off the line which might be incorrect?

I was hoping to generate a bunch of capture strings and then anaylse for similarity and/or changes that might help me work out the current temp.

Am I just being too optimistic with this approach?

Thanks,

Tom