Use your rasperry Pi as a UDP Server


#1

Hi everybody, I’m starting project using raspberry Pi as a UDP server.
In this tutorial I will explain to you how to settle your rPi to enable it to provide UDP communication.
UDP is a simple network protocol which use ip adresses and local ports to provide data via a specified network

First you need:
-A raspberry pi ( I used model B+)
-A wifi dongle ( I used WiPi dongle ) —
-A Os installed on your rPi ( I used raspbian wheezy )
-I used a monitor (+mouse & keyboard ) to configure my Pi but you can control your Pi with Putty in ssH from your computer.

I read this tutorial to use my raspberry Pi as a wiFi access point
http://elinux.org/RPI-Wireless-Hotspot

this tutorial was provided to rPi model B and there were some differences
from my B+ config but i success to understand what was uncompatible
with B+.

When I finished to follow the tutorial link instruction ,
I was just getting a FAIL result with the command

sudo service hostapd start

The hostapd service was not able to start.
After some researches on the net I found this command :

sudo hostapd /etc/hostapd/hostapd.conf

which gonna give you an understandable error message

So i understood the line from /etc/hostapd/hostapd.conf :

driver=nl80211

was not compatible with my B+ config.
I just removed that and it works successfully.

Now my rPi , after starting is emitting a wifi network i can use to send
and receive UDP packets . The important thing is we define a static ip method to give everytime the same ip from the rPi , as a reference ip to provide data on your rPi wifi network.

Your rPi can also be tuned in a router if you plug ethernet link on it.

I used esp8266 Sparkfun device in my case, and the arduino logic program is just to send from esp devices their local ip to the rPi and then , the rPi gonna send other clients ips to each client on the network to provide UDP communication.

I used my first tries with Processing from my computer
http://ubaa.net/shared/processing/udp/

a library developped by my school :grinning:

Personnaly, now i use python code with rPi , which is already included in the raspbian wheezy config.

https://wiki.python.org/moin/UdpCommunication

EDIT : Don’t forget to save your previous file of etc/network/interfaces , if you want to use wlan as a client and not as a server


#2

This is great. Thanks for the walk through.


#3

Thanks ! I tried to explain it in a simple way , i think maybe i can give
more examples , anyway the linked documentation is for my part sufficient ,
hope it gonna help ! !