Windows 10 IoT Core Realtime communication using PubNub

STORY

Update 08-15-2015: Project converted to Visual Studio 2015 RTM

Windows 10 IoT Core Realtime communication using PubNub

Windows 10 IoT Core and PubNub are great tools for makers, we can easily send and receive message to and from devices. The device can be controlled from outside world, the device ca communicate with other devices and make a network of devices, etc.. are possible.windows 10 iot core realtime communication using pubnub

Last week I decided to experiment with Windows 10 IoT Core and PubNub. It was super easy and the result is amazing, we can have a realtime dashboard using Freeboard.io and also with a little bit tweaking you can control the LEDs attached to Raspberry Pi 2.

Here is the overview, the project uses TMP102 sensor to measure the temperature and publish it using PubNub. We can also send messages to Raspberry Pi to control the devices attached to it. Any client that subscribe to the channel rpipb-temperature will get realtime updates of the temperature. The message will be a JSON string in the form of {"temperature": 29}. We can also send messages to the device to control any external devices attached to it. You can turn on/off any GPIO pins available in Raspberry Pi. The message should be in the for of {"pin": <<pinnumber>>, "value": 1/0}. The pinnumber can be any GPIO pins, value can be 1 for HIGH and 0 for LOW. For this project I have attached two LEDs to pin number 5 and 6. Here are some examples of message:

{"pin": 5, "value": 0} – this will write value of LOW to GPIO pin 5 {"pin": 6, "value": 1} – this will write value of HIGH to GPIO pin 6

To display the live dashboard, I am using Freeboard.io. You can create your own dashboard using any library that support PubNub, say for example EON. For this project I am just using Freeboard.io. I have created a widget to display the live temperature updates. With little bit of tweaking I have also created two widgets with buttons to control the LEDs. For this I am using HTML widget and inserted the code to send PubNub messages.

Using the sample

  1. Open the solution RPiPubNub.sln in Visual Studio 2015
  2. Replace the publish and subscribe keys with your keys
  3. Select the 'Remote Device' option under the Debug Tab
  4. Rebuild the project and run it.

schematic windows 10 iot core realtime communication using pubnub

Steps to create live dashboard

  1. Logon to Freeboard.io
  2. Create a datasource with type PubNub, enter the name RPI-PubNub, enter your PubNub subscribe key and enter the channel rpipb-temperature.

For more detail:  Windows 10 IoT Core Realtime communication using PubNub


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top