IoT Esp8266 BME280 sensor

Iot Esp8266 temperature, humidity, atmospheric pressure and light sensor.

After the problems with my sensor based on the DHT22 time for a redesign, this time with the BME280 for measuring temperature, humidity and atmospheric pressure. The TSL2561 known from my light sensor node is used for measuring light level.

Note: it’s hard to solder the TSL2561 and it’s even harder to solder the BME280, think it over before starting on it if you want to make your own copy.
My first 4 attempts soldering the BME280 failed. With a chip this small and the small pads that are needed for it, it’s important that to all the pads there’s an equal amount of solder paste applied. If that’s not the case the whole chip rest on the pads with the most solder and will not make contact with the other pads, extra handicap is in this case that the BME280 has a metal case an will make very easy a short circuit if you use to much solder.
I have ordered now a stencil to apply the solder paste even on the pcb. To be continued….

Update 02 April 2018
Stencil is finally in. Due the Chinese new year it took some time before they produced and shipped it. I have ordered it from Jlcpcb and it costs only $9 including shipping, unbelievable cheap.
That’s a huge stencil for such a small pcb, it didn’t even fit in the mailbox and had to collect it from the post office.
Stencil is for 2 different project’s, the upper 2 are for this project. The stencil I ordered was 100µm thick, not a standard thickness they sell, but ask for it and you will get it. Components with that small pads as the BM280 requires not to much paste, that’s why I prefer 100µm for those kind of components.
With the stencil is was easy to apply the solder paste and with the heat gun is was all soldered with ease.
Have a look at my making of the Colinkex jtag to get an idea how to apply the paste simple with not to much effort at home.

After testing every works very well. Temperature, humidity, atmospheric pressure and lux are send with the help of MQTT to the SQlite database and Node-red ones in the 2 minutes.
Some fine tuning in the with Arduino created software to disable the BME280 and TSL2561 just before the ESP8266 goes in deep sleep to reduce the standby power. Standby current is now 42µA, more then the sensor with the DHT22 (27µA) but good enough.
Btw, to measure the standby current that precise I used the µcurrent designed by Dave Jones from EEVblog.

Pcb bare front
Bare pcb back
Pcb with stencil
Pcb with stencil closeup
Pcb front finished
Pcb back finished
Sensors closeup
Sleep current
PlayPause
previous arrow
next arrow
 
Pcb bare front
Bare pcb back
Pcb with stencil
Pcb with stencil closeup
Pcb front finished
Pcb back finished
Sensors closeup
Sleep current
previous arrow
next arrow

 

You want to make your own, download the Altium Designer 16 files.

1508 Downloads

 

EWelink touch hack

This time a hack on the EWelink wifi touch switch.

The EWelink touch switch is a similar product as the Sonoff touch, but I find the look a bit nicer. It’s more streamlined and is also available with black front.

The EWelink is sold in 1,2 and 3 gang version for the EU and US market.
I had only the 2 gang EU version, but it looks to me that the 1,2 and 3 gang EU version are the same. They left some parts out, but the pcb’s are all the same.
Can’t say anything about the US version, don’t have one to take apart.
The hart of the EWelink touch switch is the PSF-B04 module. This module contains inside the well know ESP8285, that’s in fact an ESP8266 with build in 1M flash memory.

Just like the hacks for the Sonoff products we need to connect Txd, Rxd, Vcc, Gnd and Gpio0 to the touch switch to make it possible to upload our own firmware.
Bummer, EWelink didn’t provide us just like Sonoff with a header where most of the pins required are easy accessible.
Time to get the soldering iron and solder some header pins direct to the PSF-B04 module. Because you can’t and won’t program the touch pcb when it’s connected to the power pcb, you need to provide it also with 3.3V power.
For the Gpio0 a simple wire will do the trick to get the ESP8285 in programming mode.

Pin mapping:

Wifi Led Gpio-13
Touch input Relay + led
left Gpio-0 Gpio-12
middle Gpio-10 Gpio-4
right Gpio-9 Gpio-5

The 1 gang uses the middle touch sensor, the 2 gang uses the left and right touch sensor and the 3 gang uses them all.

Note:It looks to me now that they place some resistors in other places for the 1,2 and 3 gang. Think they do that for example so touch1 is always connected  to gpio0, but in the 1gang touch1 is in the middle and for the 2 gang the touch is at the left . Can’t verify this because I only have the 2 gang.

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

 

Important Note: As you can see in the last picture below they have placed a screw between the fase (L) and neutral (N) to hold the power pcb in place. The screw makes the isolation distance between the L and N to narrow. The minimum isolation distance requirement for 230V~ is 2.5mm and preferable  >3mm. With my Ewelink is was total 2.4mm, that’s not enough.
Simple solution, remove the screw, it doesn’t do anything. The power pcb can’t move because of the screw terminals and the other screws.
Do this all at your own risk.

 

Touch switch front
Touch switch back
Touch pcb
Pcb front connection
Programmer connected 1
Programmer connected 2
Isolation distance
PlayPause
previous arrow
next arrow
 
Touch switch front
Touch switch back
Touch pcb
Pcb front connection
Programmer connected 1
Programmer connected 2
Isolation distance
previous arrow
next arrow

 

Sonoff Touch Led Mod

Just like in all other Sonoff products one of the leds is hardwired to the relay and will lit up when the relay is switched on.
In my post over the Sonoff Wifi powerline switch mod I described how to put the led on a seperate IO pin of the Esp8266 so you can get full control over the led.
This post will do the same for the Sonoff touch led that’s behind the touch sensor.

The Sonoff touch has an Psf-a85 module on board from Itead, this module has the esp8285 inside. With the pinout and schematic available of the psf-a85 it’s easy to find the required pins.

You need to scratch the pcb track that’s going to the 1K resistor (see picture below). After that you need solder a thin wire between the 1K resistor and one of the free IO pins on the psf-a module, in the picture I choose pin 3 IO4.

Now you have full control over both (wifi and touch) led.
My idea was to let the touch led glow so you can find the touch button easy in the dark.

If you don’t know how to flash the esp8285 have a look at this.
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.

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

Demo/test Sketch at Github

 

Sonoff Touch, Touch led glow

 

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