Christiano Faig
Published © GPL3+

Building a Electrocardiogram with Windows IOT and Azure

Building a Electrocardiogram using Raspberry Pi and Windows IOT and sending data to Azure IOT Suit.

IntermediateFull instructions provided2 hours12,272
Building a Electrocardiogram with Windows IOT and Azure

Things used in this project


Read more




Visual Studio Coding - Im using VS 2015 private async void InGpioPinOnValueChanged(GpioPin sender,

Add Microsoft Azure Device Client from Nuget and Windows IoT extension
Please forgive I'm not using the best practice for coding...
using Windows.Devices.Gpio;
using Windows.Devices.I2c;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.UI.Core;
using Windows.Devices.Enumeration;
using Microsoft.Azure.Devices;
using System.Text;
using Microsoft.Azure.Devices.Client;
// Inside MainPage Class
private GpioPin _inGpioPin;

private I2cDevice _converter;

 protected override async void OnNavigatedTo(NavigationEventArgs e)

            await InitializeAsync();

  private async void InGpioPinOnValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
            var bytearray = new byte[2];
            _converter.WriteRead(new byte[] { 0x0 }, bytearray);
            if (BitConverter.IsLittleEndian)
            var value = BitConverter.ToInt16(bytearray, 0);
            // Sending Data to Azure
                        DeviceClient deviceClient = DeviceClient.CreateFromConnectionString("your connection key", TransportType.Http1);
            var msg = new Message(Encoding.UTF8.GetBytes(text));

            await deviceClient.SendEventAsync(value);

        private async Task InitializeAsync()
            var i2CSettings = new I2cConnectionSettings(0x48)
                BusSpeed = I2cBusSpeed.FastMode,
                SharingMode = I2cSharingMode.Shared
            var i2C1 = I2cDevice.GetDeviceSelector("I2C1");
            var devices = await DeviceInformation.FindAllAsync(i2C1);
            _converter = await I2cDevice.FromIdAsync(devices[0].Id, i2CSettings);
            _converter.Write(new byte[] { 0x01, 0xc4, 0xe0 });
            _converter.Write(new byte[] { 0x02, 0x00, 0x00 });
            _converter.Write(new byte[] { 0x03, 0xff, 0xff });
            var gpio = GpioController.GetDefault();
            _inGpioPin = gpio.OpenPin(27);
            _inGpioPin.ValueChanged += InGpioPinOnValueChanged;
  How to Read Data from ADS1115 inspired on the code from  : Oliver Matias MVP


Christiano Faig

Christiano Faig

2 projects • 51 followers