Iot Pir LedLight

Now the shorter days and the longer nights are arrived in The Netherlands it’s dark outside when leaving or coming from work.
From Ali express I bought some battery power led light with build in pir (passive infrared) and light sensor. Very handy, you stick them somewhere above the door with some dubbelsided tape and they will light up if some one, good or bad will approach the door.
It will also be handy if I get a notification on my smartphone  if some approached the door, so the idea was born.

Because I already had some domotica system with Iot (Internet of things) running it would be handy to integrate it with this. The small esp8285 Esp-M3 module was the one that will do the job, mostly because it’s small of size.  It will send a message to my mosquitto broker and with node-red it will handle the message.

The pir led light is battery powered so very low or no power consumption was required.
The idea is that when the leds are going on, the esp8285 will connect to the wifi, send a message to the broker, and then go in deep sleep. When the leds are going off again the esp8285 will be switched of completely and will therefore draw no current anymore.
After studying the controller (BISS0001) in the pir led light it was not that difficult to accomplish. Finding the correct output pin with the help of the datasheet was easy. This pin (2) will become high when the leds are turned on by the pir detector. With this is should be possible to switch on the esp8285.
The pir led light works on 4×1.5V battery and the esp8282 on 3.3V, so we need also a voltage regulator to get the correct voltage. The idea was to combine the switch on and regulator part, this made me choose for a regulator with an enabled pin. Also was it important that the regulator does drawn as low current as possible when disabled. Google and ali-express gave me the LC1463, a fixed voltage regulator that can deliver up to 300mA and draws only 0.1µA when disabled, perfect for the job.
This time no designed pcb, but floating wiring the parts together in the pir led light  with roadrunner wire.

Have a look at the schematic and picture to see how to connect. Not all the pir led lights from China are the same, but if they have the BISS0001 controller inside and you can locate the plus and minus coming from the battery it’s easy to connect.

Before soldering the esp8285 module in the pir led light you have to program it first. For this you need to connect the Vcc, Gnd, Txd and Rxd to your Usb to serial convertor. After plugin the convertor in the USB port you have to bring the esp8285 in download mode by resetting it and holding the GPIO0 to gnd. So for this you need to solder also an wire to reset and GPIO0. If the blue led on the esp8285 module short flashes it’s in download mode.
After downloading and testing the sketch you can remove the header, the reset and GPIO0 wire again. Be sure that your program works.
It’s also possible to bring the esp8282 in OTA (Over The Air programming) after programming, this can be done be placing the value 15 in the “/vm/tuin/pirsensorachter/status” topic. For more details see the sketch on github.

Current measured: 56µA when standby, 130mA when leds and wifi on (takes 4 seconds to login wifi and send message to the broker), leds on only 60mA.

The test sketch can be found on  Github

Schematic
Pir led light
Inside the lamp
Esp-M3 prog pins
Ldo floating mounted
Esp-M3 connected to pir lightsensor
Esp-M3 mounted in the case
Everything works fine
PlayPause
previous arrow
next arrow
 
Schematic
Pir led light
Inside the lamp
Esp-M3 prog pins
Ldo floating mounted
Esp-M3 connected to pir lightsensor
Esp-M3 mounted in the case
Everything works fine
previous arrow
next arrow
Sonoff Slampher V2.0

The Sonoff Slampher is a very interesting product for you domotica project if you don’t want to be to invasive in your electric system.
Factory default the Slampher has some descent software with a nice app, but if you want more for example connect is to your Mqtt broker you need to change the firmware.
If you want to program your own software or other software the can be found on the internet then you have to reprogram the ESP8285 inside

There are enough tutorials on the net how to reprogram the Slampher, however the Slampher that I bought on Ali Express is a new V2.0.
This version has an ESP8285 on board in staid of the famous ESP8266. The ESP8285 is ruffly the same as the ESP8266 except that it has an build in 1MByte flash memory.
With the Arduino ide the ESP8285 can also be programmed, luckily

Lets start;
To get the ESP8285 in flash mode we need to connect GPIO0 to the ground. To connect the button on the Slampher to GPIO0 we need to move a resistor. Normally the button is connect to the RF part to learn the Slampher the rf remote. We want to program the ESP8285 and for that move R21 to R3. It’s an 0Ω resistor so a piece of wire or solder will also do the job.
After that you need to connect your usb to serial convertor.  Pin 1: Vcc, 2:rxd, 3:txd and 4:gnd . The ESPxx works on 3V3 so don’t fry it with the 5V output of your convertor.
My convertor didn’t have enough mA to supply the Slampher direct so that’s why you see on the pictures a separate 3V3 power supply.
Press the button and insert the usb convertor in your computer and happy flashing.
Don’t connect the Slampher to the mains for your safety.
Personally I add to all my ESPxx programs the OTA (over the air) flash capability’s so you can remove the usb to serial convertor and close up the housing for safety purpose and flash new firmware ota.
The relay won’t work if you not connect the Slampher to the mains, it needs the 5V from the transformer.
Here is a small sample on GitHub to get is working, button, relay, ledgreen are supported. Ledred and the rf receiver are not (yet) supported.

