Author Topic: Light Sensor Demo Project  (Read 158 times)

mcThings

  • We Connect Things To The Internet... That Can't Be Plugged In.
  • Administrator
  • Jr. Member
  • *****
  • Posts: 68
    • View Profile
    • www.mcthings.com
Light Sensor Demo Project
« on: July 19, 2016, 11:23:42 am »
Light Sensor Demo Project
In this project we showcase the use-case of a light sensor that is soldered into a mc-module. We go through the soldering process and allow you to see the mc-studio code. You can find the full code posted below.

https://youtu.be/X92i4d88FVE

Code: [Select]
Define PinMode Pin0 As AnalogInput Alias lightVoltage

Define PinMode Pin6 As DigitalOutput Alias enableLightVoltage   

Class LightVideo         

Shared Event measureLight() RaiseEvent Every 50 milliSeconds                 

enableLightVoltage = True 'turn on voltage
divider         

Thread.Sleep(20000) 'sleep 20ms for
voltage to stabilize         

Dim voltage As Short = lightVoltage         

If voltage > 900 Then             

LedRed = True                     


Else             

LedRed = False                     

End
If                 

enableLightVoltage = False 'turn off voltage
divider     

End Event     

Shared Event sendMQTT() RaiseEvent Every 1 Minutes         

LedRed = True                 

Dim
payload As ListOfByte = New ListOfByte()       

Dim TempC As Float = TempSensor.GetTemp
       
Dim TempString As String = TempC.ToString()
               
payload.Add(TempString)
               
Lplan.Publish("mcThings/OutsideTemp", payload)                 

LedRed
= False     

End Event     

Shared Event measureVoltage() RaiseEvent Every 2 Hours                 


Dim
BattVolt
As Short = Device.BatteryVoltage                 

If BattVolt < 2200 Then             


Lplan.IFTTT("YOURUNIQUEIFTTTKEYHERE", "OutsideBatt")         

Else                     


End
If             

End Event

End Class

Social Buttons

Like Like x 1 View List

mc-T2

  • Administrator
  • Full Member
  • *****
  • Posts: 239
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: Light Sensor Demo Project
« Reply #1 on: July 19, 2016, 11:41:22 am »
Hi everyone! This project is quite simple but we wanted to show how easy it is to attach sensors to the mc-Modules. A couple of things that you could do to enhance this project could be:


- In an office building, you could use the light sensor to detect the light intensity and then:
   a) based on the outside light coming into the office, you could dim the office lights to save energy during the light hours of the day. when it starts to get dark, you could have the modules increase the light intensity of the office.
   b) You could also use this scenario to ensure that you are doing your best to help your employees maintain their optimal Circadian Rhythms which increases efficiency and health & wellness!

- In a greenhouse or agriculture scenario, you could be alerted and log what the light intensity is to ensure that you are in optimal growing conditions?
- Using MQTT, have the mc-Module publish to your phone when it is light or dark out?
- Using MQTT, publish when light is detected. You could have another module subscribe to that topic and when it detects 'dark' you could have it turn on a light  in your house or outside?
- Use the light sensor to log in a spreadsheet (using IFTTT) when the sun rises or sets at your house?

There are probably many more uses for this sensor and mc-Modules not to mention the countless other use-cases when it comes to other sensors and the mc-Thing platform!

We will continue to create more project videos with different sensors and scenarios to show you the incredible versatility of the mc-Things platform.
If you have any suggestions on how else you could use a light sensor with an mc-Module,, please post it in the comments!
If you have any suggestions on other videos or projects that you would like to see in a video, please let us know and we will do our best!
« Last Edit: July 19, 2016, 11:52:09 am by mc-T2 »
Need more mc-Modules, mc-Gateways or other mc-Things? Check out our product page: www.mcthings.com/products. mc-Development kits are available too!
Check out a live Dashboard using mcThings and Losant! Click here: https://goo.gl/ST43hB