Simple Xbee / Arduino Remote Control System

Опубликовано: 30 Июль 2026
на канале: Nick Goodey
5,124
5

http://kiwitricopter.blogspot.co.nz/
Two way comms @ 38,400 baud seems reliable, other folks on the www seem to agree with this. The Xbee's are in the out the box wire replacement mode all set to defaults except baud is set to 38,400 with the X-CTU Utility

my code is here https://drive.google.com/folderview?i...
btw make sure you need level shifters for the serial TTL to 3.3v for the Xbee

The rest is in a pretty simple bit of code shown below. The electrical circuit can be determined from the code, I will draw it up as its only on a pad soon.

Two Xbee Pro S1 60mW alleged 1500 meter range out doors
TX Arduino Uno
RX Arduino Nano 328

I am a believer in the simplest code/solution to do the job so here is my wee bit of code for. I pass back telemetery every 5 frames from the TX with 20ms frames.

Its nice smooth and responsive, Latency looks reasonable also

TX Code

I sample the analogue inputs on power up so the joysticks can be nulled.

The loop samples all channels MAX_SAMPLE times then make an average. This method seemed to work better than a rolling average which introduces noticeable lag on the servos. Next the 10 bit values from the analogue controls are scaled to 1790 bananas, this is degrees X 10. The pot values are sampled at 200 micro second-ish intervals and a 10 point average is acquired in around 2mS.

A packet is constructed including the TX Xbee's RSSI and the state of the digital switched on the box. The packet is sent over the air with a simple checksum.

At the end of loop I wait for the n microseconds based on how long it took the get to the end of the loop, giving a 20mS frame rate, the typical wait is around 8 mS at the end of the processing section, which gives some free air for the Xbee, and seems to give better responsiveness than transmitting back to back as fast as possible.

The TX packet is quite small at max of around 70 bytes so it fits in a single Xbee frame which is helpful and preferable.

The code is here http://kiwitricopter.blogspot.com/201...