Following my post about the receiver for La Crosse sensors, I started to doubt about the quality of the reception.
On my left: XY-MK-5V
As I said before, I found this one on ebay for 1 € (inc. postage)!
But it is not specially noted for its quality of reception and output signal is very noisy.
On my right: RXB6
I decided to break the piggy (hum!) and ordered a RXB6 module which has a far better reputation. Cost from China is $5 (inc. pp). Obviously it took 3 weeks to arrive but finally, I was able to try it on the Arduino.
Surprise! It didn't work at all. Nothing, no signal on the PIN 13.
After a while, and really thinking I got a duff one, I hooked it on the Digispark and... miracle!
But if I had some readings, it occured to me that something must be wrong as TX sensors are quite chatty (a repeted signal every minute or so) and I had only 20 values for a whole evening.
Something was definitely amiss. OK
pulseIn is not necessarily the best method ever but since the microcontroller is not doing anything else, this should not be a problem.
While decoding, I ignore the LOW part of the signal (the 1000μS gap) but still...
After a lot of trial and error, I finally understood where the lock was: A tiny little bug!
The first loop validate the preamble by checking the value is 10d (00001010b) but the variable was defined by
int so depending on the preceding bits it could have held a different (higher) value despite a correct preamble.
To correct this behaviour I could either do a
AND 255 with the value but I simply defined by variable by 8-bit
I also changed the boundary timings to be less restrictive.
Reading about different receivers, it seems that the RXB familly (at least) doesn't cope well with pull-ups. Since the pin 13 of the Arduino has a LED, this might be the reason why it didn't work when I first tried it. It works fine on any other pin...
Adding an external antenna to the RXB6 doesn't seem to make much difference but when hooked on the digispark, a decoupling capacitor (100nF) seems mandatory for the RF receiver!
And the winner is...
RXB6 module is definitely better, especially with the outdoor sensor, but it also uses twice as much power (6.7mA vs 3.8mA). And the XY-MK-5V has an unbeatable value for money.