Mobile App Can Now Communicate with IoT Devices via Network

IoT like Rapsberry Pi or Arduino, and Mobile Devices unveiled a lot of innovations, opportunities & new kind of technologies, such as Smart Home, Drones, Remote Robotics and many more. But, how can we make our Mobile App talks to our IoT Devices through a simple network?


Before we start, you may need to learn how to create a mobile app with .NET Standard 2.0 first, so you may refer to our previous post – “Create Cross Platform Mobile App with .NET Standard 2.0“. Secondly, you may also need Visual Studio 2017 with cross platform development component installed, download a free community version if you have yet to own one.

If you are all set, we shall begin!

  1. Launch your Visual Studio 2017 (VS2017), if you have yet to create an app with .NET Standard, or your existing PCL Xamarin app, you may have to follow this post to create a .NET Standard Cross Platform Mobile App.
  2. Once you have created Xamarin app, you may now delete the default “Welcome to Xamarin.Forms” label control from MainPage.xaml.
  3. Then, let’s add in these controls to MainPage.xaml, three (3) entry boxes & one (1) send button.
  4. Now, let’s create a SendUDP function in MainPage.xaml.cs that’ll eventually read the entered IP, Port Number & Message. Also, performs a send when user clicks the button.
  5. However, you may notice there are some red underlined errors that can be resolved by adding reference to System.Net & System.Net.Sockets.
  6. Last, but not least, we need to bind the btnConnect to the function of SendUDP, so when user presses the button, it sends some messages to our IoT Device that is listening to the same port.
  7. Let’s compile, run and send some messages through network to an App that’s listening to same specified UDP port. Over here, I use some own written UDP Listener app to simulate like a IoT Device.


Is that cool and easy? Let’s us know if this really helps you to explore more opportunities!

This shows you a very conceptual solution, however, UDP doesn’t provide a guarantee delivery of your message.
If a guaranteed delivery is required, you may try to create an app which will replace UDP by using TCP or MQTT, which is a kind of light-weighted TCP protocol.












You can download your free offline copy too! & Source code available @ GitHub here!

Don’t forget to follow me @
Twitter: @hmheng
More slides @ SlideShare:

You may also like...

5 Responses

  1. Suggest to add integrate with Microsoft Azure as Part 2

  2. May I Ask about how we find the ip address and Port?

    • hmheng says:

      To find your server ip address in Windows, you may open a command prompt, and key in the following line:
      ipconfig /all
      then look for IP address of the active ethernet/wifi adapter.

      For the port, it is definitely up to your preference. In the case above, I used 7000 as an example. You may require to add it into firewall exception if you encounter an error.


  1. November 2, 2017

    […] You may also want to learn how to make your app communicating with IoT Device or other network capable peripherals @ latest tutorial  . […]

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: