WEMOS D1 - 3 Relay Trigger Board
by JeffM15 in Circuits > Arduino
8566 Views, 8 Favorites, 0 Comments
WEMOS D1 - 3 Relay Trigger Board
"Necessity is the mother of invention"
This proverb means, roughly, the primary driving force for most new inventions is a need.
The need was to easily control 3 relays very cheaply.
Out of this need came the "Wemos Relay Trigger Board".
What Was Needed Was Not Available.
The need was looking for an easy way to control 3 relays in a very small compact space. I wanted to use the Wemos D1 because I have been using it for other projects and already knew how it worked. The size of the Wemos fit the solution perfectly. One of the main issues with using the Wemos D1 Relay Shield is that it is controlled by the D1 Pin. Since there is only 1 D1 pin on the Wemos MCU if you want more than 1 Relay Shield you have to modify the other relays to make them all work together. There were plenty of examples on how to change the I2C bus to a different pin so you can still use a Data Logger or LCD with the Relay Shield. But there was nothing about controlling more than 1 Relay Shield with a single Wemos MCU without butchering and re-soldering jumper wires onto the Relay Shields.
So, I created this happy little board and called it: "Wemos Relay Trigger Board".
It sandwiches between each Wemos Relay Shield and the main board and utilizes longer (15mm) pins. This board will let you connect up to 9 Relay Shields to 1 Wemos MCU. The next steps will show you how the board is used to create a simple 3 relay example.
Sourcing the Parts.
Purchased the following online:
https://www.ebay.com/itm/382320438229 - Wemos Mini Pro - $6.44
https://www.ebay.com/itm/183492065390 - Wemos Mini Relay v1.0 - $0.99 * 3
https://www.ebay.com/itm/173636060763 - Wemos Triple Base - $1.73
Designing the Trigger Board
Downloaded Eagle Cad from Autodesk:
https://www.autodesk.com/products/eagle/free-downl...
Designed a simple 2 layer board.
As you can see in the image it is super basic.
A. Create an outline of the board 26MM wide x 22MM long.
B. Add 8 pin headers to outside edges for through connection to Wemos Base.
C. Add 3 and 5 pin headers inside the Wemos Base headers for connection to:
......D2, D3, D4 and D0, D5, D6, D7, D8
D. Add 5 pin header down the middle connected back to D1 for soldering Trigger Wires.
E. Add some lettering and instructions to the Silk Screen layer.
Uploaded the Gerber files to JLC PCB's: https://www.jlcpcb.com
Gerber example is here: http://www.myrelayman.com/download/WEMOS-Trigger-v...
Boards were here in a week.
Solder the Trigger Boards and Assemble the Relay Shields
A. Start off the assembly by soldering the long side of the pin headers through the
"Wemos Relay Trigger Board".
B. Solder the "TRIGGER" jumper wire from the center block (D1) to the desired new pin
(D0 in this example).
C. Cut the D1 pin from long side of the pins
D. Attach the Relay Shield and Solder it to the short side of the pins.
(This relay is now controlled by D0 instead of D1 in this example)
E. Repeat for as many Relay Shields as needed.
Solder the Triple Base Board
This assembly is just simple soldering the headers to the Triple Base Board.
Solder the WEMOS MCU
This assembly is just simple soldering. We want to use the Long Double headers.
Triple Base Board Connections
A. Connect the Wemos MCU into the CENTER header socket.
B. Connect Relay Shield (D0 in this example) into the RIGHT header socket.
C. Connect Relay Shield (D5 in this example) into the LEFT header socket.
D. Connect Relay Shield (D0 in this example) into the top of the Wemos MCU header socket.
Program the Wemos MCU
Upload the following code using Arduino IDE. https://www.arduino.cc/en/Main/Software
Use the serial monitor to control the relays.
Enter "1" turns on Relay Shield D1 / Enter "1" again turns off Relay Shield D1
Enter "2" turns on Relay Shield D0 / Enter "1" again turns off Relay Shield D0
Enter "3" turns on Relay Shield D5 / Enter "1" again turns off Relay Shield D5
Enter "A" turns ALL Relay Shields ON / Enter "a" again turns ALL Relay Shields OFF
/** WEMOS-MULTI-RELAYS - v1.000 - 2018-12-06<br>
* (C) 2018 by Jeff Manross - (jeffmanross@gmail.com) * Released under the GPL * This program is a collaberation from searching the internet. * The examples from many sites and many people made this possible. * I combined the talents of many into one working program. * Thank you EVERYONE! *
** This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details visit gnu.org */ String readString; /* String captured from serial port */ int relayPin1 = D1; /* GPIO-5 */ int relayPin2 = D0; /* GPIO-16 */ int relayPin3 = D5; /* GPIO-14 */ int relayPin1Status = 0; int relayPin2Status = 0; int relayPin3Status = 0;
void setup() { Serial.begin(19200); Serial.println("Welcome to Multi Relay Wemos Example"); Serial.println(); pinMode(relayPin1, OUTPUT); digitalWrite(relayPin1, relayPin1Status); pinMode(relayPin2, OUTPUT); digitalWrite(relayPin2, relayPin2Status); pinMode(relayPin3, OUTPUT); digitalWrite(relayPin3, relayPin3Status); }
void loop() { while (Serial.available()) { char c = Serial.read(); /* gets one byte from serial buffer */ readString += c; /* makes the string readString */ delay(2); /* slow looping to allow buffer to fill with next character */ }
if (readString.length() >0) { Serial.println(readString); /* so you can see the captured string */
if (readString == "1") { if (relayPin1Status == 0) { relayPin1Status = 1; } else { relayPin1Status = 0; } digitalWrite(relayPin1, relayPin1Status); Serial.print("Relay1=");Serial.println(relayPin1Status); Serial.print("Relay2=");Serial.println(relayPin2Status); Serial.print("Relay3=");Serial.println(relayPin3Status); }
if (readString == "2") { if (relayPin2Status == 0) { relayPin2Status = 1; } else { relayPin2Status = 0; } digitalWrite(relayPin2, relayPin2Status); Serial.print("Relay1=");Serial.println(relayPin1Status); Serial.print("Relay2=");Serial.println(relayPin2Status); Serial.print("Relay3=");Serial.println(relayPin3Status); }
if (readString == "3") { if (relayPin3Status == 0) { relayPin3Status = 1; } else { relayPin3Status = 0; } digitalWrite(relayPin3, relayPin3Status); Serial.print("Relay1=");Serial.println(relayPin1Status); Serial.print("Relay2=");Serial.println(relayPin2Status); Serial.print("Relay3=");Serial.println(relayPin3Status); }
if (readString == "A") { relayPin1Status = 1;relayPin2Status = 1;relayPin3Status = 1; digitalWrite(relayPin1, relayPin1Status); digitalWrite(relayPin2, relayPin2Status); digitalWrite(relayPin3, relayPin3Status); Serial.print("Relay1=");Serial.println(relayPin1Status); Serial.print("Relay2=");Serial.println(relayPin2Status); Serial.print("Relay3=");Serial.println(relayPin3Status); }
if (readString == "a") { relayPin1Status = 0;relayPin2Status = 0;relayPin3Status = 0; digitalWrite(relayPin1, relayPin1Status); digitalWrite(relayPin2, relayPin2Status); digitalWrite(relayPin3, relayPin3Status); Serial.print("Relay1=");Serial.println(relayPin1Status); Serial.print("Relay2=");Serial.println(relayPin2Status); Serial.print("Relay3=");Serial.println(relayPin3Status); } readString=""; } }
Downloads
Conclusion
This was a quick example of how to control the 3 Wemos Relay Shields using a single Wemos MCU.
The main focus point for this is the Circuit Board contest. It is sometimes the simple ideas that makes things easier. This Instructable did not go into how to control the Relay Shields via web or app it was mainly written to showcase the simplicity of creating a circuit board for a practical application and idea then having it produced and actually using it.
If you would like more information on controlling the Relay Shields or Web or App, or would like some boards.
https://www.ebay.com/itm/183572143635
Please do not hesitate to contact me.
I hope you liked this Instructable and will vote for me.
Jeff