I hooked up RF 433 receiver to NetDuino in order to receive RF transmissions from Oregon Scientific THGN122 sensor.
RF Receiver: http://www.hwkitchen...hz-rf-link-kit/
I simply set data out of receiver to RX pin for COM2:
// initialize the serial port for COM2 (using D2 & D3) rf433 = new SerialPort(SerialPorts.COM2, 115200, Parity.None, 8, StopBits.One); // open the serial-port, so we can send & receive data rf433.Open(); // add an event-handler for handling incoming data rf433.DataReceived += new SerialDataReceivedEventHandler(rf433_DataReceived);
In the datareceived handler I am buffering incoming data till size is 1024 btes and then dumping it to SD card as text file (converted to hex)
static void rf433_DataReceived(object sender, SerialDataReceivedEventArgs e) { int count = 1024; byte[] ComBuffer = new byte[count]; int readBytes = 0; int totalReadBytes = 0; int offset = 0; int remaining = 1024; string RFLogPath = @"\SD\rflogout.txt"; //buffer received try { do { readBytes = rf433.Read(ComBuffer, offset, remaining); offset = offset + readBytes; remaining = remaining - readBytes; totalReadBytes = totalReadBytes + readBytes; } while (remaining > 0 && readBytes > 0); } catch (System.Exception ex) { byte[] temp = new byte[totalReadBytes - 1]; if (ComBuffer != null) Array.Copy(ComBuffer, temp, System.Math.Min(ComBuffer.Length, temp.Length)); ComBuffer = temp; } //save to file using (StreamWriter writer = new StreamWriter(RFLogPath, true)) { writer.WriteLine(DateTime.Now.ToString() + ":"); for (int i = 0; i < ComBuffer.Length; i++) { writer.Write(ByteToHex(ComBuffer[i]) + "-"); } writer.Flush(); } }
This is producing file as attached but I am unable to decipher any repeating transmissions.
I set up port speed to 115200 to avoid loosing some data but it looks like 1024 buffer fills up in cca 6 - 7 seconds.
Also I see a lot of traffic so I suspect that there is a number of devices around since bytes keep coming up even if I disconnect my sensor.
Anyone can help with deciphering or recognizing byte pattern of Oregon sensor ?
Thanx,
DiNo