# Send Rc to Pixhawk 

**URL:** <https://discuss.bluerobotics.com/t/send-rc-to-pixhawk/6323>\
**Category:** General Discussion\
**Created:** [November 11, 2019, 2:30am UTC](https://discuss.bluerobotics.com/t/send-rc-to-pixhawk/6323 "2019-11-11T02:30:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcussharkie](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@marcussharkie](https://discuss.bluerobotics.com/u/marcussharkie)\
**Post date:** [November 11, 2019, 2:30am UTC](https://discuss.bluerobotics.com/t/send-rc-to-pixhawk/6323/1 "2019-11-11T02:30:18Z")

</div>

Hello friends,I want to send rc values to Pixhawk from Raspberry Pi,I found this code but ı want to serial communication instead of Udp how can ı change this code thanks a lot

# Import mavutil

from pymavlink import mavutil

# Create the connection

master = mavutil.mavlink\_connection(‘udpin:0.0.0.0:14550’)

# Wait a heartbeat before sending commands

master.wait\_heartbeat()

# Create a function to send RC values

# More information about Joystick channels

# here: [Redirecting...](https://www.ardusub.com/operators-manual/rc-input-and-output.html#rc-inputs)

def set\_rc\_channel\_pwm(id, pwm=1500):  
“”" Set RC channel pwm value  
Args:  
id (TYPE): Channel ID  
pwm (int, optional): Channel pwm value 1100-1900  
“”"  
if id \< 1:  
print(“Channel does not exist.”)  
return

```
# We only have 8 channels
# https://mavlink.io/en/messages/common.html#RC_CHANNELS_OVERRIDE
if id < 9:
    rc_channel_values = [65535 for _ in range(8)]
    rc_channel_values[id - 1] = pwm
    master.mav.rc_channels_override_send(
        master.target_system, # target_system
        master.target_component, # target_component
        *rc_channel_values) # RC channel list, in microseconds.

```

# Set some roll

set\_rc\_channel\_pwm(2, 1600)

# Set some yaw

set\_rc\_channel\_pwm(4, 1600)

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [November 11, 2019, 4:30pm UTC](https://discuss.bluerobotics.com/t/send-rc-to-pixhawk/6323/2 "2019-11-11T16:30:17Z")

</div>

> [@marcussharkie](#):
>
> master = mavutil.mavlink\_connection(‘udpin:0.0.0.0:14550’)

replace the connection string: `udpin:0.0.0.0:14550` → `/dev/ttACM0` or whatever your serial port is.

`master = mavutil.mavlink_connection(‘/dev/ttyACM0’)`

---

<div class="post-metadata">

**Author:** ![marcussharkie](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@marcussharkie](https://discuss.bluerobotics.com/u/marcussharkie)\
**Post date:** [November 12, 2019, 11:38am UTC](https://discuss.bluerobotics.com/t/send-rc-to-pixhawk/6323/3 "2019-11-12T11:38:00Z")

</div>

thanks a lot

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [November 12, 2019, 12:16pm UTC](https://discuss.bluerobotics.com/t/send-rc-to-pixhawk/6323/4 "2019-11-12T12:16:39Z")

</div>


