Giter VIP home page Giter VIP logo

win10iot-azureiothub-smartlamp's Introduction

Win10IoT-AzureIotHub-SmartLamp

In this project, I put together a real-world working project that shows how we can create an IoT device based on Raspberry Pi 2, with Windows 10 IoT Core OS. It's basically a smart lamp, that's controllable (switched on/off) remotely and able to send wattage telemetry. The app is written in Node.js, and leverages Azure IoT Hub for collecting telemetry data and control the device.

I use this project for a demo during my talk about Windows 10 for Makers in Microsoft TechDays 2015 Indonesia event.

Update: I also use this project to do a demo in Bandung IoT Developer Day on Nov 14, 2015, for my talk about "Raspberry Pi 2 + Windows 10 IoT Core + Node.js". Of course, I added some new features. Here is my slide for the talk: http://www.slideshare.net/andri_yadi/raspberry-pi-2-windows-10-iot-core-nodejs

New features:

  • Detect motion using PIR sensor
  • Automatically capture photo using web camera upon motion detected
  • Upload captured photo to Azure Blob Storage
  • Opt-in to automatically turn on/off the lamp based on surrounding light, by leveraging light sensor.
  • Hey I even integrate sound sensor. When detected surrounding sound is above certain level, turn on the lamp and take photo. Who knows there's an intruder.

##Components

To properly deploy the project, you need to prepare following components:

  • Raspberry Pi 2 with Windows 10 IoT Core OS
  • Solid state AC switch circuit (circuit is below)
  • AC light bulb
  • AC current sensor ACS712 5A
  • Analog to Digital Converter IC MCP3008
  • Voltage divider circuit to convert 5 volts to 3.3 volts. Output from ACS712 is in 5 volts level, while Raspberry Pi expects 3.3 volts.

Update: Optionally you need additional components for the new features:

  • Webcam. Any webcam should do. I use Logitech C170
  • Piezoelectric infrared (PIR) sensor
  • Sound sensor. I use this one from DFRobot

Circuit Circuit

##Azure IoT Hub You need to have Azure IoT Hub account in order to try control device remotely and sending wattage. After you setup an Azure IoT Hub instance, you should change [IOT HUB CONNECTION STRING] value in server.js file with an appropriate connection string. Refer to Azure IoT Hub documentation on how to get that the connection string.

##Azure Blob Storage New feature is able to capture photo (upon motion detected) using webcam and store it in the cloud. I use Azure Blob Storage for that. If you want to use it as well, you should setup Azure Storage instance, and change [YOUR_STORAGE_ACCOUNT_NAME] and [YOUR_STORAGE_ACCOUNT_KEY] values in server.js file with your own account.

Bonus

Webcam

For new features above, I want to be able to capture photo using webcam. Accessing webcam in Windows 10, including Windows 10 IoT Core is easy, there're a lot of examples in C#, but not so much in JavaScript (Node.js). So I need to create the library for JavaScript by my own.

So here it is. A freebie for you :)

MCP3008

For reading energy used by the lamp in Watt, I need to be able to get the current used by lamp. For that I use a current sensor (ACS712) that spits out analog data. However, as we know, Raspberry can't read analog data directly. For that, I use ADC chip called MCP3008.

Inside the project, you'll find a JavaScript class (/lib/MCP3008.js) for reading analog data from MCP3008 via Serial Peripheral Interface (SPI).

There are a lot of samples to read data from SPI using C#, but I haven't found one that uses Node.js. I kind of struggle to correctly query and access SPI device in Windows 10 IoT Core with Node.js. After get the right instance, reading the analog data out of MCP3008 is simple. Hopefully the class will save your time.

win10iot-azureiothub-smartlamp's People

Contributors

andriyadi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.