4×1 WiFi Wireless Antenna Switch
I started playing with electronics back when I was 10 years old in Argentina, where I grew up. Then I got my ham radio operator license when I was 16 years old and I was very active in the ham club and on the air. It was then when I built my first vacuum tube transmitter and refurbished and old receiver (also vacuum tubes) that somebody from the club was throwing away. My interest for science and electronics grew and I ended studying physics but always tinkered with electronics, whenever I could.
I’ve moved a lot around the world for work (oil and gas) so my dedication to ham radio pretty much faded away. But it came back! Just recently, I got my ham radio operator license back and started to get active on 2mtr and on digital.
Due to lack of space outdoors, I had to settle for installing my center fed dipole on the attic (I have a long attic), but I quickly realized I needed more than 1 antenna. 80 mtr, 40 mtr, 20mtr….
I bought a 4 position manual antenna switch and very quickly realized (again) that I did not want to go up and down the stairs with kids and wife sleeping to switch the antenna. And more importantly, I did not want to run another set of cables to drive a wired remote controlled one. Wireless was the solution. I checked the prices, and they were outside of my budget for a switch. So, what’s next? I came up with an idea. Get a RaspberryPi and add a relay board and then I have my WIFI wireless relay control. Add some UHF female SO-239s and we have a WIFI Antenna Switch. Well, two problems with this, first it is really clunky connecting all those coaxial cables to the relays and there would be a lot of signal loss (and good luck tuning that), its bulky and pretty difficult to assemble in one unit and that would not work properly; second, it was more expensive than I expected, even DIY it was around 100 dollars. I built it anyway and, well it worked for a while. But I was not happy so I looked around and came up with a better idea (or so I thought!). I found the ESP8266, a WIFI module which is small, cheap, I mean 3-dollars-cheap and fully programmable. Combining this module with a standard relay switch design, I thought I had a solution for way under 100.00 dollars integrated all in one single PCB board, suitable for mounting on a proper box. Lets look at the design.
The brain of the switch
The ESP8266 is a very small WIFI enabled microcontroller. It can be programmed in C by flashing it with the manufacturer’s (Espressif) software development kit (SDK). But it can also be programmed in LUA using the NodeMCU SDK (open source, just Google it or go to GitHub). LUA is a scripting language used widely in the gaming industry and I picked it to program the ESP8266 because of being compact, very high level and allowed rapid prototyping.
The ESP8266 acts as an access point and/or a WIFI station, so once it is configured it acquires an IP address and then you can communicate with it via a web browser or a TCP connection (phone, tablet, computer, etc).
The ESP8266-01 used in this project, has 2 GPIOs, GPIO0 and GPIO2, meaning that we can program the module so it can read and write stuff on these GPIOs. The ‘stuff’ is simply digital signals, a 0 or a 1, or in volts, a few millivolts or 3.3 volts. This is perfect to drive LEDs or relays and make them open or close according to some logic and control either running on the module or instructed via a web or TCP server.
The module features a serial interface so you can communicate with it to program it.
There is plenty of material out there to get anyone going with this little wonder. The key things to know is that you will need a USB to serial module to initially talk to the ESP8266, be familiar with serial communication and able to do some script programming. For USB to serial, any FTDI232 based module will pretty much work, but be careful as they are counterfeit FTDI232 that can render useless, make sure whatever you get is genuine. Then you need to choose a serial terminal to send commands to the serial module that will send commands to the ESP8266. Something like CoolTerm or SSCOM32 would do the job. I use CoolTerm mostly on the Mac. Also, when you start copying LUA code into the module, CoolTerm does a great job.
With this brief introduction to the ESP8266, you can have a lot of fun prototyping all kinds of interesting WIFI projects.
Driving the relays
I looked a several relay types, and for this first version of the switch, I estimated going with something on the lower power side would be a wise choice, something that could handle 100-300 Watts. There is plenty of time to improve the design and make it robust for high power transmitters. I started with a 4 position switch, so I needed to drive 4 low power, low current relays. The ESP8266 has 2 GPIOs (general purpose IO), GPIO0 and GPIO2, but just 2 GPIOs, were not going to be able to drive 4 relays, I needed some logic. I decided to go with the 74HC238, a 3-to-8 line decoder. I just needed a 2-to-4 line decoder but since I had a bunch of these, lets use them, and connect the unused input line to ground. The ESP8266 GPIOs were going to feed the 74HC238 and provide the logic to switch the outputs, then these outputs will drive a Darlington power driver like the ULN2803. To make it safer, I decided to split the 8 ULN2803 outputs into 2 groups of 4, one group feeding the relays, the other the LEDs.
For more detail: 4×1 WiFi Wireless Antenna Switch
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
Cheapest PCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 24 hours Quick Turn, DHL Delivery in 3 Days