# Pymavlink Examples

**URL:** <https://discuss.bluerobotics.com/t/pymavlink-examples/7800>\
**Category:** General Discussion\
**Created:** [July 16, 2020, 9:46pm UTC](https://discuss.bluerobotics.com/t/pymavlink-examples/7800 "2020-07-16T21:46:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sena](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sena](https://discuss.bluerobotics.com/u/Sena)\
**Post date:** [July 16, 2020, 9:46pm UTC](https://discuss.bluerobotics.com/t/pymavlink-examples/7800/1 "2020-07-16T21:46:32Z")

</div>

Hi,  
I have tried some examples from the guide. But it doesn’t work.  
-top side computer connected to raspberry pi via ethernet  
-pixhawk connected to raspberry pi via usb  
-I changed ip address of top side as “192.168.2.1”  
-I’ve tried first example. (rebooting pixhawk)

```
import time
# Import mavutil
from pymavlink import mavutil
master = mavutil.mavlink_connection('udp:192.168.2.1:14550')
def set_rc_channel_pwm(id, pwm=1500):

    if id < 1:
        print("Channel does not exist.")
        return

    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_rc_channel_pwm(2, 1600)
set_rc_channel_pwm(4, 1600)
set_rc_channel_pwm(8, 1900)

```

What could be the problem?

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [July 17, 2020, 12:52pm UTC](https://discuss.bluerobotics.com/t/pymavlink-examples/7800/2 "2020-07-17T12:52:37Z")

</div>

Hi,

Mavproxy in the raspberry is using udpbcast as an endpoint, try using `udpin:192.168.2.1:14550` instead.

Have you tried the [RC Joystick](https://raw.githubusercontent.com/bluerobotics/ardusub-gitbook/master/developers/pymavlink/rc_joystick.py) as we wrote it?

---

<div class="post-metadata">

**Author:** ![Sena](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sena](https://discuss.bluerobotics.com/u/Sena)\
**Post date:** [July 21, 2020, 8:50pm UTC](https://discuss.bluerobotics.com/t/pymavlink-examples/7800/3 "2020-07-21T20:50:43Z")

</div>

Hi,  
Yes I’ve tried RC Joystick example. But it didn’t work. I also tried Arm/Disarm example and motor turned at maximum value. I guess there is no problem about communication. But I don’t understand why motor don’t run according to given pwm values as in the RC Joystick example.

---

<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:** [July 25, 2020, 9:00pm UTC](https://discuss.bluerobotics.com/t/pymavlink-examples/7800/4 "2020-07-25T21:00:05Z")

</div>

This topic was automatically closed after 5 days. New replies are no longer allowed.
