temp sensor over 433Mhz

Dependencies:   FastIO

BBC MicroBit with RF 433Mhz receiver reading Oregon-Scientific wireless temperature sensor. Originally written for the Raspberry Pi but easily converted for the little microbit.

Committer:
daw9000
Date:
Tue Jul 26 13:57:34 2016 +0000
Revision:
3:fe79c130b25f
Parent:
2:7455dae4e624
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daw9000 2:7455dae4e624 1 /* Program Oregon Written by David Wright, Jan 2015. */
daw9000 2:7455dae4e624 2 /* thanks and plagarised from various internet sources on oregon sensors. Paul(DISK91.com), ALTelectronics for their document on */
daw9000 2:7455dae4e624 3 /* Oregon Scientific RF protocol v1.0, kevinmehall on github for rtldr-433m-sensor, Alexander Yerezeyev and more .... */
daw9000 2:7455dae4e624 4 /* */
daw9000 2:7455dae4e624 5 /* This Program reads a 433Mhz transmission from an Oregon version 1 Protocol Temperature Sensor */
daw9000 2:7455dae4e624 6 /* */
daw9000 2:7455dae4e624 7 /* Programming uses the logic of first detecting the preamble portion of transmission by counting the number of short 1 pulses */
daw9000 2:7455dae4e624 8 /* Next the progam monitors the 3 sync pulses and translates the last sync pulse to determine the first data message bit either 1 or 0 */
daw9000 2:7455dae4e624 9 /* From knowing the first message data bit the program determines the next 31 message data bits using the logic as follows:- */
daw9000 2:7455dae4e624 10 /* Two SHORT pulses means that the message data bit is the same as the previous message data bit (we know first so can do this) */
daw9000 2:7455dae4e624 11 /* One LONG pulse means that the message data bit is opposite (inverse) of the previous message data bit. */
daw9000 2:7455dae4e624 12 /* */
daw9000 2:7455dae4e624 13 /* The resulting 32 bit message is reversed to form 8 nibbles(4 bit). These nibbles are decoded to produce the data values. */
daw9000 2:7455dae4e624 14 /* */
daw9000 2:7455dae4e624 15 /* This program is quite basic and simplistic in that there is no error checking and only really gets temperature, channel and low bat */
daw9000 2:7455dae4e624 16 /* I wrote this program to learn C programming from being a visual basic and java programmer and as an aid to learning to code */
daw9000 2:7455dae4e624 17 /* hardware interfaces on my Raspberry Pi B+. I found plenty of code for various Oregon sensors but none I could easily understand */
daw9000 2:7455dae4e624 18 /* from the C or Python code. Hence this program does nothing clever using bitwise or memory facilities or uses no rising clock edges */
daw9000 2:7455dae4e624 19 /* , falling clock edges, clock ticks etc. Just simple time measurement and ONs and OFFs. Also I dont do any hex conversions. */
daw9000 2:7455dae4e624 20 /* There are no hex conversions because for channel, temperature and low battery all the hex and decimal values are the same i.e. */
daw9000 2:7455dae4e624 21 /* only numbers 0 to 9 are used for each part of the message. The temp minus sign and low battery are determined from the raw binary */
daw9000 2:7455dae4e624 22 /* in nibble 2 (third nibble as it starts nibble zero). */
daw9000 2:7455dae4e624 23 /* */
daw9000 2:7455dae4e624 24 /* If you wish this program can be improved on by adding error checking by using the checksum (hex conversion needed) and/or */
daw9000 2:7455dae4e624 25 /* by storing values and checking against the second transmission of the same message (all messages sent twice, I sleep through the */
daw9000 2:7455dae4e624 26 /* second transmission Zzzzz). */
daw9000 2:7455dae4e624 27 /**/
daw9000 2:7455dae4e624 28
daw9000 2:7455dae4e624 29 /*IMPORTANT NOTE : Most 433Mhz receivers are 5v so will not be powered from MicroBit. The data output is low voltage 3v so OK for MicroBit. */
daw9000 2:7455dae4e624 30 /* FastIO used because pin bashing was too slow. Maybe improvements could be made by using mbed interruptln */
daw9000 2:7455dae4e624 31
daw9000 2:7455dae4e624 32 /* Feel free to change, copy, or whatever ... */