I have a Raspberry Pi Zero W running Raspbian OS which is connected to a few sensors. I can broadcast the sensor data from the Pi to my Android tablet for display. I've written a UDP socket/client code which works fine while behind my router, but now I have to take the instrument/sensor out into the field where there is no network (WAN or LAN).

How do I set up the communications to broadcast the data from the Pi to my tablet through a direct wireless connection? I'm assuming an ad-hoc connection would suffice? Maybe something better? Assuming an ad-hoc connection is what I need, how do I set it up on the Pi? Would I have to set this up on both devices or just the Pi (or just the tablet)?


You are confusing network layers.

The ad-hoc vs. Infrastructure networking is done on the media layer. E.g. for Ethernet, the only thing you have to do is connecting two devices by a cable. They have their MAC address built-in and all the other configuration (10/100/1000Mbit etc.) can be autoconfigured by the hardware. For wireless, it's a bit more complicated but the principle stays the same.

Your own program runs on top of that. It doesn't matter whether it is using UDP, TCP or which component is the server and which one the client. It doesn't even notice the difference between an ad-hoc and an infrastructure wireless network. It wouldn't notice the difference between wireless and cable either.

What you have to do is setting up the network parameters on all components to ad-hoc. That's it.

EDIT: Please take a deeper look into the git archive you had linked: It's nothing more but a configuration file for udhcpd, which is not needed if all your components have a fixed IP address, and a startup script which pinnacles round one single line:

iwconfig wlan0 mode Ad-Hoc

That's it. You have an ad-hoc wifi network. You can easily set this up inside the standard networking configuration, too.

  • I appreciate your insights. As I said in closing "I don't know", which was kinda a generic closing remark. I do know the UDP stuff has nothing to do with the network. I get that. I was just stating what I have working now for the sake of putting the question in context. OK, moving forward. So it sounds like an ad-hoc configuration is what I need to accomplish my goal? Or is some other configuration necessary/better? Again, I'm looking to set up "communications to broadcast the data from the Pi to my tablet through a direct (independent of network) wireless connection". How do I do that? Jan 23 '18 at 7:50
  • I've edited my question in hopes that it better reflects my purpose..."How do I set up the communications to broadcast the data from the Pi to my tablet through a direct wireless connection?" Jan 23 '18 at 8:00
  • You can edit your own question instead of commenting it.
    – Janka
    Jan 23 '18 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.