Close
0%
0%

ESP8266 DIN 8-Channel Wifi Relay Controller

8 channels of 10A 250V relays controlled over Wifi with an ESP8266 module at the core. Built in RS232-TTL level shifter for external devices

Similar projects worth following
I wanted to build a fairly simple project that combined a number of elements to further my skills. Mainly it was about creating a project to further develop my code writing skills for the ESP8266 in C code.

Essentially, it is an 8-channel relay controller with a wifi interface and an auxiliary RS-232 port for connection to industrial equipment over serial. The PCBs are designed as a dual layer stack with a 24-way FPC cable connecting the main control board to the relay board. This way I can swap out the ESP8266 based wifi board for something else (Ethernet/Zigbee/nRF) and retain the same baseboard. It is all designed to fit into a plastic DIN rail enclosure sourced from Aliexpress. Status LEDs for the relay channels are channeled through light pipes, through the top board, and out the front panel of the enclosure.

Microchip MCP23S08 GPIO expander over SPI for 8 GPIOs. TI TRS3221 for TTL->RS232

General Features & IOs:

  • 8x Relay Channels - 10A 250V AC with NO/NC/COMMON connections
  • PWR input (7-28V DC) with reverse power diode protection.
  • Internal DC-DC module with 5V output
  • RS232 level serial connection TX/RX/GND
  • Reset Button
  • Bootload/Program Button (GPIO0)
  • User Input Button
  • Status LEDs: Power, User Controlled (wifi activity), Serial TX, Serial RX

  • 1 × ESP8266 ESP-12 ESP-12 module
  • 1 × MCP23S08 Microprocessors, Microcontrollers, DSPs / IO Controllers
  • 1 × trs3221 Interface and IO ICs / RS-232, RS-422, RS-423 and RS-485

  • Internet Success

    David Ogilvy07/06/2015 at 08:54 0 comments

    Apart from the webserver crashing overnight, it seems like the live control test went well :) Thanks to those who tried it out! Ustream on my tablet stops streaming after 3 hrs so I have to keep restarting it (if you see the stream dead, try again later).

  • LIVE

    David Ogilvy07/05/2015 at 13:24 0 comments

    ESP8266 Server: Link Removed

    UStream: http://www.ustream.tv/channel/metalphreak (stream lags by about 15 seconds...)

    Will stay up for the next 24hrs or until something breaks.

    EDIT: Live site is now offline :) Thanks for playing.


  • Webserver Works

    David Ogilvy07/05/2015 at 12:33 0 comments

    Got the web interface up and running. No live status of the relays shown on the page yet, but remote turning on/off works perfectly :)

  • Front Panel Overlay and HTTP Server

    David Ogilvy07/05/2015 at 06:12 0 comments

    I've been looking at options to put some kind of front panel overlay on the DIN rail enclosure. The best option I've seen so far that doesn't cost huge amounts of money is die-cut vinyl stickers. Looking at a service like stickeryou.com or stickerapp.com

    Front panel dimensions and LED pipe/button locations have already been marked out in DXF format and converted to SVG for editing. Just need to dust off my photoshop skills and get something done...

    In the meantime, I've been playing around with sprite-tm's esphttpd web-server code which works quite well. The actual code to control the relays on this via a web-interface are going to be quite simple. The challenge will be writing the html/css/js/ajax stuff to make it pretty.


  • Some videos of an assembled board...

    David Ogilvy06/26/2015 at 10:57 0 comments

    Just sending simple 2 byte packets over a TCP socket for testing.

    And just to see how many updates it can do over Wifi for kicks... Good thing these Omron relays are rated for millions of operations :)

  • Limited GPIO? Hardly.

    David Ogilvy06/26/2015 at 10:49 0 comments

    The first step when beginning this project was dealing with the limited IO pins on the ESP8266 modules. The ESP-07 and ESP-12 modules break out all of the useful pins. A number of pins needs to be pulled high or low during power on so it boots off the SPI flash memory (or bootloader).

    GPIO0 - 10k pullup for boot mode - Bootload/Program button pulls this to ground on powerup/reset to enable update over serial. Doubles as a i2c clock pin

    GPIO2 - 10k pullup for boot mode - also doubles as i2c data pin

    If you gotta pull the pins up for boot select, might as well put anything needing a pullup on those pins ;) i2c is broken out to a header on this for future use

    GPIO4 - 10k pullup - user switch

    GPIO5 - user LED output

    GPIO12/13/14/15 - hardware SPI pins for Data In/Out, Clock, and Chip Select

    Note: GPIO15 has to be pulled low for both SPI flash/Serial boot modes. A 10k pulldown is fine for this as it is only the SPI clock line.

    GPIO16 - unconnected by default - footprint for resistor connection to reset for sleep mode reset (not needed for this project).

    Microchips MCP23S08 provides 8 GPIO pins over the SPI bus. Up to 4 of these can be connected to the same bus with a common chip select line. Each chip can be set to one of 4 addresses. So a total of 32 GPIOs is possible. Even better, the bigger brother MCP23S17 provides 16 GPIOs and can have up to 8 devices on one SPI bus (128 GPIOs!).

    Some driver code for the MCP23Sxx chips is available on my Github - including support for multiple devices per SPI bus: https://github.com/MetalPhreak

    So in summary, you can have 2 on-module GPIOs, (software) i2c and SPI with no issues. GPIO expanders provide plenty of addition IOs as required. The 2 on-module GPIOs can be used with the Microchip's interupt-on-change output pin to provide equivalent functionality to on-module GPIOs. Using the hardware SPI module for this is much better than the i2c versions, as you can buffer the data in the SPI module (which sends it at 10MHz), while you continue to do work with the main cpu (@80MHz). Software i2c ties up the whole device while it sends at sub 1MHz speeds.

