Things used in this project

Schematics

Heart_bb.png
Heart bb

Code

Visual Studio Coding - Im using VS 2015 private async void InGpioPinOnValueChanged(GpioPin sender, C#
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)
        {
            base.OnNavigatedTo(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)
                Array.Reverse(bytearray);
            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 http://www.guruumeditation.net/en/analog-io-on-windows-10-iot-raspberry-pi-2-and-ads1115-converter/
  

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Particle Photon Based Security System with Alerting
Intermediate
  • 1,194
  • 20

Full instructions

Be alerted to any door or window opening and closing in your house on your smart phone.

Sigfox Forest Fire Detector
Intermediate
  • 999
  • 9

Full instructions

How to prevent forest from burning? A small Sigfox signal can prevent natural disasters. We will use an Arduino MKRFOX + a flame detector

LoRaWAN for Raspberry Pi with Worldwide Frequency Support
Intermediate
  • 2,862
  • 12

Full instructions

LoRaWAN LMIC 1.6 for Raspberry Pi with Dragino LoRA/GPS HAT or standalone RFM95W LoRa Module.

Using Common Cathode and Common Anode RGB LED with Arduino
Intermediate
  • 735
  • 14

Protip

Common Cathode and Common Anode RGB LEDs are two different kinds of RGB LEDs whose function is same but working is different.

Wall Mounted Textile MP3 Player
Intermediate
  • 59
  • 2

MP3 Player with fabric user interface using Arduino LilyPad.

Arduino Word Clock
Intermediate
  • 468
  • 8

Full instructions

A clock that let you read the time, for real!

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog