BRUH DIY Multisensor

Once they don’t suck, yeah :slight_smile:

1 Like

Is it possible to change the colour of the LED?

And/or make it lit when te motion is activated?

Yes and yes. You can use normal automations for this

I had it turning red when motion was detected and green when was no motion.

To activate the LED in hass:

light:

  • platform: mqtt_json
    name: “LED”
    state_topic: “sonoff/sonoff”
    command_topic: “sonoff/sonoff/set”
    brightness: true
    flash: true
    rgb: true
    optimistic: false
    qos: 0

Then the automation:

automation:
alias: TEST with Motion
trigger:
- platform: state
entity_id: sensor.pir
from: ‘standby’
to: ‘motion detected’
action:
- service: light.turn_on
entity_id: light.led
data:
brightness: 150
rgb_color: [255, 0, 0] # This is RED you can choose here the color you want

1 Like

SO it always stays green and when there is motion goes red?

I would rather have a quick blink of a colour (red for example) when there is motion and that’s it, when no motion off.

My automation works, but the LED is on for 5-6 seconds, a bit too much, how to solve?

  - alias: "Motion Office SN3- ON motion light"
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.sn3_pir
        from: 'standby'
        to: 'motion detected'
    action:
      - service: light.turn_on
        entity_id: light.sn3_led
        data_template:
          brightness: 255
          rgb_color: ['{{ (range(0, 255)|random) }}','{{ (range(0, 255)|random) }}','{{ (range(0, 255)|random) }}']
      - service: mqtt.publish
        data:
          topic: sensor/livingSN3
          payload: "on"
          retain: "true"
#
# Automation off
  - alias: "Motion Office SN3- OFF motion light"
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.sn3_pir
        state: 'standby'
        for: '00:00:01'
    action:
      - service: light.turn_off
        entity_id: light.sn3_led
      - service: mqtt.publish
        data:
          topic: sensor/livingSN3
          payload: "off"
          retain: "true"
1 Like

you can try instead having only only for flash when motion is detected(?)

something like this:

action:
- service: light.turn_on
entity_id: light.led
data:
rgb_color: [0, 255, 0]
flash: ‘short’

1 Like

No, it flashes, but then it stays on for 5-6 seconds

I changed like this and now is ok, It flashes only.

I notices that it takes 5-6 seconds to go from MOTION to back to STANDBY … anyway to change this and make it shorter, like 1 second?

#
  - alias: "Motion Office SN3- ON motion light"
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.sn3_pir
        from: 'standby'
        to: 'motion detected'
    action:
      - service: light.turn_on
        entity_id: light.sn3_led
        data_template:
          brightness: 255
          rgb_color: ['{{ (range(0, 255)|random) }}','{{ (range(0, 255)|random) }}','{{ (range(0, 255)|random) }}']
          flash: 'short'
      - service: light.turn_off
        entity_id: light.sn3_led
      - service: mqtt.publish
        data:
          topic: sensor/livingSN3
          payload: "on"
          retain: "true"
#
# Automation off
  - alias: "Motion Office SN3- OFF motion light"
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.sn3_pir
        state: 'standby'
        for: '00:00:01'
    action:
#      - service: light.turn_off
#        entity_id: light.sn3_led
      - service: mqtt.publish
        data:
          topic: sensor/livingSN3
          payload: "off"
          retain: "true"
1 Like

probably needed to change the arduino code? But how?

It is possible to run two PIR’s off one NodeMCU with one one VIN? Could I run an additional PIR from a 3.3v pin?

I was planning on ditching one of the other sensors, temp, LED or LUX sensor.

Many thanks

you can without any problem I guess, all these sensors do not use much current. However, you have to check the datasheet of the sensor to make sure it will work with 3.3V. If not, you must wire it to VIN also, using a breadboard or solder to wire the two to the same pin.
Also, if you have only BRUH’s sensors, there is still GPIO pin lefts on the nodemcu, so you can add the extra PIR without removing the other stuff.
You will also need to adapt the arduino code to take into account the new PIR

Excellent, thank you. I already have a number of BRUH nodes. Two of them have reed switches for doors and also a push button to trigger an automation using the spare GPIO pins.

I’ll have a go tonight! thanks!

