IOT123 - I2C BRICK MASTER JIG

Introduction: IOT123 - I2C BRICK MASTER JIG

About: The tension between novelty and familiarity...

While developing the ASSIMILATE SENSORS and ACTORS, I keep a UNO handy for sending adhoc I2C commands to the prototypes being developed. One of the benefits of the I2C BRICKS is the standardized pinouts. Rather than using breadboard wires each time (see the Fritzings), a sturdy lo-tech shield is used.

Step 1: Materials and Tools

  1. 4cm x 6cm Uninersal PCB (1)
  2. Hookup wire (~6)
  3. 4K7 Resistors (2)6
  4. Male Header (12P, 8P)
  5. Female Header (9P, or 3P, 3P)
  6. Solder and Iron (1)

Step 2: Assembly

If you use 2 off 3P female headers instead of the 1 off 9P female header, the ASSIMILATE SENSOR/ACTORS will fit on the JIG without disassembling them.

With the wiring, strip off up to 10mm on the ends and tin the very ends.

  1. On the bottom of the PCB, insert the male header (1)(2) and solder off on top.
  2. On the top of the PCB, insert the female header (3) and solder off on bottom.
  3. On the top, through-hole a red wire into RED1 and RED2.
  4. On the bottom, through-hole wire from RED1 into RED3.
  5. On the bottom, through-hole wire from RED2 into RED5, and solder.
  6. On the top, through-hole wire from RED3 into RED4, and solder.
  7. On the top, through-hole a red wire into RED6 and RED7.
  8. On the bottom, through-hole wire from RED6 into RED8.
  9. On the bottom, through-hole wire from RED7 into RED10, and solder.
  10. On the top, through-hole wire from RED8 into RED9, and solder.
  11. On the top, through-hole a black wire into BLACK1 and BLACK2.
  12. On the bottom, through-hole wire from BLACK1 into BLACK3.
  13. On the bottom, through-hole wire from BLACK2 into BLACK5, and solder.
  14. On the top, through-hole wire from BLACK3 into BLACK4, and solder.
  15. On the top, through-hole a blue wire into BLUE1 and BLUE2.
  16. On the bottom, through-hole wire from BLUE1 into BLUE3.
  17. On the bottom, through-hole wire from BLUE2 into BLUE5, and solder.
  18. On the top, through-hole wire from BLUE3 into BLUE4, and solder.
  19. On the top, through-hole a green wire into GREEN1 and GREEN2.
  20. On the bottom, through-hole wire from GREEN1 into GREEN3.
  21. On the bottom, through-hole wire from GREEN2 into GREEN5, and solder.
  22. On the top, through-hole wire from GREEN3 into GREEN4, and solder.
  23. On the top, through-hole a 4K7 resistor into SILVER3 and SILVER4.
  24. On the bottom, through-hole wire from SILVER3 into GREEN5, and solder.
  25. On the bottom, through-hole wire from SILVER4 into RED10, and solder.
  26. On the top, through-hole a 4K7 resistor into SILVER1 and SILVER2.
  27. On the bottom, through-hole wire from SILVER1 into BLUE5, and solder.
  28. On the bottom, through-hole wire from SILVER2 into RED10, and solder.

Step 3: Code for the UNO

The sketch here is rudimentary. It allows you to use the Console Input, to make the UNO send I2C messages to the I2C ATTINY85 BRICK.

All of the instructions are printed to the screen, with the supported options.

I2C BRICK adhoc commands for slaves from UNO master.

#include<Wire.h>
const byte _num_chars = 32;
char _received_chars[_num_chars]; // an array to store the received data
boolean _has_new_data = false;
voidsetup() {
Serial.begin(9600);
Serial.println();
Serial.println("ASSIMILATE IOT ACTOR/SENSOR EEPROM EDITOR");
Serial.println("ensure newline selected in console window");
Serial.println();
Serial.println("ADDRESS 1 CONFIRM METADATA RECEIPT N/A (FOR M2M)");
Serial.println("ADDRESS 2 ACTOR COMMAND");
Serial.println();
Serial.println("ADDRESSES ON BUS:");
scan_i2c_addresses();
Serial.println();
Serial.println("");
}
voidscan_i2c_addresses(){
int device_count = 0;
for (byte address = 8; address < 127; address++)
{
Wire.beginTransmission(address);
const byte error = Wire.endTransmission();
if (error == 0)
{
Serial.println(address);
}
}
}
voidloop() {
recv_with_end_marker();
send_to_i2c();
}
voidrecv_with_end_marker() {
static byte ndx = 0;
char end_marker = '\n';
char rc;
while (Serial.available() >0 && _has_new_data == false) {
rc = Serial.read();
if (rc != end_marker) {
_received_chars[ndx] = rc;
ndx++;
if (ndx >= _num_chars) {
ndx = _num_chars - 1;
}
}
else {
_received_chars[ndx] = '\0'; // terminate the string
ndx = 0;
_has_new_data = true;
}
}
}
voidsend_to_i2c() {
char param_buf[16];
const String received_string = String(_received_chars);
if (_has_new_data == true) {
int idx1 = received_string.indexOf('');
String address = received_string.substring(0, idx1);
int address_int = address.toInt();
if (address_int < 8 || address_int >127){
Serial.println("INVALID ADDRESS INPUT:");
Serial.println(address);
return;
}
int idx2 = received_string.indexOf('', idx1+1);
String code;
if (idx2 == -1){
code = received_string.substring(idx1+1);
}else{
code = received_string.substring(idx1+1, idx2+1);
}
int code_int = code.toInt();
if (code_int < 0 || code_int >5){
Serial.println("INVALID CODE INPUT:");
Serial.println(code);
return;
}
bool has_parameter = idx2 > -1;
String parameter;
if (has_parameter){
parameter = received_string.substring(idx2 + 1, idx2 + 17); // 16 chars max
if (parameter.length() < 1){
Serial.println("PARTAMETER MIN. LENGTH 1");
_has_new_data = false;
return;
}
}else{
if (code_int >1){
Serial.println("PARAMETER REQUIRED!");
_has_new_data = false;
return;
}
}
Serial.println();
Serial.print("input orig = ");
Serial.println(received_string);
Serial.print("address = ");
Serial.println(address);
Serial.print("code = ");
Serial.println(code);
Serial.print("parameter = ");
Serial.println(parameter);
// SEND VIA I2C
Wire.beginTransmission(address_int);
Wire.write(code_int);
if (has_parameter){
parameter.trim();
strcpy(param_buf, parameter.c_str());
Wire.write(param_buf);
}
Wire.endTransmission();
Serial.println();
Serial.println("SENT VIA I2C!");
Serial.println();
Serial.println("");
_has_new_data = false;
}
}

Step 4: Next Steps

From the builds presented, there are enough moving parts for you to build your own ASSIMILATE IOT NETWORK.

Each of the individual functions of the nodes (sensors and actors) are controllable in a decentralized manner, not depending on the MCU master to have any knowledge of the features supported.

Any app connecting to the MQTT broker can control/observe every feature of the IOT Node. Thats M2M, web applications, IFTTT and so on. Much simpler (or richer if you like) interfaces to your IOT world.

Share

    Recommendations

    • Creative Misuse Contest

      Creative Misuse Contest
    • Metalworking Contest

      Metalworking Contest
    • Tiny Home Contest

      Tiny Home Contest

    Discussions

    As mentioned in Assembly, if using 2 off 3P instead of a 9P female header, the fully assembled ASSIMILATE ACTORS/SENSORS can be used.

    1.png2.png3.png