fastlater
Posts: 1
Joined: Wed Sep 12, 2018 6:42 am

Send data over wifi from raspberry to android using windows and c# in both sides

Wed Sep 12, 2018 3:12 pm

Hi Community.
First post and really new on raspberry pi.

I have experience using windows and C# (windows forms and wpf, not too much asp.net and xamarin) so I will try to make a project to communicate my app (developed using xamarin native c#) and raspberry pi with win 10 iot. Unfortunately, there are no books for iot using rp with xamarin and web is so big when you are newbie and dont know what to search for.

I have been collecting info about how to send data from rp (data from sensors) to the app but most of the examples use python, pi-arest or examples in linux. I would like to establish the communication using windows and C# in both sides.

Till now, I have come with one idea:
Convert my rp into a c# server, display the sensor´s readings in a html webpage and use GET from the app using httpClient. Security is not my concern right now, I just want to accomplish the task first.


I am not requesting codes (if you want to share then, you are welcome) but maybe if it is possible, some suggestions or at least someone who can tell me if my idea could work or give me some hints to follow. If my ideas make no sense, any example, any library, or any class you can mention to me so I can research about it, I will appreciate it.

rasp14
Posts: 57
Joined: Sun Jun 22, 2014 2:49 pm

Re: Send data over wifi from raspberry to android using windows and c# in both sides

Fri Sep 14, 2018 4:19 pm

You can expose any data in Raspberry Pi you intended via a self-hosted web service written using C#. You can use WCF (Tcp binding only for Raspberry Pi) or Owin. Google both term should be enough to get you started. I personally like to use Owin because it can support multiple flavor of services such as web api, hosting static web site and SignalR (real time web library), without the dependency of IIS. So the web service can work on both Windows and Linux!

Of course you will need to install mono on Raspbian before you can run the C# code. Fortunately, latest Raspbian stretch repo already got a quite up-to-date mono available. Simply install mono using sudo apt-get install mono-complete should ready your Pi to run C# codes.

Return to “Windows 10 for IoT”