View all 6 project logs

Enjoy this project?

Share

Discussions

ketinenirk wrote 05/19/2016 at 10:31 point

Where can I find the instructions, code to make this

  Are you sure? yes | no

nospam32768 wrote 07/07/2015 at 20:26 point

Have you thought of using two 250VAC 20A Relays and adding a temperature sensor and turning this into a wifi enabled wall thermostat?  I'd buy these all day long.

  Are you sure? yes | no

David Ogilvy wrote 07/10/2015 at 11:07 point

Unfortunately, we don't typically have those kinds of thermostats in Australia. All I have is a digital control panel for the AC unit! 

  Are you sure? yes | no

umursengul wrote 07/06/2015 at 11:38 point

Okay, I went to livestream, closed all relays, and then opened them... Now, I don't know why, but wanna do it again, and again, and again... This is wonderful :D

  Are you sure? yes | no

David Ogilvy wrote 07/06/2015 at 11:48 point

lmao - sitting here in my living room watching TV, and the relays are clicking away every few minutes...

  Are you sure? yes | no

Steve Shaffer wrote 07/06/2015 at 14:54 point

I also found myself addicted for a few minutes.  As soon as someone else showed up trying to turn them all on, I was trying to prevent that by slowly turning them all off.  I couldn't tell if it was me or others competing against me, but it seemed if I clicked too fast the server wouldn't get the signal - like clicking a link but then clicking another before the first could fully load.

  Are you sure? yes | no

David Ogilvy wrote 07/06/2015 at 14:59 point

It loads up a "relay.cgi" page to post the data, then gets redirected back to the relay.tpl page. It get's kinda slow because it's on an ADSL2+ connection with only 800kbps of upload bandwidth (which I use sometimes for internet-y things) :)

  Are you sure? yes | no

matt venn wrote 07/05/2015 at 14:17 point

can you link your pcbs? I'd like to learn from them. Nice cutouts for HV protection and I've not used that SMT connector before. Also would like to know what mains->low voltage converter you're using. I typically use bigger (more expensive) units that I mount elsewhere to keep mains voltage off my pcb.

  Are you sure? yes | no

David Ogilvy wrote 07/05/2015 at 14:33 point

I'll add some PCB gerbers tomorrow night (past midnight here now...). 

In the photos, it's actually just an FPC cable soldered directly to the PCB. I've received my FPC sockets now and have made a few more boards. 

Converter onboard is just a DC-DC module. Only cabling I had with me was some mains IEC stuff (so blue and brown wires aren't hot/neutral!). It's being powered from an external 27V DC power supply. 

  Are you sure? yes | no

Steve Shaffer wrote 07/05/2015 at 13:38 point

nice work, I might have to roll my own version, it's a great idea.

  Are you sure? yes | no

Craig Hissett wrote 07/05/2015 at 10:30 point

This is tremendous!

I have an 8 channel relay board i was using in an arduino/MIDI controlled switcher but I think i migjt have to get an ESP8266 and use that - this is brilliant!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates