IoT Esp8266 Temperature and humidity sensor

This is my second project with the Esp-12-e module that contains the famous esp8266 from Espressif.
This sensor will connect to my Mqtt broker and send data to it. The broker will then with the help of Node red store it in an sqlite database and make some nice charts of it.
There are other similar sensor on the web, but I like to design and make my own. It’s my hobby and work.
The software will be writen with the Arduino ide for simple and quick design.
This is my second design now with Altium desiger. Switched from Eagle to Altium because Eagle has it’s limitation, not for this design but for more complexer. This board was not to difficult to start learning using Altium, and if I messed it up also not to expensive.

The hart of the board is the Esp-12-e module with a DHT22 Temperature and humidity sensor, all powered from a 16340 Li-ion battery that must last for at least a year. That’s what we hope.
The board contains also a ldo voltage regulator, led for debugging etc, some extra pads for  “you never know in the future” and a programming socket. This socket is only used ones to program in the OTA and after that updating the firmware can be done over the air.

For now there’s nothing more to see then the 3D images from Altium Designer. Pcb’s are ordered in China and I have to wait for 2~4 weeks before they are here.
The picture is the panalized version, but the download version is a single board.

 

Update 3/10/2016:
Boards are in.
After some quick testing the esp8266 was not always starting up. My mistake, I forgot the pull-up resistor(12k) on gpio2.
The esp8266 determines with the help of gpio 0,2 and 15 how it will boot. With the gpio2 floating this gave problems.
esp8266startup

Added the pull-up resistor (R7) already to the Altium files below. If there are no more errors maybe I going order some new pcb’s.

 

Update 14/10/2016:
I wrote a small test program to test the hardware and get some numbers out and from it. You can find the test program on github.
Hardware is working fine. DHT22 (btw is official a AM2302, see source ) temperature reading is slightly different from my (also uncalibrated) temperature meter. 0.4 °C is more then the 0.2°C according the datasheet, but I’m not sure how accurate the temperature meter is.
Humidity is even harder to say if it’s correct because I don’t have anything to compare with.
Current consumption is around 27μA with a supply voltage of 3.6V.
Calculated is 10μA for the Esp8266 + 8μA for the battery measure voltage divider + 4μA for the LDO quiescent current = 22μA.  Not bad result.
Because you can switch off the DHT22 completely by removing the power supply from it (gpio5) your not draining the additional 500μA standby current for this sensor. This will result in longer battery lifetime.

Update 7/10/2017:
Finally I got time to finish this project.
But what a disappointment, the battery on last for 1 day and we where hoping for a year 🙁 . Was sending every 30sec data to the mqtt broker and a collect and send data cycles from the esp8266 took 8 seconds.
So this made that the esp8266 120×8 seconds = 960 seconds = 16 minutes running every hour. 16min x 24 hours is 384 minutes. So the temperature and humidity sensor can run continue 384 minutes on a 3.6V Cr123a 1200mAh Li-io rechargeable battery. That’s not even that bad.
For longer battery life I optimized the code and reduced the data collect and send cycles time to 4 seconds. I’m now collecting the data during the periode that the wifi connection is setup, so that the total time that wifi is connected is reduced and with this the cycles time is down from 8 to 4.2 seconds.
I also changed the sample rate from 30sec to 5 minutes. This will bring down the running time 12×4.2 seconds=50 seconds every hour.
With this and a 2800mAh (Chinese specs) Cr123a battery that I ordered it should be possible to run 1 month from the battery, reducing the sample rate will even extend the battery life.
Pcb and battery where nicely fit in an Cr123a storage box, is no coincidence because the pcb was designed to fit in this box.

Update 11/03/2018:
It has been sometime ago with my last update.
What a drama with those Lithium-ion batteries, none of the batteries bought on ebay or Ali express have the capacity they promise. 1200mAh, 2800mAh forget it 250mAh is what you can get out of it. That’s why my first test with the sensor where that disappointed, if the battery only last 1/5 of the time promised 🙁
Bought now a Nitecore Li-Ion battery from Reichelt and now you know why this battery is 4x expensive then those from Ali-express, it was rated at 650mAh and after testing you could get 647mAh out of it, that’s better. The battery will last now for 1 month.
The second problem that occurs is that the DHT22 will stop working reliably below 3.3V. Bummer, the idea was that it should work down to 3.0V. Completely my fault and a bit of Adafruit. On there website was advertised that it works with 3.0V, however in the datasheet they talk about 3.3V, the rest of the internet (except those who copied Adafruit there text) are mentioning the 3.3V. Due this fault you can’t use a part of the battery charge because the sensor won’t work good.

With those problems in mind I decided to stop using the DHT22 and after some searching and reading the BME280 was the one the should do the job better. Have a look at this post to how this is going.

 