I use these mini breadboard with my multisensor as I added a lot of other sensors to them. You just need to have female to male wires along with them and everything works like a charm.

https://fr.aliexpress.com/item/Free-shipping-Mini-25-Tie-point-Breadboard-Solderless-Prototype-Test-Board/32562517170.html?spm=2114.13010608.0.0.RYSNQx

They’re nice, might have to get some.

I’ve just been soldering the wires, reeds, switches and resistors to the wires and putting them in project boxes, these might be easier as it’s a bit of a faff soldering and using heat shrink.

Plus if a sensor ever failed this would make it much easier to replace!

Cheers!

Hi, I just copy and past Bruh code in Arduino and change wifi and mqtt info and when I verify the code getting following error:

E:\MultiSensor\BrushMultiSensor\BrushMultiSensor.ino:32:17: fatal error: DHT.h: No such file or directory

#include <DHT.h>

             ^

compilation terminated.

exit status 1
Error compiling for board Generic ESP8266 Module.

download DHT library

after downloading the DHT library getting following error:

Arduino: 1.8.2 (Windows 10), Board: “Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 1M (64K SPIFFS), ck, Disabled, None”

Build options changed, rebuilding all
BrushMultiSensor:68: error: ‘D1’ was not declared in this scope

const int redPin = D1;

                ^

BrushMultiSensor:69: error: ‘D2’ was not declared in this scope

const int greenPin = D2;

                  ^

BrushMultiSensor:70: error: ‘D3’ was not declared in this scope

const int bluePin = D3;

                 ^

BrushMultiSensor:72: error: ‘D7’ was not declared in this scope

#define DHTPIN D7

               ^

E:\Amazon Alexa\Sonoff\Arduino\Bruh MultiSensor\BrushMultiSensor\BrushMultiSensor.ino:136:9: note: in expansion of macro ‘DHTPIN’

DHT dht(DHTPIN, DHTTYPE);

     ^

E:\Amazon Alexa\Sonoff\Arduino\Bruh MultiSensor\BrushMultiSensor\BrushMultiSensor.ino: In function ‘void setup()’:

BrushMultiSensor:71: error: ‘D5’ was not declared in this scope

#define PIRPIN D5

               ^

E:\Amazon Alexa\Sonoff\Arduino\Bruh MultiSensor\BrushMultiSensor\BrushMultiSensor.ino:145:11: note: in expansion of macro ‘PIRPIN’

pinMode(PIRPIN, INPUT);

       ^

BrushMultiSensor:72: error: ‘D7’ was not declared in this scope

#define DHTPIN D7

               ^

E:\Amazon Alexa\Sonoff\Arduino\Bruh MultiSensor\BrushMultiSensor\BrushMultiSensor.ino:146:11: note: in expansion of macro ‘DHTPIN’

pinMode(DHTPIN, INPUT);

       ^

E:\Amazon Alexa\Sonoff\Arduino\Bruh MultiSensor\BrushMultiSensor\BrushMultiSensor.ino: In function ‘void loop()’:

BrushMultiSensor:71: error: ‘D5’ was not declared in this scope

#define PIRPIN D5

               ^

E:\Amazon Alexa\Sonoff\Arduino\Bruh MultiSensor\BrushMultiSensor\BrushMultiSensor.ino:427:28: note: in expansion of macro ‘PIRPIN’

 pirValue = digitalRead(PIRPIN); //read state of the

                        ^

exit status 1
‘D1’ was not declared in this scope

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

Did you follow the instructions: download the zip version, install it and make a portable folder?

Yes, already installed and make portable folder for Sonoff, additionally install
- DHT sensor library
- Adafruit unified sensor

The not declared part issue could be due to the board you have selected (esp8266 generic or wemos d1 etc. etc.), if you select the wemos d1 board you’ll see that those specific error messages will dissapear (did for me) however, selecting the esp8266 generic board/nodemcu board you’ll have to translate those d1, d2 etc. to actual gpio ‘numbers’, like:

const int greenPin = D2; should be const int greenPin = 4; etc. etc.

This is what fixed it for me back when I got those specific errors, hopefully might do it for you too.
Here is one of the pinout images for nodemcu boards:

1 Like