Tag Archives: MOSFET Shield

Home Automation – Immersion Heater Controller

Although automated sockets and temperature sensing is useful, I needed to solve a more complex problem with my home automation system. I have Economy 7 heating, which heats both my hot water and central heating system overnight on cheap electricity, so I can use it during the day. The controller for my hot water was old and mechanical (a ticking clock) which was in my daughters bedroom next to the hot water tank and the ticking kept her awake at night.

It has a boost function, which allows you to turn on a second heating element during the day for an hour, if you run out of hot water. Again, this button was in my daughters bedroom, and rather high up, making it difficult to reach during the night, if we needed extra hot water, without waking her.

Economy 7 Heating Clock

Economy 7 Heating Clock

You can buy digital controllers which would solve the ticking problem, but they would still have the boost button problem. A more automated solution would be better.

I wanted to use Tasmota and a Wemos D1 mini as I had found them to be very reliable and easy to configure and manage in other projects. The two elements (Main and Boost) are mains voltage and 3kW each (13A @ 230v) so I cant control them with a microcontroller pin ! 😊

I used two 25A mains rated relays with 12v coils. I can fit these, plus a couple of power supplies on a DIN rail in an IP rated enclosure.

However to switch the relays I needed to control them with a MOSFET. There wasn’t an existing MOSFET shield for the Wemos D1 mini, so I decided to build my own shield with a custom PCB.

The design is quite simple. The MOSFET needed to be logic level, turned on with 3.3v. The relays only draw about half an amp, but for future use, the shield supports more current.

There is a dedicated blog post about the process I went through to design and manufacture the MOSFET shield, and you can buy them on Tindie 😊

I sell on Tindie

4 Channel MOSFET Shields for Wemos D1 Mini

4 Channel MOSFET Shields for Wemos D1 Mini

The custom immersion heater controller needs two relays to control the two heating elements. The controller must prevent the possibility of ever having both immersion heaters on at the same time. This would draw too much current (26A!) and overload the mains wiring to the controller. The previous manual controller had the same interlock to prevent both elements being powered. If you select the boost function, it turns off the main heater. It’s not safe enough to just have one heater on one relay and the second heater on the second relay. Although I could configure the code to not turn on both relays at the same time, there was a risk that if the microcontroller crashed or hung, both relays could come on at the same time.

So, the solution is to use the first relay to provide power and the second relay to switch the power between the main and boost elements. When both relays are off, power is off. With the power relay on and the second relay off, the main element is powered. With the power relay on and the second relay on, the boost element is powered. At no point can both elements be powered at the same time. Safe!

Immersion Heater Controller Diagram

Immersion Heater Controller Diagram

The circuit was built in an IP rated box and tested, then installed in the hot water cylinder cupboard.

Immersion Heater Controller Installed

Immersion Heater Controller Installed

Node Red was configured to control it. There are two flows. The first turns the main element on between 00:30 and 06:30 to heat the tank overnight. This just needs to turn the first relay on, to apply power through the normally closed contact of the second relay to the main element.

The second flow is more complex, but essentially sends four messages; the first two messages send “On” commands to both relays, to the first relay supplies power and the second relay connects the boost element. After a delay of 60 minutes, two further messages send “Off” commands to turn both relays Off. A button is used on the Node Red Dashboard user interface to trigger the flow.

I also have two manual switches on the dashboard to control the individual relays, if required.

Immersion Heater NodeRed Flow

Immersion Heater NodeRed Flow

Immersion Heater NodeRed Dashboard

Immersion Heater NodeRed Dashboard

My Economy 7 hot water system is now fully automatic, silent, hidden, and fully controllable from any browser enabled device in the house!

Combine this with the hot water tank temperature monitoring I have already installed and I have complete visibility over how much hot water I have left and the ability to switch on the boost all from my mobile phone browser if I ever run low !

Home Automation – Automatic Garden Watering

An automatic garden watering system was my original goal for my home automation system, especially as this year we have had very sunny and dry conditions. I was out watering my plants nearly every night.

I have several different things I needed to water; raised beds with vegetables, a wall of strawberries, some fruit trees, and we tried our hand at potatoes this year as well.