Design front Altium
Design bacl Altium
Pcb V3
Test setup V1
Finished pcb back
Programmer connected
Temperature validation
Standby power consumption
Data is coming in
Finished module with sensor
Finished box opened
Finished project
PlayPause
previous arrow
next arrow
 
Design front Altium
Design bacl Altium
Pcb V3
Test setup V1
Finished pcb back
Programmer connected
Temperature validation
Standby power consumption
Data is coming in
Finished module with sensor
Finished box opened
Finished project
previous arrow
next arrow

 

Altium 16 Design files V3

1980 Downloads

Kymco light control bypass

For the second time the light controller of my Kymco S8 is broken.
You expect that Kymco improves bad designed parts, but unfortunately the replacement part is broken now again. The light controller will cost here in The Netherlands around €65, a lot of money for something you not really need.
The light controller will dim you light’s when the engine is running at idle speed. It’s not exactly clear why this is done but they say that it is to comply with the Euro 2 norm. Less pollution when the engine is running at idle speed.
When the controller breaks down you don’t have light anymore, no dim light and no high beam. When the blue high beam light on your dashboard is working you can almost be sure that the controller is broken.
To bypass the light controller and not alter your cable wiring you can insert some 8mm (outside measured) “fork crimp socket” in the plug that was going to the controller.
Be sure to bridge the blue wire with the blue wire and the white one with the white one.
Fork should insert easy, but you should feel that it’s making perfect contact.
The other 3 wires are for the power supply for the controller and the 3e single wire is coming from your cdi to tell the controller the rpm.
You don’t need them anymore.
To get it all mechanical stable and to prevent short circuit to some metal parts, finish it with some tape or heat shrinking tube.

 

Fork bridge connector
Fork bridge connector
Fork bridge ready
Some shrink tube for protection
The bad light controller
PlayPause
previous arrow
next arrow
 
Fork bridge connector
Fork bridge connector
Fork bridge ready
Some shrink tube for protection
The bad light controller
previous arrow
next arrow

 

Restore IP cam password

I was forgotten the password and ip address for my Chinese Ip Camera. Tried everything, but it was impossible to enter the camera again.
Most cams and other ip device’s have a reset button to “reset to factory default” but this cam not.
With the help of Wireshark the ip adres was found looking at the broadcast the cam did.

Looking at this youtube clip is was clear it can be done with a tool called ResetConfig_V2.

Easier said then done. Looking for this tool trough all Chinese webpages was not that easy because I can’t read any word Chinese and google translate also not.
After some search finally I found the tool.
It worked great for me, was not that difficult to reset the ip camera after I changed the language to English in the config.ini file.

Have fun.

2452 Downloads

Tcp/ip gateway #2

 

UnderConstruction
For my Joshua domotica I needed a better tcp/ip gateway. The old gateway was only used as gateway, but this #2 revision will also be used as webserver to control the devices on the Joshua bus from a webpage so that it can be used from different mobile devices.

This new tcp/ip gateway will run on a Stm32F427 arm processor in combination with the Texas instruments ethernet phy DP83848. These combination is already tested and working well in this post.
For communication with the Joshua bus we have an Rs-485 driver, for storing images for the webpages  there’s a Sd card connected to the Stm32 with 4bit width sdio interface. There’s also an i2c eeprom on the pcb to store some specific Joshua network parameters.

To check the working of the gateway there’s a 320×240 color tft screen connected trough spi bus. This display uses the ILI9341 controller for the display and the XPT2046 for the touchscreen. The last one is fully compatible with the well known ADS7843.

For my previous arm projects i had used the Coocox ide, but after the update to the 2.xx version is become very crapy. Now I will use the Em::Bitz ide, known before as Em::Blocks.

 

Schematic sheet1
Schematic sheet 2
Finished pcb top
Finished pcb back
Pcb with display mounted
PlayPause
previous arrow
next arrow
 
Schematic sheet1
Schematic sheet 2
Finished pcb top
Finished pcb back
Pcb with display mounted
previous arrow
next arrow

 

If you want to make your own, or use parts of the design, feel free to download the design in Eagle.

2186 Downloads

Stm32F4 with ethernet phy

For my Joshua domotica bus i was looking for an new tcp/ip gateway and webserver to control everything from my smartphone.
The old gateway based on a Atmel mega32 was not powerfull enough to make nice looking webpages.

Searching the web i found a post from Jesper with a nice sample written with Coocox.
I was so disappointed about the performance , running on a 168mhz ARM the demo page loading took about 4 seconds including the images, my good old 8bit avr was even faster then that.
Also dynamic IP was not working, only dhcp, not that handy for my purpose.

To trying to get the problems solved i have updated most of the drivers in the project from version 1.0.0 to 1.1.0. After that everything was working fine.
The demo page loads now in a blink of an eye, even with IE and on an Ipad.

See for your self.
[wpdm_file id=3 ]

 

Ethernet module
Stm32 connection
PlayPause
previous arrow
next arrow
 
Ethernet module
Stm32 connection
previous arrow
next arrow