The wire.h is used in the original program to accomodate use of I2C
How would you suggest to improve this?
Question 1: the appearance of < in the message x+1 still puzzles me. Is there any possible explanation?
During the 6 hours the test currently runs one crash occured:actual message: 4 1 . 6 7 , 2 ⸮ 0 , 2 , A . ASCII message: 52 49 46 54 55 44 50 255 48 44 50 44 65 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
As far as I can see whatever is the problem it is not a fault with my Serial Input Basics There are too many cooks paddling around in this soup so I'm gonna drop out.Just one last thought ... any time I have found myself with a significant programming problem the solution has ALWAYS involved making things simpler and shorter....R
Can you please give your input how to program the calculated XOR at transmission and at reception?
Code in attachment due to 9000 chars limit
The baud rate used is 1200: this allows the maximum possible range for the HC12 radio.
communication takes place wirelessly with HC-12 433MHz radios: up to four transmitters, one receiver.
As a result and after advice from Robin2 I added a XOR checksum calculation stored as 2 hex values in one int variable, and this is added after the start marker upon transmission.
What needs to be done now is to extract/remove these 2 hex values and the first comma in the received message. Then calculate the XOR checksum again, on the received character array.
...Still you should be using the Virtual-wire library ! man those 433Mhz radios are far from reliable to begin with, and if they jitter long enough on your input line they may even cause your wdt to fire.
Virtual Wirewill take care of the CRC check for you
The HC12's are designed to run with a serial UART, and I would be interested to know if @Deva_Rishi has direct experience running them with an ASK protocol and VirtualWire/RadioHead
True. RadioHead and VirtualWire have a CCITT CRC16 baked in, but is would be simple to add this to the serial protocol of the HC12. There are arduino libraries for this, and I think they would be valid for the ESP8266.The HC12's are designed to run with a serial UART, and I would be interested to know if @Deva_Rishi has direct experience running them with an ASK protocol and VirtualWire/RadioHeadWhat checksum routine are you using? I thought it was a simple byte wise XOR which should give an 8 bit checksum. It its not a CRC.
I had them running using the VW-library using more or less any pin ( i had 12 & 3) at 4000bps of course it is a blocking protocol, (for sure for tx one should wait until transmission is complete, think it does it using a timer interrupt) but the sheer simplicity of it is remarkable (sketches upon request) I don't know for what they were designed, but i tried them out and for me the 1-way communication, and the total lack of security meant that i decided that i would not use them for anything other then controlling kids-toys
For my application, where 3 times an hour 5 values and a character need to be transmitted this I thought would be good enough.