Automatic Watering System - Beds

Automatic Watering System – Beds

Four zones fitted nicely with my four channel MOSFET board I had designed. There is a dedicated blog post about the process I went through to design and manufacture the MOSFET shields and you can buy them on Tindie for you own projects. 😊

I sell on Tindie

I designed a water manifold with four 12v solenoids which would give me four individually controlled watering zones and a pass-through connector so I could daisy chain additional controllers later as required.

I needed to split the watering zones up because my water pressure could not drive all the drippers and sprinklers at the some time, if they were all connected in series. You need a reasonable amount of pressure to get the mini sprinklers to work properly and you can’t drive more than 15-20 at once as the pressure drops too low.

I used Hoselock Easy Drip system to supply water to the plants and beds I needed to water. The system is simple to configure. You run a standard hose around the bed, and clip on sprinkler heads which pierce the hose and provide irrigation. There is also a micro drip system which uses smaller 4mm hose for pots. I used the Easy Drip for all the beds and Micro Drip for the strawberries.

Hozelock Easy Drip System

Hozelock Easy Drip System

Hozelock Micro Dripper

Hozelock Micro Dripper

Design

I built the manifold out of ¾” threaded pipe connectors and 12v solenoids. Next time, I might try making the manifold from soldered fittings, but the threaded fittings gave me the flexibility to change the design as I built it. I have also found some ready-made manifolds since building mine, so I might try those too next time.

Automatic Watering System Manifold

Automatic Watering System Manifold

I built a wooden box out of some old decking boards I had, so I could mount the manifold and controller on the fence.

Automatic Watering System Box

Automatic Watering System Box

The device would be in my garden, so I used a Wemos D1 Mini microcontroller with an external antenna to give me a bit of extra WiFi range. It will be powered by a 12v battery, so I mounted the Wemos and MOSFET shield in an IP60 weatherproof case, with a DC-DC step down convertor to give me 5v to power the Wemos and 12v from the battery for the solenoids.

The plan is to charge the battery from a small solar panel, so its completely wireless in the garden. The current draw is tiny. The solenoids only draw about 600mA each and they are only on for short amounts of time. Even without a solar panel to charge the battery, it would last maybe 2 weeks between charges.

Automatic Watering System Final Installation

Automatic Watering System Final Installation

The main water feed from the garden tap comes in on the right hand side via a manual valve so I can quickly turn off the water if I need to, without having to walk all the way back down the garden. I leave this on and connected all the time, so the watering system can water at any time of the day or night.

There are four watering zones, one on each solenoid. The four zones are;

  1. Potatoes
  2. Vegetables Beds
  3. Fruit trees
  4. Strawberry Wall

The last connection on the left is a pass through from the main feed, also via a manual valve, where I can either daisy chain another four zone controller, or attach a hose and hand held sprinkler for manual watering.

Testing

To test the controllers and manifold worked correctly before I installed it permanently, I wrote a simple script that turned on each channel sequentially, with an MQTT message, every 2 seconds.

I positioned the controller with its external antenna just on the edge of my house WiFi range, so it was as far up the garden as it could be, but still in range.

Automatic Watering System - Potatoes

Automatic Watering System – Potatoes

The automation is driven by NodeRed. I water each zone for 20 mins every morning at 6am. I can add more logic later if I need. There are all kinds of modules and sensors I could add to measure soil moisture or rain sensors and decide not to water if its been raining or the ground is already moist, but there’s no risk of over-watering anything at the moment, so it just waters every day for 20 mins.

In theory if the summer gets really hot, I could measure soil moisture and decide to add an extra watering cycle midday if the ground is really drying out in the sun. But that will be a phase two.

I also have a manual override using the NodeRed dashboard buttons, so I can manually turn zones on and off from my mobile phone.

Automatic Watering System NodeRed Flows

Automatic Watering System NodeRed Flows


Automatic Watering System NodeRed UI

Automatic Watering System NodeRed UI

The results have been amazing. The strawberries have really benefited for daily watering. We got a fantastic crop of potatoes too. Now the automatic watering system is in place we will increase the volume of plants next summer, now I’m confident they will all survive, and I don’t need to spend hours watering them every day! 😊

