I can communicate with the Yun over wifi, but is there a more reliable/easy way?


Just FYI, I’m new to Arduino and web development but I work using C# on desktop apps (mostly WPF related).

I have a project I’m doing for fun that has a couple of Yuns hooked up to ID20 RFID sensors. The Yuns connect to a wireless router that my pc is connected to (nothing else is on the network, so no web access or anything).

When the an RFID tag is sensed it sends to the C# app running on my PC and the app updates a database with the current location of that tag. I started working on the UNO, but when I discovered the YUN I switched over to try making the project wireless and ported most of my code resulting in some of the work being done in python.

Currently I have communication with the Yun working with two python scripts that send or receive over UDP via WIFI (as far as I understand there is no UDP library for the YUN like there is the UNO). When the Yun first powers on it writes these scripts to the linux side and then it loops sending broadcasts “I’m alive” until the C# recognizes the broadcast, responds and they are “connected” because they know each other’s IP address, from then on the C# app is just listening for rfid tag updates to update a database and the yun is waiting for RFID scans. When scanning a rfid tag the yun calls into the send python script and sends the tag info to the pc over UDP and I then store in the database that the tag was last scanned at that ip address.

This implementation works for the most part but it seems clunky to me, and there is no real way of preventing messages from getting lost since it is UDP.

Is there an easier/more reliable way to do the communication between a C# app and the arduino yun? I’d like to be able to have two way communication between them and be able to detect from C# when a Yun comes online and I’d prefer to not be dealing with passing data to python just to send it.

I’m sorry if this is a really newbie question, I’ve looked into the Server/Client examples and maybe it is just my lack of knowledge on web dev but I don’t understand how I would send and receive strings from them.

Any Suggestions?

Also planning on doing something similar with RFID.

you could write a python/php/... script using TCP on the Linux side. then invoke the script from sketch using the Process library passing the rfid data as arguments. Or use serial console commands with serial1 to invoke your scripts.

optionally read the script response from process.read() as feedback to the user. (data registered in db)

in python arguments can be read with sys.argv[n] where n stands for the number of argument to read from. To respond with data use print("some data") in your python script

hope it help.

Greetz. Vinzz

DarthVadersMom: I'm sorry if this is a really newbie question, I've looked into the Server/Client examples and maybe it is just my lack of knowledge on web dev but I don't understand how I would send and receive strings from them.

I think you're onto something with this train of thought, it may be your best bet if you don't want to keep passing data to Python just to have it it send it over the network.

I would keep your Python and C# code that does your initial broadcast and handshake routine. Then, when C# knows where the Yun is, it opens a TCP stream network socket to the Yun. The sketch uses YunServer/YunClient to catch that connection, and then the two nodes can talk reliably over that socket.

Here is a simple example of the sketch side code that may help you get started. Read the whole thread, but the code is in post #8.

DarthVadersMom: ::::SNIP::::

Any Suggestions?

You might consider storing the data on the Yun and then transferring with a checksum every hour or so, or once a day.


@DarthVadersMom, You may find something useful in this Thread about Python Bottle



Use WCF(Windows Communication Foundation) write WCF RESTful Service for Post JSON data to MSSQL.

The concept is simple, basic setup httpend point allow post json payload for database insert.

Install prerequisites:

opkg update
opkg install python-openssl #adds ssl support to python
opkg install distribute #it contains the easy_install command line tool (this can take some time)
easy_install pip #installs pip  (this can take some time)
pip install requests

Python code:

nano /mnt/sda1/rfid.py
import sys, requests, json
data = {}
data['rfid'] =sys.argv[1]
#print data
url = ""  #url of WCF http endpoint 
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
#print r
chmod 755 /mnt/sda1/rfid.py

Testing without ATmega32u4:

/mnt/sda1/rfid.py "123"

ATmega32u4 Code:

#include <Process.h>
void setup() {
     Bridge.begin();  // Initialize Bridge
void loop() {
     int rfid = random(0, 100);
     Process p;              


Same here basic setup httpend point allow post json payload for database insert.

bypass PHP, Apache, Mysql Driver by use latest technology Mysql HTTP Plugin from Oracle.


Yun and ATmega32u4 Code are remain.

Thanks for all of the replies! Looks like the WCF RESTful service will work for me!