Raspberry pi hat board template for Altium designer (16) if you like to design you own add on board.
Template made according the Raspberry specs.
For Raspberry with 40p connector.
Found this interesting Wifi power switch on Ebay for only $6,11. It’s not clear to me if this is the original design or a copy of it. Detailed info can be found on this Wiki page.
To connect it to my Mqtt broker and domotica I wanted to make my own firmware.
Easy said, easy done. There are plenty example on the net how to do this. Because there’s an esp8266 inside there are also numerous Arduino software example available.
First step was soldering a header to the empty programming socket and connect my Usb to serial adapter to it. Take a note that you must have a 3.3V usb to serial adapter, they can be found for under a dollar on ebay. Don’t know how they can make it for that amount and even send it to the other side of the world.
Connected the usb adpater to my pc and voila, I’m in. Keep also in mind not connect it to the mains when connected to your pc. Both powersupply’s are not happy with each other.
Simple led blink program was working, connecting to wifi was also working, but unfortunately the red led and ota (over the air) update was not working.
The ota was complaining that the authentication was not correct and I was sure it was correct.
After lot of Googleing and some tries it was clear that the memory settings in the Arduino ide where not correct, but what must it be then?
This setup was working for me, cant say it will work for all Sonoff versions, but you can try setting the ide like this.
Gerneric Esp8266 Module: Flash Mode: DIO, Flash Frequency: 40MHz, CPU Frequency: 80MHz
Flash Size: 1M (64K SPIFFS), Debug Port: Disabled, Debug Level: None, Reset Method: ck
Now the red led.
In some Arduino code that I found they say that the red led will lit when the relay will be activated. But both didn’t work. Red led and relay didn’t worked. Relay was simply fixed, it needed the 5V from the Sonoff build in power supply, connected to the mains and the relay worked, but still no red led.
Looking at the schematic and the pcb some critical components for the led where not placed. Q3, Q4, R2 and R23 are not placed.
Q3 and R2/22 are used for the Sonoff version that have also the 433Mhz receiver. Q4 and R23 are used to lit the red led if the relay is activated.
Both are not placed, so that’s why the led will not lit. If you want to let the red led work together with the relay, just place Q4 (2N7002) and R23 (1K) and it works.
However I wanted the red led under software control and decided to use one of the free gpio ports from the Esp8266.
Soldered a wire from gpio4 (pin16) on the Esp8266 to the drain of Q3. See the pictures below for details.
That’s it everything working as wanted.
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.
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.
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.
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.
Altium 16 Design files V2