Lots of Strawberries

Lots of Strawberries

Design, Fabrication and Testing of a MOSFET Shield for a Wemos D1 mini ESP8266 Microcontroller

Design

I needed a MOSFET Shield for a Wemos D1 mini to drive solenoids and relays. I could not find anything suitable online, so I decided to design and build my own. The board size of a Wemos D1 mini is quite small (1″ x 1.3″) and part of that is the PCB antenna, so a shield should avoid covering the area over the antenna with copper or lots of components.

Wemos D1 Mini ESP8266 Development Board

Wemos D1 Mini ESP8266 Development Board

I wanted the shield to be the same size as the Wemos D1 mini. I need to be able to switch about 12v at about 2A. Most use cases I had were small relays and solenoids.

I found a very small dual channel MOSFET in a 2mm x 2mm package (FDMA1024NZ – Dual N-Channel MOSFET 20V / 5.0A). This MOSFET is so small I could fit two on the shield, giving a total of four channels.

Wemos D1 Mini MOSFET Shield 4ch v1.3 Schematic

Wemos D1 Mini MOSFET Shield 4ch v1.3 Schematic

Wemos D1 Mini MOSFET Shield 4ch v1.1 Board

Wemos D1 Mini MOSFET Shield 4ch v1.1 Board

Fabrication

I created the board design and ordered the PCBs and a solder stencil for the first prototype. The 2mm x 2mm package is very difficult, if not impossible, to hand solder, so the stencil would allow me to stencil the solder paste and hand place the components, before reflowing it in an oven.

MOSFET Shield for Wemos D1 mini before solder stencilling

Before solder stencilling

MOSFET Shield for Wemos D1 mini during solder stencilling

During solder stencilling

MOSFET Shield for Wemos D1 mini after solder stencilling

After solder stencilling

MOSFET Shield for Wemos D1 mini close up of solder stencilling and component placement

Close up of solder stencilling and component placement

MOSFET Shield for Wemos D1 mini v1.1

First prototype completed

The first version worked perfectly, but the 2mm x 2mm MOSFET was a little obscure and difficult to hand solder. In addition, JLC PCB had launched a pick and place PCB fabrication service which was very economical. I thought I’d try it for my MOSFET board, but the MOSFETs I was using were not supported. So I replaced the two obscure dual MOSFETs with four discrete MOSFETs which JLC support as a basic components.

Wemos D1 Mini MOSFET Shield 4ch v1.3 Board

Wemos D1 Mini MOSFET Shield 4ch v1.3 Board

The JLC PCB fabrication service built a batch which again all worked perfectly.

MOSFET Shields for Wemos D1 Mini v1.2

MOSFET Shields for Wemos D1 Mini v1.2

Testing

I needed to test the board design to ensure it could handle the current rating. The MOSFETs are rated at a maximum of 5A each. So, each individual channel should switch 5A. In addition all four channels can be connected together which would switch about 20A in total. I wanted to make sure the tiny PCB would handle this load. I designed the power traces on the PCB to be as wide as the physical dimensions of the board would allow.

I bought a 180W battery tester from BangGood to use as a variable load which could test up to 20A and 180W. This device has lots of useful features. You can configure it as a constant current load in 10mA increments. It measures voltage, current, power and even temperature using a plug in thermocouple, and displays all the readings in real time on a colour LCD. Its a very functional device for a very economical price.

To source 20A, I decided to use a lead acid battery. I don’t have a bench power supply that can easily provide 20A. I used thick 12AWG wire to connect the battery to the variable load and the shield under test.

MOSFET Shield for Wemos D1 mini Power Testing Setup

MOSFET Shield for Wemos D1 mini Power Testing Setup

The test setup consisted of;

  • A 12v lead acid battery
  • The variable load
  • The shield under test – with the MOSFET outputs shorted together

Power Testing Setup

Power Testing Setup

I planned to test each individual channel at 1A, 2A, 3A, 4A & 5A, while monitoring the temperature of the MOSFET, PCB traces and connectors. In addition, I want to connect all four channels together and test up to 20A.

