256 Relays! © GPL3+

Control 256 relays! Seeing is believing!

  • 11,206 views
  • 8 comments
  • 49 respects

Components and supplies

Apps and online services

About this project

256 Relays!

The IO Expander now supports 256 relays per board. Due to cable lengths and capacitance issues the clock and data lines need to be separated to two separate lines each with 8 relay boards. The first 8 relay boards are with R1 and R2 and the next 8 relay boards are with ECHO and TRIG. The clock rate for each line is 68KHz and since it is a dual clock interface you get a combined 136KHz effective data output. Oh did we mention that it is also latched so all 256 relays get activated at exactly the same time!

Note: R3 and R4 gets connected to the second lines as shown by the green wires on the far right hand side.

Warning: Do NOT connect the grounds between the lines thus creating a ground loop!

But you don't have to stop at 256 relays. You can link multiple IO Expander together and control up to 65,280 relays!

See our Control Up to 65,280 Relays with Your Arduino project!

The IO Expander is more than just a relay controller. You can use it to also interface to the following sensors with no drivers required!

Sensors Supported

Maxim 1-Wire® DS18B20, DS18S20,DS1822 Temperature.
Maxim 1-Wire® Control.
Maxim 1-Wire® DS28E17 to I2C.
OneWire AM2302, DHT11, DHT22 Temperature/Humidity.
Sensirion SHT1x Temperature/Humidity.
4 Relays or Relay Expander for 256 Relays.
Flow (Hall Effect).
GPIO Control.
Float Switch (Magnetic and Optical).
Button Input.
Proximity Sensor. (New v1.14)
Ultrasonic HCSR04.
ADC TEMT6000 Light.
Sensirion I2C HTU2x, SHT2x, SHT3x Temperature/Humidity.
I2C Control.
Silicon Labs I2C Si7021 Temperature/Humidity.
Bosch I2C BMP180 Temperature/Pressure.
TAOS I2C TSL2561 Light.
Ti I2C LM75 Temperature.
Maxim I2C DS3231 RTC/Temperature.
Atmel I2C AT24C32 32Kbps Serial EEPROM.
SSD1306 0.96", SSD1309 2.42" (New v1.14) I2C 128x64 Dot Matrix OLED/PLED Display.
Microchip I2C MCP9600 Thermocouple Temperature.
HX711 Load Cell Weight Sensor. (New v1.13)
SH1106 1.3" I2C 128x64 Dot Matrix OLED/PLED Display. (New v1.13)
TAOS I2C TSL2591 Light. (New v1.14)
TAOS I2C TCS34725 RGB Light. (New v1.14)
Sensirion I2C SCD30 CO2 Temperature/Humidity. (New v1.14)
System Commands.
New sensors added with firmware updates.

Here's the 256 relays in action! Seeing is believing!

/* IO Expander
*
* 256 Relays
*
*/

#include <SoftwareSerial.h>
#include "IOExpander.h"
#include <avr/wdt.h>

//#define SERIAL_DEBUG
#define MAX_RELAYS 256

#ifdef SERIAL_DEBUG
SoftwareSerial swSerial(8,7);
#endif

char cmd[10];

void setup()
{
Serial.begin(115200);
#ifdef SERIAL_DEBUG
swSerial.begin(115200);
swSerialEcho = &swSerial;
#endif
wdt_enable(WDTO_8S);
sprintf(cmd, "eb%d", MAX_RELAYS / 16);
SerialCmdDone(cmd);
}

void loop()
{
uint8_t i;
static uint8_t s = 1;
static uint8_t d = 0;
uint8_t r[32];

for (i = 0; i < 32; i++) {
r[i] = ~s;
}

SerialWriteRelayExpander(r, 32);
delay(50);

if (d) {
if (s > 1) s >>= 1;
else d = 0;
}
else {
if (s < 0x80) s <<= 1;
else d = 1;
}

wdt_reset();
}

So get your IO Expander today and build your system!

Code

Control 256 RelaysArduino
/* IO Expander
 *  
 * 256 Relays
 *
 */

#include <SoftwareSerial.h>
#include "IOExpander.h"
#include <avr/wdt.h>

//#define SERIAL_DEBUG
#define MAX_RELAYS    256

#ifdef SERIAL_DEBUG
SoftwareSerial swSerial(8,7);
#endif

char cmd[10];

void setup()
{
  Serial.begin(115200);
#ifdef SERIAL_DEBUG
  swSerial.begin(115200);
  swSerialEcho = &swSerial;
#endif  
  wdt_enable(WDTO_8S);
  sprintf(cmd, "eb%d", MAX_RELAYS / 16);
  SerialCmdDone(cmd);
}

void loop()
{
  uint8_t i;
  static uint8_t s = 1;
  static uint8_t d = 0;
  uint8_t r[32];

  for (i = 0; i < 32; i++) {
    r[i] = ~s;
  }

  SerialWriteRelayExpander(r, 32);
  delay(50);

  if (d) {
    if (s > 1) s >>= 1;
    else d = 0;
  }
  else {
    if (s < 0x80) s <<= 1;
    else d = 1;
  }

  wdt_reset();
}

Schematics

256 Relays Diagram
Relayexpander256 rfdkvzviul

Comments

Similar projects you might like

Control/Synchronize Hundreds of Relays at the Same Time

Project tutorial by Christian

  • 5,630 views
  • 5 comments
  • 26 respects

Control Up to 65,280 Relays with Your Arduino!

Project tutorial by Christian

  • 29,384 views
  • 10 comments
  • 73 respects

Control Two Relays Over the Internet

Project tutorial by Arduino_Genuino

  • 2,727 views
  • 0 comments
  • 0 respects

Arduino BME280 Sensor How To

by Dragos Iosub

  • 2,300 views
  • 0 comments
  • 2 respects

Publish Your Arduino Data to the Cloud

by Jaume Miralles

  • 10,378 views
  • 14 comments
  • 53 respects
Add projectSign up / Login