BH1750 - heating status

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

BH1750 - heating status

#1 Post by TungstenE2 » 13 Nov 2018, 20:12

Hi all,

I have BH1750 installed on Wemos D1 mini and attached to my central heating in the basement.
There is a small red status LED, where I would like to catch the status.

In normal mode the LED is turned on while heating. Lux = 3-4
If heating is off Lux = 0

In case of failure the LED is blinking, but not very fast.

I would like to create a rule or similar in order to get a notice via FHEM and Telegram that the heating is in failure mode.

So how best to catch the blinking? Using a counter?
BH1750.PNG
BH1750.PNG (20.84 KiB) Viewed 9070 times
thx

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: BH1750 - heating status

#2 Post by grovkillen » 13 Nov 2018, 20:16

You could use a timer and see it the change is still there after a second. See the rules section for the long press example.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: BH1750 - heating status

#3 Post by TungstenE2 » 14 Nov 2018, 08:38

ok, thx. So I will try to setup a dummy switch which will be set by a rule if lux >2. This will indicated the LED is on.

But I have a question on the timer and long press. How does the sample rule distinguish between short press and still pressed?
Is this because the timer was triggered and when the rule is checking the status is back to 0?
So I need to find the right duration of the LED blinking and change 'timerSet,1,1' accordingly?

Code: Select all

on Button#State=1 do
  timerSet,1,1
endon