The first few tests went well. Each channel can handle up to 5A. The MOSFETs get a little warm at 5A. If the board is used at maximum capacity for long periods, it would benefit from either forced air cooling or a small heat sink on the MOSFETs.

MOSFET Shield for Wemos D1 mini Power Testing Temperature

MOSFET Shield for Wemos D1 mini Power Testing Temperature

I struggled to test all channels to a total of 20A. The battery tester I had can only handle 180W, and the only convenient 20A source I had was a 12v lead acid battery. 12v @ 20A is 240W which is more than 180W, and the tester cuts out when it hits 180W.

I managed to test up to 16A with the lead acid battery setup, which was right on the limit of the 180W limit.

MOSFET Shield for Wemos D1 mini Power Testing 16A

MOSFET Shield for Wemos D1 mini Power Testing 16A

I had a small 2S LiPo at 7.2v and managed to complete a final test of 20A using this LiPo, but at 20A is the battery discharged very quickly and the voltage would drop to 6v very quickly and the tester cuts out at 6v to protect the battery from over discharge.

MOSFET Shield for Wemos D1 mini Power Testing 18A

MOSFET Shield for Wemos D1 mini Power Testing 18A

I’m confident the boards will operate to 5A per channel, to a maximum combined current of 18A as I managed to successfully test to both these levels. At higher currents the individual MOSFETs get hot and the Dupont header does. I think the header pins are only rated to 5A, so for 20A the board would need a redesign with more power pins to distribute the load. 4A per channel is way more than most of my projects need, so I’m happy with the design. If you really need to switch 20A for short periods of time, use a heatsink and solder the wires directly to the board rather than use pin headers and a Dupont connector.

Batch production

The shields were used in three of my home automation projects:

  • Automatic Garden Watering to control four water solenoids connected to garden hoses.
  • Immersion Heater Controller to control 2 high current relays to switch two 3kW hot water immersion heaters.
  • Automatic plant Pot Watering to control a small peristaltic pump to water pot plants based on moisture reading from a capacitive moisture sensor. This was the project that I added the analogue in header on the shield for. This allowed me to connect the moisture sensor and the peristaltic pump to the same shield.

Once the shields had been running in projects for a couple of months, without any issues, I decided to build a small batch to sell online. If I couldn’t find something similar online, then maybe others would like to buy these to use in their robotics or home automation projects.

MOSFET Shield for Wemos D1 mini v1.3 Panel for Fabrication

MOSFET Shield for Wemos D1 mini v1.3 Panel for Fabrication

The four channel MOSFET shield can be purchased here on Tindie.

I sell on Tindie

Final Specification

  • Dimensions : 1″ x 1.3″ x 0.063″ (25.4mm x 33.0 x 1.6mm)
  • Four MOSFETs : AO3400A – 30V N-Channel
    • Maximum Drain-Source Voltage : 30v
    • Continuous Drain Current : 5A
  • GPIO pins used : D5 (GPIO14), D6 (GPIO12), D7 (GPIO13) & D8 (GPIO15)
  • ADC pin A0 available on 0.1″ header with power pins (selectable 3.3v or 5v)

Future revisions

I have already starting thinking about additional features that could be useful.

Using four digital GPIO pins to control the MOSFETs is sometimes a pain as the GPIO pins are shared with other features on the microcontroller. The D5, D6, D7 & D8 pins used on the shield are also the SPI port, so when the MOSFET shield is connected you cannot use SPI at the same time.

An improvement would be to use a I2C device to control the four MOSFETs rather than discrete GPIO pins. Multiple I2C devices can be connected in parallel to the same pins, so if I switched the shield to use I2C you could stack other shields in parallel and all of them would work.

There is a 4-bit I2C I/O expander IC (PCA9536) which could facilitate this. The board layout would be very tight to fit this additional chip on the same top layer. I could try and place it on the bottom layer, but a dual sided board is more expensive and complex to produce.

Or I could also try and add solder jumpers on the bottom layer to allow different GPIO pins to be user selectable.

I’m interested in any feedback on the board or any additional feature requests you would like to see. Leave your feedback in the comments section below.