BH1750 - heating status
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 135
- Joined: 03 Apr 2018, 21:46
BH1750 - heating status
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?
thx
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?
thx
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: BH1750 - heating status
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



-
- Normal user
- Posts: 135
- Joined: 03 Apr 2018, 21:46
Re: BH1750 - heating status
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?
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
Re: BH1750 - heating status
HiTungstenE2 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
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
-
- Normal user
- Posts: 135
- Joined: 03 Apr 2018, 21:46
Re: BH1750 - heating status
setup following rules:
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?
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
Any idea how to fix this?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: BH1750 - heating status
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



-
- Normal user
- Posts: 135
- Joined: 03 Apr 2018, 21:46
Re: BH1750 - heating status
can you provide me with the syntax of 'task run'? do not find a sample in the rules wiki.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: BH1750 - heating status
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



-
- Normal user
- Posts: 135
- Joined: 03 Apr 2018, 21:46
Re: BH1750 - heating status
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
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: BH1750 - heating status
Sorry I must have misunderstood you. I suggest you use this rule instead:
May work?
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
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



-
- Normal user
- Posts: 135
- Joined: 03 Apr 2018, 21:46
Re: BH1750 - heating status
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...
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...
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: BH1750 - heating status
Move this part into the Heizung#Lux chunk:
Just as the other if statements.
Code: Select all
on Heizung#Lux=0 do
timerSet,2,90
endon
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



-
- Normal user
- Posts: 135
- Joined: 03 Apr 2018, 21:46
Re: BH1750 - heating status
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
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: BH1750 - heating status
Move this part to the top of the event chunk.
If not it'll never trigger since it's also "<5"
Code: Select all
if [Heizung#Lux]=0 do
timerSet,2,30
endif
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



-
- Normal user
- Posts: 135
- Joined: 03 Apr 2018, 21:46
Re: BH1750 - heating status
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
Who is online
Users browsing this forum: No registered users and 10 guests