on rules#timer=1 do
 if [Button#State]=0
  //Action if button is short pressed
 else
  //Action if button is still pressed
 endif
endon

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: BH1750 - heating status

#4 Post by toffel969 » 14 Nov 2018, 09:47

TungstenE2 wrote: 14 Nov 2018, 08:38 ok, thx. So I will try to setup a dummy switch which will be set by a rule if lux >2. This will indicated the LED is on.

But I have a question on the timer and long press. How does the sample rule distinguish between short press and still pressed?
Is this because the timer was triggered and when the rule is checking the status is back to 0?
So I need to find the right duration of the LED blinking and change 'timerSet,1,1' accordingly?

Code: Select all

on Button#State=1 do
  timerSet,1,1
endon

on rules#timer=1 do
 if [Button#State]=0
  //Action if button is short pressed
 else
  //Action if button is still pressed
 endif
endon
Hi

I think you should use a different sensor. In my experiene the BH1750 is just to slow to catch blinking LED's. Its a great sensor for ambient light. Just not very fast and the I2C protocoll causes overhead. All you really need is a digital output (LED on or not)

check out https://www.mysensors.org/build/pulse_power

for some inspirtation
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: BH1750 - heating status

#5 Post by TungstenE2 » 15 Nov 2018, 18:18

setup following rules:

Code: Select all

On System#Boot do
  TaskValueSet 2,1,0
  TaskValueSet 2,2,0
  endon

// reset HeatingError after 90Sek

on Heizung#Lux=0 do
  timerSet,2,90
endon

on rules#timer=2 do
  TaskValueSet 2,2,0
endon  


// set HeatingLED

on Heizung#Lux>20 do
  TaskValueSet 2,1,1
endon

on Heizung#Lux<5 do
  TaskValueSet 2,1,0
endon
  
// check if LED is blinking by checking Lux via Timer1   
  
on Heizung#Lux>2 do
  timerSet,1,1
endon

on rules#timer=1 do
 if [Heizung#Lux]<2
     TaskValueSet 2,2,1
 else
   TaskValueSet 2,2,0
   endif
endon
In general it seems to be working. Only problem is that when heating LED in normal mode is turned off, this is recognized by the rule and the error status is set. I am trying to fix this with timer 2, but seems like this is not working.

Any idea how to fix this?
BH1750-2.PNG
BH1750-2.PNG (40.24 KiB) Viewed 9012 times

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: BH1750 - heating status

#6 Post by grovkillen » 15 Nov 2018, 18:35

You should use a task run command after the TaskValueSet for it to trigger the events for those values
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: BH1750 - heating status

#7 Post by TungstenE2 » 16 Nov 2018, 07:23

can you provide me with the syntax of 'task run'? do not find a sample in the rules wiki.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: BH1750 - heating status

#8 Post by grovkillen » 16 Nov 2018, 08:22

TaskRun,<task number>
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: BH1750 - heating status

#9 Post by TungstenE2 » 16 Nov 2018, 10:07

thx, included it, but seems not to be working.

Code: Select all

On System#Boot do
  TaskValueSet 2,1,0
  TaskValueSet 2,2,0
  endon

// reset HeatingError after 90Sek

on Heizung#Lux=0 do
  timerSet,2,90
endon

on rules#timer=2 do
  TaskValueSet 2,2,0
TaskRun,2
endon  


// set HeatingLED

on Heizung#Lux>20 do
  TaskValueSet 2,1,1
endon

on Heizung#Lux<5 do
  TaskValueSet 2,1,0
endon
  
// check if LED is blinking by checking Lux via Timer1   
  
on Heizung#Lux>2 do
  timerSet,1,1
endon

on rules#timer=1 do
 if [Heizung#Lux]<2
     TaskValueSet 2,2,1
 else
   TaskValueSet 2,2,0
   endif
endon

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: BH1750 - heating status

#10 Post by grovkillen » 16 Nov 2018, 10:33

Sorry I must have misunderstood you. I suggest you use this rule instead:

Code: Select all

On System#Boot do
  TaskValueSet 2,1,0
  TaskValueSet 2,2,0
endon

// reset HeatingError after 90Sek

on Heizung#Lux=0 do
  timerSet,2,90
endon

on rules#timer=2 do
  TaskValueSet 2,2,0
endon  


// set HeatingLED

on Heizung#Lux do
 if [Heizung#Lux]>20
  TaskValueSet,2,1,1
 endif
 if [Heizung#Lux]<5
   TaskValueSet,2,1,0
  endif
  if [Heizung#Lux]>2 do
   timerSet,1,1
  endif
endon

on rules#timer=1 do
 if [Heizung#Lux]<2
     TaskValueSet 2,2,1
 else
   TaskValueSet 2,2,0
   endif
endon
May work?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: BH1750 - heating status

#11 Post by TungstenE2 » 16 Nov 2018, 11:49

hm, still not working as expected.

If heating is on, Lux is up to 24 and HeatingLED is 1 and HeatingError is 0.
If heating is off, Lux is 0 and HeatingLED is 0 but HeatingError is 1 and is not reset.
This is triggered as the tigger sees the LED is switching from 1to 0, but this should be reset, as it is not back to 1.

Blinking was recognized as expected, but normal mode when heating is off is not.

Dont know how to solve this...
BH1750-3.PNG
BH1750-3.PNG (28.26 KiB) Viewed 8977 times

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: BH1750 - heating status

#12 Post by grovkillen » 16 Nov 2018, 11:59

Move this part into the Heizung#Lux chunk:

Code: Select all

on Heizung#Lux=0 do
  timerSet,2,90
endon
Just as the other if statements.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: BH1750 - heating status

#13 Post by TungstenE2 » 16 Nov 2018, 12:50

moved it, but still the same result

Code: Select all

On System#Boot do
  TaskValueSet 2,1,0
  TaskValueSet 2,2,0
endon

  
on Heizung#Lux do
 if [Heizung#Lux]>20
  TaskValueSet,2,1,1
 endif
 if [Heizung#Lux]<5
   TaskValueSet,2,1,0
 endif
 if [Heizung#Lux]>2 do
   timerSet,1,1
 endif
 if [Heizung#Lux]=0 do
   timerSet,2,30
 endif
endon

// set HeatingLED
on rules#timer=1 do
 if [Heizung#Lux]<2
     TaskValueSet 2,2,1
 else
   TaskValueSet 2,2,0
   endif
endon

// reset HeatingError
on rules#timer=2 do
  TaskValueSet 2,2,0
endon

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: BH1750 - heating status

#14 Post by grovkillen » 16 Nov 2018, 13:58

Move this part to the top of the event chunk.

Code: Select all

if [Heizung#Lux]=0 do
   timerSet,2,30
 endif
If not it'll never trigger since it's also "<5"
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: BH1750 - heating status

#15 Post by TungstenE2 » 16 Nov 2018, 15:02

done, but still the same...

Code: Select all

On System#Boot do
  TaskValueSet 2,1,0
  TaskValueSet 2,2,0
endon

  
on Heizung#Lux do
 if [Heizung#Lux]=0 do
   timerSet,2,30
 endif
 if [Heizung#Lux]>20
  TaskValueSet,2,1,1
 endif
 if [Heizung#Lux]<5
   TaskValueSet,2,1,0
 endif
 if [Heizung#Lux]>2 do
   timerSet,1,1
 endif
endon

// set HeatingLED
on rules#timer=1 do
 if [Heizung#Lux]<2
     TaskValueSet 2,2,1
 else
   TaskValueSet 2,2,0
   endif
endon

// reset HeatingError
on rules#timer=2 do
  TaskValueSet 2,2,0
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests