Adding Brightness Sensor to Lights Logic

337 views
Skip to first unread message

Michael Ingraham

unread,
Sep 24, 2018, 2:56:54 PM9/24/18
to SonoffUsers
I am using Sonoff Basic switches to turn on some lights in out home. I have flashed the switches with TASMOTA. I am using openHAB to set up logic conditions for controlling different lights in the house. The rules use a combination of sun elevation, sunset/sunrise offset, and our location (i.e., are we home). Unfortunately, sun elevation and sunset/sunrise don't account for the actual "darkness" in some of our rooms (e.g., when it's overcast). I need to add a brightness sensor to the mix.

Options?
  • An "adjustable" sensor that I can "plug in" to GPIO 14 on the Sonoff that will trigger an on/off input to tell me the brightness has reached a certain threshold?
  • A "standalone" brightness monitor that will publish (ideally state messages via MQTT) it's readings? If not a push setup, I can poll the device periodically (again, MQTT?).
  • ...
Your experiences and advice are appreciated.

Regards.

Mike

Philip Knowles

unread,
Sep 24, 2018, 4:18:24 PM9/24/18
to Michael Ingraham, SonoffUsers

I think that you could do it quite easily with a light dependent resistor to A0 on an ESP12 device such as a LoLin.. You’d just need a dropping resistor drop the voltage to 1V and possibly a potentiometer

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Michael Ingraham

unread,
Sep 24, 2018, 9:21:49 PM9/24/18
to SonoffUsers
Phil,

First and foremost, thank you!

Is this the circuit as you describe?
LDR-NODE-MCU

Quick search for Lolin popped up "Lolin D32".
  1. Is this the module you meant?
  2. From the looks of it, this could be flashed with TASMOTA?
    • If so, is flashing this the same as flashing a NodeMCU?
  3. Is the upload directly through the microUSB port? Or do I have to connect leads to RX/TX etc.?
  4. How do you put the Lolin in programming mode?
  5. Is there a Lolin TASMOTA module type or do I choose Generic?
  6. Does TASMOTA report the LDR reading as a numeric value?

Regards.

Mike

Philip Knowles

unread,
Sep 25, 2018, 2:02:49 AM9/25/18
to Michael Ingraham, SonoffUsers

Your circuit is almost right but the LDR would be between A0 and 0V and the 10k resistor between 3.3V and A0. At least that's how I would do it. From memory LDRs resistance decreases with increasing light intensity so the voltage would increase and, again from memory, I think the max voltage at A0 is supposed to be 1V but I may be wrong. If you're allowed 3.3V your circuit would give you a larger number with brighter light so is more intuitive.
The Lolins are also known as Wemos. The Lolin V3 is slightly bigger. Search for ESP-12 E.
The latest allsensors.bin has A0 set as Analogue input as standard and just select the generic module.
Hope that helps

Regards

Phil K


To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers+unsubscribe@googlegroups.com.

Philip Knowles

unread,
Sep 25, 2018, 2:04:01 AM9/25/18
to Michael Ingraham, SonoffUsers

They have a Flash button next to the USB input

Regards

Phil K


--
Reply all
Reply to author
Forward
0 new messages