I finished the challenge and being new to this blog and new to the Azure Sphere, it was a real challenge to get something interesting up and running. Also, The changes By Microsoft to the SDK and OS, added more challenges to a moving target. But Things were only made much better. It gave me a sense that I was on the cutting edge by using the Beta version.

 

My background and career for the past 35 years has been as a Software Engineer. Now, I'm retired and concentrating on Learning more about IoT as a hobby. My Electrical experience is very slim, but I'm learning more and more.

 

I created this blog post on November 12, 2019 in a hope of documenting my steps. This was entered into the competition and confirmed in a discussion by Daniel Zima of the element14 Team on Dec 2, 2019 9:43 AM.

My username is on the list, so I now know that I'm in the competition.

I've been pinging  the server  and wanted to start documenting my progress from the design phase.on a project for the challenge.

 

I received a lot of assistance from this blog and felt a real sense of collaboration.. I will continue to use this instead of hackster.io for my continued projects as a maker hobbyist. Well done element14....

I used all the tutorials and Information on this blog to implement the concept and design listed below. It turned out that I didn't need to write a bit of code and used the on-board sensors to gather Telemetry data for my Solution.

This was a steep learning curve for me but, I was able to get my solution done and running on the kit. Thanks guys for the excellent explained blog post.

 

There are so many interesting projects that were submitted and I plan on reviewing and using some as examples to implement my other  ideas that I have for the Azure Sphere.

 

I started by listing the stages of the project

 

Stage
Concept

My wife always complains that I leave the light on in rooms in the house that are unoccupied.

So I thought to implement a solution that would record the time of day that a light was on in a room.

The solution is centered around the Avnet  Azure Sphere MT3620 Starter Kit

  • Design

 

  • I will be using the on board Light Sensor for this project.
  • I need to Research and Learn how to read the data from this Sensor.
  • The software will :

 

    1. Be able to read the Light sensor data
    2. Define a time-span that it will send the data out. The Time-span will be in the range when the room has no Sunlight.
    3. It will determine the Luminosity level that Will represent a Light Being on and Not Sunlight.
    4. An email will be sent when this threshold is reached.
      1. A value while determine how many times the email will be sent (ex. send 10 times)
      2. A value will determine how often in Minutes it will be sent.  (ex Every five minutes.)
      3. The emails will stop being sent after the Luminosity value drops below this Threshold
      4. A value will determine how much time should elapse before starting to send an email.  (ex Wait 30 minutes )

 

  • The Data Will:
    1. Be stored in the cloud.
    2. The data can be analysed to:
      1. Report how often the light is left on
      2. How long the light was left on
      3. configure the software .

 

Development

Task
  • Setup the Kit
  • Get your Sphere Starter kit setup and working
  • There are various task that you need to d,  to get you to a point of having the kit set up and working.
    • SDK installed for development
    • Install Visual Studio
    • Getting your kit registered with Azure.
    • Create a Tenent and Connecting to an azure account and claiming the device.
  • I found this to be an Excellent  project to do the previous steps here
CODE step 1 -- on board Light Sensor

Use the on board Light Sensor device on the kit to detect that the Light is on.

NOTE it can be sunlight! You will have to program a time period that the sensor is working

IDEA: send this up to the device twin

You;ll be able to change the time span in Iot Central

CODE step  2-- Send Data to the cloudSend the light sensor information to Azure IoT Central
CODE Step 3 -- Send a Notification.Send an email if the light is on and falls in the time period assigned. Using The Iot Central Actions
Test

Hopefully it works and that you don't run up charges on Azure IoT Central, which can add up.

Even though you have 50,000 messages a month and up to 5 devices for FREE. You can chock up pennies pretty quickly if you process all the sensors Telemetry data.



 

HERE ARE THE DEVELOPMENT STEPS

 

SETUP the KIT

A great detailed way to do this is here: https://www.hackster.io/monica/the-lazy-person-s-guide-to-azure-sphere-1c513a

Check it out. I was able to get the Kit Up and running about 5 hours after I received my kit in the mail. Being secure does have a sharp learning curve, but once you understand the architecture, its quit amazing.

 

 

 

Code

     HOW to read the light sensor?

  • Well, I used these projects on element14 from Peter Fenn
  • They access the Light Sensor
    • one using the A7 and A4 cores the other using a new feature of the OS version 19.9
  • I used these code samples to Send the Light Sensor data  to Azure IoT central and used the Email Alert rule to Send the email to tell me when the light was on.
  • There was no code to write for this project. All the functionality I needed to track the Light Sensor Telemetry data was already written. These are excellent starting points to reading the On-board kit sensors,click boards and an optional OLED Display.
  • I did not order the OLED Display, but the demos worked  fine without it. My soldering skills are not up to snuff and I didn't want to harm the board with my inexperienced soldering techniques.

 

 

Here are the Tutorials that I studied, used  and found extremely helpful in understanding the SDK, OS and Azure IoT Hub and IoT Central services used to implement my Solution.

Thanks to Authors Brian Willess and Peter Fenn. Your help is greatly appreciated.

 

Avnet's Azure Sphere Starter-Kit (Out of Box Demo) Part 1 of 3

Posted by Brian Willess element14 Team in Azure Sphere on Apr 24, 2019 6:58:25 AM

 

These 3 "Out-of-Box demo" three-part blog series (by Brian Willess) is an excellent starting point for you to use the on-board sensors to gather Telemetry data.

 

This "advanced tutorial" is partitioned into two sections, enabling it to be worked on in two sessions:

• 1st section focus is on configuring, building and running the M4 and A7 embedded applications (and viewing local output from these applications)

• 2nd section walks the user through the capabilities and expansion options of the Azure IoT Central cloud application that the A7 embedded application is connected to

 

It consolidates what was covered in Part 1 and Part 3 of the "Out-of-Box demo" three-part blog series (by Brian Willess) but adds shortcuts and a number of new capabilities to the overall application (see detail below).

This tutorial is intended to be used standalone (no dependency on previous material) but it is recommended that at minimum Part 1 of the earlier blog series be reviewed before starting.

 

I've COMPLETED THIS ONE AND IT IS somewhat WORKING NOW

I'll be able to use what I learned to  complete code steps 2 and 3 mentioned above.

But I was unable to CMake the A4 project for some reason.

 

Azure Sphere OS 19.09 - New Capabilities for your Starter Kit!

Another way of getting to the light sensor with new enhancements  to the OS and SDK

https://www.element14.com/community/groups/azuresphere/blog/2019/10/12/azure-sphere-os-1909-new-capabilities-for-your-starter-kit

Can use Enabled New Chip Features

ADC inputs and PWM output peripheral functions are now accessible from the high-level A7 user application

I have used this tutorial to Access the Light Sensor from the A7 level. It is much easier

 

 

Send Data to the Cloud

     The 2 demos above connect to IOT Central and IOT HUB

      Be careful to not leave the program running on the kit, you can easily runny up charges, as I describe HERE.

 

Send a notification

     How to Send Email?

          IOT CENTRAL HAS THIS ABILITY without any programming involved

          You can easily create a Rule with a snap.

          Configure Azure IoT Central Rules (Email Alerts) to send emails if the light sensor goes over a certain threshold.

          I was unable to implement my design spec:

      • it can be sunlight! You will have to program a time period that the sensor is working
      • IDEA: send this up to the device twin.  You'll be able to change the time span in IoT Central

      

 

TEST  Works fine