Hello all, I have made a project where I use 2 Xbee S2C to communicate between 2 Atmega328p(one is the remote and 1 is controlling some motors after receiving):
1)In total there are 2 brushless motors(with ESCs) and 1 servo.
2)The remote is made out of 2 analog joystick and 1 pot. 1 analog joystick controls one brushless motor(I have done it so that it simply sends 1 or 0, and then the motor goes to full speed or is stopped), one analog stick send L or R, and then the servo itself moves to 2 different positions for left and right, alternatively if there's no L or R it stays in center(a third position) and a pot with which I control the last brushless motor with full range control(0-180).
3)The baud rate is 19200 for both the atmega and xbee.
4)Both circuits for the remote and the receiving board are custom and have 7805s with capacitors on input and output and heatsinks.
5)The receiving board is powered by a 3 cell lipo, 5000mAh, 50C, while the remote with a 7.4v, 3000mAh, 2 cell li-ion.
6)The Xbees are on Xbee Explorer Regulated Shields and then connected to the Atmega thorugh that.
7)The brushless motors are not the same, one is 2700kv and one is 6700kv.
8)There is around 15cm between the 2 brushless motors and 10cm between the second brushless motor and the PCB. Also the higher KV motor is in a mounting bracket that fully covers it(think about it as a metal box, it should help with the noise).
So here comes the problem, everything works perfectly fine when not using a propeller on the 6700kv(but using a propeller on the 2700kv), I can use any commands by themselves, together, everything is fine, no problem, for as long as I want. As soon as I add a propeller to the second brushless motor (6700KV), after a few second of use the xbee freezes and doesn't receive any commands anymore, sometimes it just freezes with the second motor spinning, sometimes the second motor stops spinning and the first one randomly starts spinning. This only happens with a proppeler installed, which I find strange, the only thing I can think of, is that the motor draws more power with the propeller and creates noise which influences and freezes the Xbee.
I was also thinking of maybe changing the baud rate to 4800 or 9600, maybe that can help? Let me know if you have any ideas or solutions.
It seems that all the wiring is correct, which leads me to believe the extra load of adding a second propeller is not causing the failure. You need to do more testing to figure out what exactly is causing the problem. Tbh, if you could make a small youtube video of it "working" and "not working" and post the link here, that would help.
As a side note, the way you're parsing the XBee commands is rather strange and might have a bug or two in it. I'd suggest using SerialTransfer.h to automatically packetize and parse your data. The library is installable through the Arduino IDE and includes many examples.