Steun onze actie WeGoSTEM

Voor onze actie WeGoSTEM zoeken we nog vrijwilligers. Doe mee via WeGoSTEM.be/meedoen

Home automation with the I/O board

Did you ever dream about controlling your lights, fridge or radio using a microcontroller? This can be done easily with the Dwenguino I/O board with which you can control 8 different devices (< 250 VAC). Moreover, if you connect 4 I/O boards in series you can increase this up to 24 different devices.


Functionality

The Dwenguino I/O board connects to the Dwenguino using its expansion connector and has the following functionality:

  • eight buffered outputs (5 A, 250 VAC or 30 VDC) each with status LED and connector for save connection. warning: working with high VAC requires discipline and proper safety measures (see how to connect)
  • eight additional digital input pins
  • additional power input
  • easy connection with the Dwenguino board through the expansion connector
  • in order to further expand the number of IO, up to four Dwengo I/O boards can be cascaded
  • address selection with a DIP switch

Please note that the I/O board uses the I2C bus on pins 14 and 15. Consequently, you should not connect anything else on these pins when using the I/O board.

IO board

Getting started

We start by initialising the required libraries:

  1. #include <Wire.h>
  2. #include <LiquidCrystal.h>
  3. #include <Dwenguino.h>
  4. #include <DwenguinoIOBoard.h>

After initialising the libraries we can instantiate an IOBoard object which has an address (0-3) as an argument. The address can be set on the IO Board by setting the jumper ADDRESS. Please also note that JP1-1 and JP1-2 must be set.

  1. IOBoard io(0); // create an IOBoard object with address 0 (see jumper ADDRESS on Dwengo IO Board)

In the setup function we have to initialise both, the Dwenguino board and the IO Board:

  1. void setup() {
  2. // put your setup code here, to run once:
  3. initDwenguino();
  4. io.init();
  5. }

After which we can use the IO Board in the loop function. In this example we use the setOutputs function to switch on and off the relays. The argument is an eight bit number, each bit refers to one of the eight relays. With the readInputs function, the additional inputs provided by the IO Board can be read.

  1. void loop() {
  2. // put your main code here, to run repeatedly:
  3. dwenguinoLCD.clear();
  4. dwenguinoLCD.print("IO status = ");
  5. io.setOutputs(B11110000);
  6. dwenguinoLCD.print(io.readInputs());
  7. delay(1000);
  8. io.setOutputs(B00001111);
  9. delay(1000);
  10. }

The example code can also be found in Arduino IDE File > Examples > Dwenguino > IOBoard

How to connect

Firstly, whenever you want to control a high voltage device (120 VAC or 220 VAC) with the Dwengo I/O Board you need to be extremely careful! The Dwengo I/O board should be placed in an insulated box (plastic or wood) and one should never make touch one of the electric contacts during operation.

Secondly, the Dwengo I/O board contains 8 relays which work as a programmable switch for your device (light bulb, coffee machine, Rube Goldberg machine,...). Such a (one phased) machine comes typically with two (neutral and phase line) or three wires (neutral, phase line and earth). Find out which wire the phase line is and cut that wire in two. One end goes into screw one of a relay, the other end goes into the other screw. Screw tightly!

relay circuit

Thirdly, the I/O Board has to be powered with a 12 V DC power supply. Use the power input connector. There is no need to supply the connected Dwenguino board. The Dwenguino board can be powered through the I/O Board.

Lastly, check all the connections and put everything in a well insulated box. Make sure there are no wires making contact with each other or other electrical contacts! The other end of the phase line, the neutral and (if present) the earth can be connected to the appropriate plug for your country. If you feel confident, plug it in!

Schematics and design files

CC-BY-SA Dwengo I/O Board by Dwengo vzw is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Please read the license before using this material

Click to download the schematics and design files

Additional Materials