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!

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

Give feedback

Comments

Similar projects you might like

Starry Night Prom
Intermediate
  • 997
  • 7

How did I stand out at prom? In a light up dress of course!

Face Detection Using OpenCV With Raspberry Pi
Intermediate
  • 2,372
  • 21

Protip

In this project, we are going to detect faces using OpenCV with Raspberry Pi.

Creating an IoT Server with Home Assistant and MQTT
Intermediate
  • 2,523
  • 17

Full instructions

Home Assistant is one powerful home automation platform and it is complacently open source. Access it from any web browser and automatons.

DIY Fidget LED Display
Intermediate
  • 1,146
  • 8

Work in progress

Fidget spinners...the simple spinning toy that came out of nowhere. I thought it'd be cool give it some flare and make it a POV display.

Adding RC Transmitter/Receiver to Control Mecanum Bot
Intermediate
  • 431
  • 6

Full instructions

We previously showed our Mecanum Bot being controlled by a wireless Xbox controller, now we added RC transmitter/receiver.

ArduRadio AlarmClock
Intermediate
  • 1,432
  • 2

Full instructions

Build an FM radio with alarm clock.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login