The IOT123 BRICKS are DIY modular units that can be mashed up with other IOT123 BRICKS, to add functionality to a node or wearable. They are based on the inch square, double-sided protoboards with interconnected through holes.
A number of these BRICKS are expected to be on multiple nodes (Master MCUs - ESP8266 or ATTINY84) on a site. The MCU needs no prior knowledge of the sensors purpose or software needs. It scans for I2C nodes then requests a property dump (sensor data) from each slave. These BRICKs supply 5.0V, 3.3V and another AUX line which is customizable.
This I2C KY019 BRICK is the first of the ACTORS, and has one read/write property:
The Keyes type sensor bricks will be abstracted first as they come with vitamins (extra components needed) included and are relatively cheep (I bought 37 for 10AUD). Other boards/circuits will be introduced to the I2C BRICKS.
The through-holes adjacent to the ATTINY85 have been left unused, to enable a pogo pin programmer while the DIP8 is soldered to the PCB. A further abstraction, packaging the BRICKS in small cylinders that plug into a D1M WIFI BLOCK hub, pumping the values to a MQTT server, is being developed.
Step 1: Materials and Tools
There is a full Bill of Material and Sourcing list.
- KY-019 Relay (1)
- ATTINY85 20PU (1)
- 1" Double sided protoboard (1)
- Male Header 90º (3P, 3P)
- Hookup wire (~7)
- Solder and Iron (1)
Step 2: Prepare the ATTINY85
AttinyCore from the Boards Manager is needed. Burn bootloader "EEPROM Retained", "8mHZ Internal" (all config shown above).
The code repository can be found here.
A ZIP of the library can be found here.
Instructions for "Importing a ZIP Library" here.
Once the library is installed you can open the example "attiny_ky019".
To upload the firmware to the ATTINY85, you may find more details in these instructables:
Best to test via breadboard before continuing.
If you have existing ASSIMILATE SENSORS, make sure the slave address is different on a SENSOR/MCU Host combination i.e. all the Relay actors can have the same address as long as you only have one Relay actor on a MCU/node.
Step 3: Assemble the Circuit
- On the front, insert the components ATTINY85 (1), 3P 90deg male headers (2)(3), and solder off on the rear.
- On the rear, trace a yellow wire from YELLOW1 to YELLOW2 and solder.
- On the rear, trace a blue wire from BLUE1 to BLUE2 and solder.
- On the rear, trace a green wire from GREEN1 to GREEN2 and solder.
- On the rear, trace a black wire from BLACK1 to BLACK2 and solder.
- On the rear, trace a black wire from BLACK3 to BLACK4 and solder.
- On the rear, trace a red wire from RED1 to RED2 and solder.
- On the rear, trace a red wire from RED3 to RED4 and solder.
The relay can now be connected directly via its pins to the PCB or via wires, to the points shown in the pin contract.
Step 4: Testing
A number of these BRICKS are expected to be on multiple nodes (MCUs - ESP8266 or ATTINY84) in an environment. This is a unit test: sends I2C commands from the UNO to the ATTINY which opens or closes the relay.
We have previously built a I2C SHIELD for Arduino.
If you want to breadboard it instead:
- Connect the 5.0V on UNO to a VCC on BRICK.
- Connect the GND on UNO to GND on BRICK.
- Connect the A5 on UNO to SCL on BRICK.
- Connect the A4 on UNO to SDA on BRICK.
- Connect a 4K7 pull-up resistor from SDA to VCC.
- Connect a 4K7 pull-up resistor from SCL to VCC.
Running the test.
- Connect your UNO to your Dev PC with USB.
- Upload the code to the UNO.
- Open the Arduino Console.Choose 9600 baud (restart the UNO and reopen the console if you have to).
- The address of the slave will print to console.
- When <Arduino is ready>, enter in the send box <ADDRESS> 2 1 (so 12 2 1), and the relay turns on.
- When <Arduino is ready>, enter in the send box <ADDRESS> 2 0 (so 12 2 0), and the relay turns off.
Step 5: Next Steps
The follow-up ASSIMILATE ACTOR: KY019 which uses this brick has automatic configuration for Crouton via the metadata already installed in the ATTINY85 here. The JSON packet sent to Crouton is sent via the latest firmware for the ICOS10. You can do a Proof-of-concept on an ordinary ESP8266, if the build is a too much for now.
The UNO sketch used in Testing has a function for saving a new slave address to EEPROM on the ATTINY85, if you have a clash on your target I2C bus.
A few schematics have been added, but there are various ways to wire the downstream circuit depending on what you want to achieve, so I'll leave that for you : )