Hi Andrew,
What excellent progress
very good work. Thank you for your comments.
I have a few suggestions to make and maybe answers for some of your questions.
I will email your code back to you. I am just a beginner on GIT-Hub and not confident about the push/pull process. However I won't attach it here and indirectly publish it myself, and you will obviously need to consider what you keep and what you alter.
There was a late edition to the Debug program (won't be the last I am sure!) that concerned checking the first zero and also making sure the header hits had been equaled or exceeded. I have added that in.
if ((!firstZero)&&(headerHits>=headerBits))
It basically forces the header to be valid before the first zero is accepted.
Secondly I have also simplified the idea of how to discard the leading zero and one in a more general way (Thanks to your request
) track the variable "discards" and you will spot what I have done. However it means the first byte in the manchester[bank][0] array is where to begin for the data ie index=0. You will need to alter your calculations for temp and hum as they will be one byte out now.
I have also added a 1 second interrupt that calls a small routine that can trigger off a 1 minute output of your data. Not original but you will find the acknowledgement in the code.
If you increase the number of bytes required until you stop getting data then you know will have to reduce the maxBytes by one and then you should be looking at all the stable data. If you are getting two quick transmissions of the same packet then you will probably need to store each packet in a separate manchester[bank][byteNos] and then compare them. I have inserted a bank check routine that will check all four banks so feel free to modify that as you need. It may send the packets twice as some form of redundancy and still have a check sum as well. Watch the byte you suspect is the checksum and see what its behaviour is with changing values in the rest of the bytes. The Bios WS sent the packet 4 times as validation check, the Oregon Scientific had a simple arithmetic checksum based on nibbles. Ambient may just rely on a comparison of two packets.
If you intend have multiple sensors each with its own transmitter you will need some way of stopping the output until all of them have registered valid numbers, then after that, send output each minute. Each Tx'er ORing a bit in a byte if successful will allow an easy check. Now that you have a timer in there you can also set up a check for Tx'ers going "quiet" for too long as well.
You will probably need a more generalised way of calculating from the Manchester[bank] the values for the transmitter/sensors so that your output to the server will be more manageable? I think you need to use an array of some sort.
These changes may get rid of the 3% bad readings, especially the validation of course.
The final caveat is all I have done is see if the program with my alterations compiles which is definitely no guarantee it is still working. I am looking forward to see what you do now. I am impressed and feel you are definitely on the homeward stretch to quite a useful package.
Cheers, Rob