Cov txheej txheem:

IOT123 - I2C 2CH RELAY BRICK: 5 Kauj Ruam (nrog Duab)
IOT123 - I2C 2CH RELAY BRICK: 5 Kauj Ruam (nrog Duab)

Video: IOT123 - I2C 2CH RELAY BRICK: 5 Kauj Ruam (nrog Duab)

Video: IOT123 - I2C 2CH RELAY BRICK: 5 Kauj Ruam (nrog Duab)
Video: IOT123 - ICOS10: STRUCTURE 2024, Hlis ntuj nqeg
Anonim
IOT123 - I2C 2CH RELAY BRICK
IOT123 - I2C 2CH RELAY BRICK
IOT123 - I2C 2CH RELAY BRICK
IOT123 - I2C 2CH RELAY BRICK
IOT123 - I2C 2CH RELAY BRICK
IOT123 - I2C 2CH RELAY BRICK
IOT123 - I2C 2CH RELAY BRICK
IOT123 - I2C 2CH RELAY BRICK

IOT123 BRICKS yog chav DIY modular uas tuaj yeem sib xyaw nrog lwm IOT123 BRICKS, txhawm rau ntxiv kev ua haujlwm rau ntawm qhov chaw lossis hnav tau. Lawv tau ua raws li lub xwmfab nti, ob-tog protoboards nrog sib cuam tshuam los ntawm qhov.

Ib tug xov tooj ntawm cov BRICKS no yuav tsum yog nyob ntawm ntau lub node (Master MCUs - ESP8266 lossis ATTINY84) ntawm qhov chaw. MCU tsis xav tau kev paub ua ntej txog lub hom phiaj ntsuas lossis software xav tau. Nws ntsuas rau I2C cov nodes tom qab ntawv thov cov khoom pov tseg (cov ntaub ntawv sensor) los ntawm txhua tus qhev. Cov BRICKs muab 5.0V, 3.3V thiab lwm txoj kab AUX uas tuaj yeem tsim kho tau.

Qhov I2C 2CH RELAY BRICK txuas ntxiv kev ua haujlwm ntawm I2C KY019 BRICK, thiab muaj ob qhov nyeem/sau khoom:

2CH RELAYS [0] (muaj tseeb/tsis tseeb)

2CH RELAYS [1] (muaj tseeb/tsis tseeb)

Qhov dhau los ntawm qhov uas nyob ib sab ntawm ATTINY85 tau tso tseg tsis siv, txhawm rau ua kom tus pogo tus programmer thaum DIP8 tau muab muag rau PCB. Ib qho kev tsis txaus ntseeg ntxiv, ntim BRICKS hauv lub tog raj kheej me uas txuas rau hauv D1M WIFI BLOCK hub, tso tus nqi rau MQTT server, tab tom tsim.

Kauj Ruam 1: Cov Ntaub Ntawv thiab Cov Cuab Yeej

Cov Khoom thiab Cov Cuab Yeej
Cov Khoom thiab Cov Cuab Yeej
Cov Khoom thiab Cov Cuab Yeej
Cov Khoom thiab Cov Cuab Yeej
Cov Khoom thiab Cov Cuab Yeej
Cov Khoom thiab Cov Cuab Yeej

Muaj Daim Ntawv Teev Npe Tag Nrho ntawm Cov Khoom thiab Sourcing.

  1. 2 Channel Relay (1)
  2. ATTINY85 20PU (1)
  3. 1 "Ob tog ob tog protoboard (1)
  4. Txiv neej Header 90º (3P, 3P)
  5. Txiv neej Header (2P, 2P)
  6. Jumper Shunt (1)
  7. Hookup hlau (~ 7)
  8. Cov laug thiab hlau (1)

Kauj Ruam 2: Npaj ATTINY85

Npaj ATTINY85
Npaj ATTINY85
Npaj ATTINY85
Npaj ATTINY85
Npaj ATTINY85
Npaj ATTINY85

NCO TSEG: Yog tias xav kom muaj Crouton kev koom ua ke, thov siv lub tsev qiv ntawv los ntawm no, thiab siv tus piv txwv teeb tsa "attiny_2ch_relay".

AttinyCore los ntawm Tus Thawj Saib Xyuas Boards xav tau. Hlawv bootloader "EEPROM khaws cia", "8mHZ Internal" (txhua qhov teeb tsa pom saum toj no).

Qhov chaws khaws cia tuaj yeem pom ntawm no.

ZIP ntawm lub tsev qiv ntawv tuaj yeem pom ntawm no.

Cov lus qhia rau "Ntshuam ZIP Library" ntawm no.

Thaum lub tsev qiv ntawv raug teeb tsa koj tuaj yeem qhib qhov piv txwv "attiny_2ch_relay".

Txhawm rau rub cov firmware rau ATTINY85, koj yuav pom cov ntsiab lus ntxiv hauv cov lus qhia no:

www.instructables.com/id/How-to-Program-A…

www.instructables.com/id/Programming-the-…

www.instructables.com/id/Programming-the-…

www.instructables.com/id/Programming-the-…