Arduino ide settings:
Gerneric Esp8285 Module
CPU Frequency: 80MHz
Flash Size: 1M (64K SPIFFS)
Upload Speed: 115200

Overview pcb
Usb to serial
Powersupply
Move R2 to R3
PlayPause
previous arrow
next arrow
 
Overview pcb
Usb to serial
Powersupply
Move R2 to R3
previous arrow
next arrow
Iot LightSensor Node

It is some time ago, but finally a new project from me.
The idea was to make an light sensor for my domotica that will communicate with my Mosquitto Mqtt broker over wifi, the old light sensor was cast in epoxy but due the weather the epoxy got discolored and is not working therefore anymore accurate. And with accurate I meant not at all anymore. The TSL2561 was very interesting to use as sensor. There are some nice Arduino library’s that are very complete.
During design there was also a temperature sensor (DS1820) and decibel meter (MAX4466 module) added. Don’t know if the decibel meter will be accurate, but it’s just for logging the airplanes flying over my house. The decibel meter will later be calibrated with an real decibel meter, we will see how accurate this is.

The design started with finding a suitable enclosure, water resistant and suitable for measuring light. On ebay I found a nice one and not that expensive $8,00
When the sensor was in I first took it apart and see what the possibilities are with the enclosure.

A round pcb with a diameter of 63mm was needed. I want to design the board with Altium Designer to get more familiar with this pcb design software. Easier said then done.
It’s my 4e design with Altium, but because of the round pcb and the strange angles that some of the components must placed it took some time to get it all finished. But it was all very educational.

The first ideas was to use the new ESP32 module, would be nice to use this very powerful mcu in the design, but there was no room enough. Next time if there’s not enough room I will not use the ESP32 module, but just the ESP32 mcu. Due the connector in the center of the pcb with it’s mounted to the enclosure there was not that much space as it looks like. Because of the limited usable space i used the good old EPS8266 module, the Esp-12.

Pcb is ordered, story will be continued.

Update 11/03/2018:
It took some time to finish this project. Due some stupid and unseen design faults I had to redesign the pcb 2 times.
In V1 I was completely forgotten that the ESP8266 has an AD convertor with a max input of 1V and the microphone amplifier was spitting out Vcc and that’s is 3.3V.
After adding a voltage divider in V2 the mic amplifier was sensitive to the noise on the Vcc rail and added a lot of switching noise to the output of the amplifier.
In V3 there was a lowpas filter added in the power supply line to the mic amplifier and that did the job, smooth about from the amplifier.
Still not all problems solved, the mic amplifier didn’t amplified enough and after some testing I noticed that in the original design from Adafruit they used an 100K pot meter and my amplifier from Ebay had a 10K resistor. After replacing that everything worked fine and the data is coming in nice. Except the temperatuur sensor, because it’s inside the enclosure it doesn’t measure accurate.

Schematic
Pcb design front Altium
Pcb design back Altium
Sensor orginal split
Sensor original inside
Sensor original pcb
Noise
Wrong potmeter
Finished pcb top view
Finished pcb mounted in housing
Finished sensor hanging outside
PlayPause
previous arrow
next arrow
 
Schematic
Pcb design front Altium
Pcb design back Altium
Sensor orginal split
Sensor original inside
Sensor original pcb
Noise
Wrong potmeter
Finished pcb top view
Finished pcb mounted in housing
Finished sensor hanging outside
previous arrow
next arrow

 

If you want to make your own, or use some parts. Altium 16 Schematic and pcb files.

1766 Downloads

Esp32s Altium library

Altium designer 16 library for the Esp32S wifi-bluetooth module.
Library design base on the Espressif Esp-Wroom-32 module that should be the same as the Al thinker Esp32s.

Note: Design is not yet verified because I don’t have the module yet.

Update 9 Feb 2017: Finally I received the module. Good news it matches my Altium design.
Made also a wider footprint for people who want to solder the module by hand.

 

 

 

 

 

 

 

 

 

 

 

 

7729 Downloads