# Adhoc network on Raspberry Pi 4

**URL:** <https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578>\
**Category:** Pi Image\
**Created:** [July 3, 2020, 11:59pm UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578 "2020-07-03T23:59:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![johncarl81](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/johncarl81/32/300_2.png) [@johncarl81](https://forum.ubiquityrobotics.com/u/johncarl81)\
**Post date:** [July 3, 2020, 11:59pm UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578/1 "2020-07-03T23:59:02Z")

</div>

Hello,

I’m running the ubiquityrobotics raspberry pi 4 2019-06-19-ubiquity-xenial-lxde image on my UAV companion computer. ROS is working, including multimaster and connecting wired internet works well. I have 3 of these PIs set up on an ad-hoc networks with the following configuration in the `/etc/network/interfaces` file:

```
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet dhcp

auto wlan0
iface wlan0 inet static
    address 10.42.0.3
    netmask 255.255.255.0
    gateway 10.42.0.1
    wireless-channel 1
    wireless-essid dragonflyadhoc
    wireless-mode ad-hoc
    wireless-key s:xxxx

```

This works from boot, but often the connection becomes unavailable after a couple minutes. Looking at the syslog, I can’t see any related issues that come up.

Is there a different or proper way to setup an ad-hoc network with this image?

Thanks.

---

<div class="post-metadata">

**Author:** ![rohbotics](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/rohbotics/32/222_2.png) [@rohbotics](https://forum.ubiquityrobotics.com/u/rohbotics)\
**Post date:** [July 7, 2020, 3:45am UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578/2 "2020-07-07T03:45:23Z")

</div>

I don’t know of anyone who has tried ad-hoc mode on our image, sorry. We generally use AP mode instead.

See if there is something in the `dmesg` log or maybe in `journalctl -b`.

---

<div class="post-metadata">

**Author:** ![johncarl81](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/johncarl81/32/300_2.png) [@johncarl81](https://forum.ubiquityrobotics.com/u/johncarl81)\
**Post date:** [July 8, 2020, 5:05pm UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578/3 "2020-07-08T17:05:33Z")

</div>

Hmm, nothing notable in dmesg or journalctl -b either. What’s strange is the adhoc network behaves normally from boot for a time period (ping, ssh, etc works) then just shuts off silently.

I do see this error from pifi during boot, but during that time period the adhoc network is functional:

```auto
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: Initializing AP Mode
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: Traceback (most recent call last):
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: File "/usr/bin/pifi_startup", line 9, in <module>
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: load_entry_point('pifi==0.6.0', 'console_scripts', 'pifi_startup')()
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: File "/usr/lib/python3/dist-packages/pifi/startup.py", line 123, in main
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: start_ap_mode(pifi_conf_settings, ApModeDevice, ClientModeDevice)
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: File "/usr/lib/python3/dist-packages/pifi/startup.py", line 70, in start_ap_mode
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: NetworkManager.NetworkManager.AddAndActivateConnection(settings, ApModeDevice, "/")
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: File "<string>", line 6, in AddAndActivateConnection
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: **keywords)
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: message, timeout)
Mar 2 17:08:13 ubiquityrobot pifi_startup[650]: dbus.exceptions.DBusException: org.freedesktop.NetworkManager.UnknownConnection: Connection 'Pifi AP Mode' is not available on the device wlan0 at this time.
Mar 2 17:08:13 ubiquityrobot systemd[1]: pifi.service: Main process exited, code=exited, status=1/FAILURE
Mar 2 17:08:13 ubiquityrobot systemd[1]: pifi.service: Unit entered failed state.
Mar 2 17:08:13 ubiquityrobot systemd[1]: pifi.service: Failed with result 'exit-code'.

```

---

<div class="post-metadata">

**Author:** ![rohbotics](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/rohbotics/32/222_2.png) [@rohbotics](https://forum.ubiquityrobotics.com/u/rohbotics)\
**Post date:** [July 8, 2020, 5:30pm UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578/4 "2020-07-08T17:30:25Z")

</div>

Maybe pifi/NetworkManager is doing something screwy in the background that is causing your network to fail.

Try disabling pifi with `sudo systemctl disable pifi`

Rohan

---

<div class="post-metadata">

**Author:** ![johncarl81](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/johncarl81/32/300_2.png) [@johncarl81](https://forum.ubiquityrobotics.com/u/johncarl81)\
**Post date:** [July 8, 2020, 8:05pm UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578/5 "2020-07-08T20:05:06Z")

</div>

Although it removes the error from the log, the problem with the adhoc connection is the same. I did notice that cycling a `sudo ifdown wlan0` and `sudo ifup wlan0` restores the network. Is there another log associated with the network of if\* that may give some more clues?

---

<div class="post-metadata">

**Author:** ![rohbotics](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/rohbotics/32/222_2.png) [@rohbotics](https://forum.ubiquityrobotics.com/u/rohbotics)\
**Post date:** [July 8, 2020, 9:06pm UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578/6 "2020-07-08T21:06:24Z")

</div>

You could try checking /var/log/syslog or dmesg, but after that I am unsure of anywhere else to check.

Rohan

---

<div class="post-metadata">

**Author:** ![johncarl81](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/johncarl81/32/300_2.png) [@johncarl81](https://forum.ubiquityrobotics.com/u/johncarl81)\
**Post date:** [July 8, 2020, 10:16pm UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578/7 "2020-07-08T22:16:12Z")

</div>

Playing with some of the configurations, it seems I just needed to change the channel that I was running on. Thanks for your help @rohbotics

---

<div class="post-metadata">

**Author:** ![rohbotics](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/rohbotics/32/222_2.png) [@rohbotics](https://forum.ubiquityrobotics.com/u/rohbotics)\
**Post date:** [July 8, 2020, 11:41pm UTC](https://forum.ubiquityrobotics.com/t/adhoc-network-on-raspberry-pi-4/578/8 "2020-07-08T23:41:27Z")

</div>

Glad you got it working!  
Good luck with your project.

Rohan