Qhov zoo tshaj los sim ntawm lub khob cij ua ntej txuas ntxiv.

Yog tias koj muaj ASSIMILATE SENSORS uas twb muaj lawm, xyuas kom tus qhev qhov chaw nyob sib txawv ntawm SENSOR/MCU Tus tswv tsev ua ke piv txwv li txhua tus ua yeeb yaj kiab Relay tuaj yeem muaj qhov chaw nyob tib yam yog tias koj tsuas muaj ib tus neeg ua yeeb yaj kiab tso rau ntawm MCU/ntawm.

Kauj Ruam 3: Sib dhos Circuit

Sib dhos Circuit
Sib dhos Circuit
Sib dhos Circuit
Sib dhos Circuit
Sib dhos Circuit
Sib dhos Circuit
  1. Nyob rau sab xub ntiag, ntxig cov khoom ATTINY85 (1), 3P 90deg txiv neej lub taub hau (2) (3), 3P txiv neej lub taub hau (4) (5) thiab muab tshuaj txhuam tso rau tom qab.
  2. Sab nraub qaum, taug ib txoj kab daj los ntawm YELLOW1 mus rau YELLOW2 thiab cov laug.
  3. Ntawm sab nraub qaum, taug ib txoj kab txiv kab ntxwv los ntawm ORANGE1 mus rau ORANGE2 thiab cov laug.
  4. Ntawm sab nraub qaum, xaim xaim xaim los ntawm BLUE1 rau BLUE2 thiab cov laug.
  5. Ntawm sab nraub qaum, taug ib txoj kab ntsuab los ntawm GREEN1 rau GREEN2 thiab cov laug.
  6. Ntawm sab nraub qaum, taug ib txoj kab dub los ntawm BLACK1 rau BLACK2 thiab cov laug.
  7. Ntawm sab nraub qaum, taug ib txoj kab dub los ntawm BLACK3 rau BLACK4 thiab cov laug.
  8. Nyob tom qab, taug ib txoj kab liab los ntawm RED1 mus rau RED2 thiab cov laug.
  9. Ntawm sab nraub qaum, taug ib txoj kab liab qab los ntawm RED3 txog RED4 thiab cov laug.
  10. Ntawm sab nraub qaum, taug ib txoj kab liab qab ntawm SILVER1 rau SILVER2 thiab cov laug.
  11. Ntxiv jumper ntawm kab 5V lossis 3V3.

Tam sim no kev xa tawm tam sim no tuaj yeem txuas ncaj qha los ntawm nws cov pins rau PCB lossis ntawm cov xov hlau, mus rau cov ntsiab lus pom hauv daim ntawv cog lus tus pin.

Kauj ruam 4: Xeem

Kev Xeem
Kev Xeem
Kev Xeem
Kev Xeem
Kev Xeem
Kev Xeem
Kev Xeem
Kev Xeem

Tus lej ntawm cov BRICKS no yuav tsum yog nyob ntawm ntau lub hauv paus (MCUs - ESP8266 lossis ATTINY84) hauv ib puag ncig. Nov yog chav ntsuas: xa I2C cov lus txib los ntawm UNO mus rau ATTINY uas qhib lossis kaw qhov kev xa tawm.

Peb tau tsim yav dhau los I2C SHIELD rau Arduino.

Yog tias koj xav tau breadboard nws xwb:

  1. Txuas 5.0V ntawm UNO rau VCC ntawm BRICK.
  2. Txuas GND ntawm UNO rau GND ntawm BRICK.
  3. Txuas A5 ntawm UNO rau SCL ntawm BRICK.
  4. Txuas A4 ntawm UNO rau SDA ntawm BRICK.
  5. Txuas tus 4K7 rub tawm tus tiv thaiv los ntawm SDA rau VCC.
  6. Txuas tus 4K7 rub tawm tus tiv thaiv los ntawm SCL rau VCC.

Khiav qhov kev xeem

  1. Txuas koj UNO rau koj Dev PC nrog USB.
  2. Xa cov cai mus rau UNO.
  3. Qhib Arduino Console.
  4. Xaiv 9600 baud (rov pib dua UNO thiab rov qhib lub console yog tias koj yuav tsum tau).
  5. Qhov chaw nyob ntawm tus qhev yuav luam tawm rau lub console.
  6. Thaum twg, nkag mus rau hauv lub thawv xa 2 0: 1 (yog li 15 2 0: 1), thiab CH1 txuas ntxiv mus.

  7. Thaum twg, nkag mus rau hauv lub thawv xa 2 0: 0 (yog li 15 2 0: 0), thiab CH1 kev xa xov xa tawm.
  8. Thaum twg, nkag mus rau hauv lub thawv xa 2 1: 1 (yog li 15 2 1: 1), thiab CH2 xa xov xa mus.
  9. Thaum twg, nkag mus rau hauv lub thawv xa 2 1: 0 (yog li 15 2 0: 0), thiab CH2 kev xa xov xa tawm.

I2C BRICK adhoc cov lus txib rau qhev los ntawm UNO tus tswv

#suav nrog
const byte _num_chars = 32;
char _received_chars [_num_chars]; // ib qho array khaws cov ntaub ntawv tau txais
boolean _has_new_data = tsis tseeb;
voidsetup () {
Serial.begin (9600);
Serial.println ();
Serial.println ("ASSIMILATE IOT ACTOR/SENSOR EEPROM EDITOR");
Serial.println ("xyuas kom meej kab tshiab xaiv hauv lub qhov rai console");
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 ntaus_count = 0;
rau (byte chaw nyob = 8; chaw nyob <127; chaw nyob ++)
{
Wire.beginTransmission (chaw nyob);
const byte yuam kev = Wire.endTransmission ();
yog (yuam kev == 0)
{
Serial.println (chaw nyob);
}
}
}
voidloop () {
recv_with_end_marker ();
xa_to_i2c ();
}
voidrecv_with_end_marker () {
zoo li qub byte ndx = 0;
char end_marker = '\ n';
caj rc;
thaum (Serial.available ()> 0 && _has_new_data == tsis tseeb) {
rc = Serial.read ();
yog (rc! = end_marker) {
_received_chars [ndx] = rc;
ndx ++;
yog (ndx> = _num_chars) {
ndx = _num_chars - 1;
}
}
lwm tus {
_received_chars [ndx] = '\ 0'; // txiav txoj hlua
nnx = 0;
_has_new_data = tseeb;
}
}
}
voidsend_to_i2c () {
char param_buf [16];
const String received_string = Txoj hlua (_received_chars);
yog (_has_new_data == muaj tseeb) {
int idx1 = tau txais_string.indexOf ('');
Txoj hlua chaw nyob = tau txais_string.substring (0, idx1);
int address_int = chaw nyob.toInt ();
yog (address_int <8 || address_int> 127) {
Serial.println ("Qhov chaw nyob tsis raug nkag mus:");
Serial.println (chaw nyob);
rov qab;
}
int idx2 = tau txais_string.indexOf ('', idx1+1);
Txoj hlua;
yog (idx2 == -1) {
code = tau txais_string.substring (idx1+1);
lwm yam {
code = tau txais_string.substring (idx1+1, idx2+1);
}
int code_int = chaws.toInt ();
yog (code_int <0 || code_int> 5) {
Serial.println ("INVALID CODE INPUT:");
Serial.println (chaws);
rov qab;
}
bool has_parameter = idx2> -1;
Txoj hlua parameter;
yog (muaj_parameter) {
parameter = tau txais_string.substring (idx2 + 1, idx2 + 17); // 16 kab ntawv max
yog (parameter.length () <1) {
Serial.println ("PARTAMETER MIN. LENGTH 1");
_has_new_data = tsis tseeb;
rov qab;
}
lwm yam {
yog (code_int> 1) {
Serial.println ("PARAMETER YUAV TSUM!");
_has_new_data = tsis tseeb;
rov qab;
}
}
Serial.println ();
Serial.print ("keeb kwm input =");
Serial.println (tau txais cov hlua);
Serial.print ("chaw nyob =");
Serial.println (chaw nyob);
Serial.print ("chaws =");
Serial.println (chaws);
Serial.print ("ntsuas =");
Serial.println (qhov ntsuas);
// Xa VIA I2C
Wire.beginTransmission (address_int);
Wire.write (code_int);
yog (muaj_parameter) {
parameter.trim ();
strcpy (param_buf, parameter.c_str ());
Hlau.write (param_buf);
}
Wire.endTransmission ();
Serial.println ();
Serial.println ("Xa VIA I2C!");
Serial.println ();
Serial.println ("");
_has_new_data = tsis tseeb;
}
}

saib rawuno_i2c_command_input.ino tuav nrog ❤ los ntawm GitHub

Kauj Ruam 5: Cov Kauj Ruam Tom ntej

Cov kauj ruam tom ntej
Cov kauj ruam tom ntej
Cov kauj ruam tom ntej
Cov kauj ruam tom ntej
Cov kauj ruam tom ntej
Cov kauj ruam tom ntej
Cov kauj ruam tom ntej
Cov kauj ruam tom ntej

Kev taug qab tus neeg ua yeeb yam: 2CH RELAY uas siv cov cib no tau teeb tsa tsis siv neeg rau Crouton ntawm cov metadata twb tau teeb tsa hauv ATTINY85 ntawm no. JSON pob ntawv xa mus rau Crouton tau xa los ntawm cov khoom siv tshiab tshaj plaws rau ICOS10. Koj tuaj yeem ua pov thawj-ntawm-tswvyim ntawm qhov ESP8266 zoo tib yam, yog tias kev tsim yog ntau dhau rau tam sim no.

UNO cov duab kos siv hauv Kev Xeem muaj lub luag haujlwm rau txuag chaw qhev tshiab rau EEPROM ntawm ATTINY85, yog tias koj muaj kev sib tsoo ntawm koj lub hom phiaj I2C npav. Ob peb qhov kev xav tau ntxiv, tab sis muaj ntau txoj hauv kev los xaim hluav taws xob nqes hav nyob ntawm qhov koj xav kom ua tiav, yog li kuv yuav tso qhov ntawd rau koj:)

Pom zoo: