Cov txheej txheem:
- Kauj Ruam 1: Cov Ntaub Ntawv thiab Cov Cuab Yeej
- Kauj Ruam 2: Npaj ATTINY85
- Kauj Ruam 3: Sib Sau Cov Ntsiab Lus
- Kauj Ruam 4: Sib dhos Lub Hauv Paus Loj
- Kauj ruam 5: Xeem
- Kauj Ruam 6: Cov Kauj Ruam Tom ntej
Video: IOT123 - I2C HEARTBEAT BRICK: 6 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
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 HEARTBEAT BRICK no qhia tias tus qhev ATTINY tseem muaj txoj sia nyob, tseem yog I2C kev mus los, thiab muaj ib lub cuab yeej:
STATUS ("NYOB")
PB1 (dawb) qhia txog ATTINY kev noj qab haus huv.
PB3 (daj) toggles nrog I2C thov los ntawm tus tswv.
PB4 (txiv kab ntxwv) toggles nrog I2C tau txais los ntawm tus tswv.
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
Muaj Daim Ntawv Teev Npe Tag Nrho ntawm Cov Khoom thiab Sourcing.
- Ntawv PCB (7 x 7 qhov)
- LEDS (Liab, Ntsuab, Xiav)
- Resistors (3 tawm 1K)
- ATTINY85 20PU (1)
- 1 "Ob tog ob tog protoboard (1)
- Txiv neej Header 90º (3P, 3P)
- Txiv neej Header (2P, 2P)
- Jumper Shunt (1)
- Hookup hlau (~ 7)
- Cov laug thiab hlau (1)
Kauj Ruam 2: 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_heartbeat"
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_heartbeat".
Txhawm rau rub cov firmware rau ATTINY85, koj yuav pom cov ntsiab lus ntxiv hauv cov lus qhia no:
www.instructables.com/id/Programming-the-….
www.instructables.com/id/How-to-Program-A…
www.instructables.com/id/Programming-the-…
www.instructables.com/id/How-to-Program-A…
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 chaw nyob txawv ntawm SENSOR/MCU Host ua ke. txhua tus ua yeeb yaj kiab Relay tuaj yeem muaj qhov chaw nyob ib yam tsuav koj tsuas muaj ib tus ua yeeb yam Relay ntawm MCU/ntawm qhov.
Kauj Ruam 3: Sib Sau Cov Ntsiab Lus
Cov ntsuas ntsuas tau txhais tau tias tuaj yeem hloov kho tau. Nws yog qhov xwm txheej tshwm sim los ntawm cov kab hluav taws xob tseem ceeb uas tau pom ua Heartbeats. Rau qhov kev tsim no peb yuav siv cov ntsuas LED; koj tsim tau tuaj yeem siv txuas (yog VCC tau tawg tawm) lossis lwm qhov pom/teeb liab raws qhov ntsuas. Qhov tseem ceeb ntawm tus tiv thaiv yuav nyob ntawm tus kheej nyiam ntawm qhov kaj uas koj xav tau.
- Nyob rau sab saum toj, ntxig ib lub xiav LED rau hauv RED1 (+) thiab BLACK1 (G), thiab tso rau hauv qab.
- Hauv qab, khoov cov hlau lead los ntawm RED1 kom nws kov cov tooj liab ntawm SILVER8 thiab txiav.
- Hauv qab, txiav cov hlau lead los ntawm BLACK1 saum cov laug.
- Nyob rau sab saum toj, ntxig ib lub LED ntsuab rau hauv RED2 (+) thiab BLACK2 (G), thiab muab tshuaj txhuam rau hauv qab.
- Hauv qab, khoov cov hlau lead los ntawm RED2 kom nws kov cov tooj liab ntawm SILVER9 thiab txiav.
- Hauv qab, txiav cov hlau lead los ntawm BLACK2 saum cov laug.
- Nyob rau sab saum toj, ntxig lub teeb liab liab rau hauv RED3 (+) thiab BLACK3 (G), thiab muab tshuaj txhuam rau hauv qab.
- Hauv qab, khoov cov hlau lead los ntawm RED3 kom nws kov cov tooj liab ntawm SILVER10 thiab txiav.
- Hauv qab, txiav cov hlau lead los ntawm BLACK3 saum cov laug.
- Nyob rau sab saum toj, ntxig rau 1K tus tiv thaiv rau hauv qhov hla SILVER1 thiab SILVER4.
- Hauv qab, taug qab, txiav thiab ua cov hlau lead los ntawm SILVER1 mus rau BLACK1.
- Nyob rau sab saum toj, ntxig rau 1K tus tiv thaiv rau hauv qhov hla SILVER2 thiab SILVER4.
- Hauv qab, taug qab, txiav thiab ua cov hlau lead los ntawm SILVER2 mus rau BLACK2.
- Nyob rau sab saum toj, ntxig rau 1K tus tiv thaiv rau hauv qhov hla SILVER3 thiab SILVER4.
- Hauv qab, taug qab, txiav thiab ua cov hlau lead los ntawm SILVER3 mus rau BLACK3.
- Hauv qab, cov xov hlau txuas ntawm SILVER4 thiab txiav ntawm kwv yees li 5 hli txuas ntxiv.
- Hauv qab, muab xaim dub txuas rau SILVER4.
- Hauv qab, muab xaim xaim dawb tso rau hauv SILVER5, kom ntseeg tau txuas ntxiv los ntawm RED1.
- Hauv qab, muab xaim daj tso rau hauv SILVER6, ua kom muaj kev txuas mus txuas ntxiv los ntawm RED2.
- Nyob rau hauv qab, muab cov kab xev liab tso rau hauv SILVER7, ua kom muaj kev txuas mus txuas ntxiv los ntawm RED3.
Kauj Ruam 4: Sib dhos Lub Hauv Paus Loj
Sib dhos:
- 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.
- Sab nraub qaum, taug ib txoj kab daj los ntawm YELLOW1 mus rau YELLOW2 thiab cov laug.
- Ntawm sab nraub qaum, taug ib txoj kab txiv kab ntxwv los ntawm ORANGE1 mus rau ORANGE2 thiab cov laug.
- Ntawm sab nraub qaum, xaim xaim xaim los ntawm BLUE1 rau BLUE2 thiab cov laug.
- Ntawm sab nraub qaum, taug ib txoj kab ntsuab los ntawm GREEN1 rau GREEN2 thiab cov laug.
- Ntawm sab nraub qaum, hla kab xaim dawb los ntawm WHITE1 txog WHITE2 thiab cov laug.
- Ntawm sab nraub qaum, taug ib txoj kab dub los ntawm BLACK1 rau BLACK2 thiab cov laug.
- Ntawm sab nraub qaum, taug ib txoj kab dub los ntawm BLACK3 rau BLACK4 thiab cov laug.
- Nyob tom qab, taug ib txoj kab liab los ntawm RED1 mus rau RED2 thiab cov laug.
- Ntawm sab nraub qaum, taug ib txoj kab liab qab los ntawm RED3 txog RED4 thiab cov laug.
- Ntawm sab nraub qaum, taug ib txoj kab liab qab ntawm SILVER1 rau SILVER2 thiab cov laug.
- Ntxiv jumper ntawm kab 5V lossis 3V3.
Yog tias siv Cov Ntsiab Lus saum toj no (xa mus rau daim duab pinout):
- Ntawm sab nraub qaum, xaim xaim dawb rau hauv PB1.
- Ntawm sab nraub qaum, xaim xaim daj rau hauv PB3.
- Ntawm sab nraub qaum, xaim kab xev txiv kab ntxwv rau hauv PB4.
- Ntawm sab nraub qaum, xaim dub xaim rau hauv GND.
Kauj ruam 5: 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 hloov pauv Txais Txais LED. ATTINY ALIVE LED tseem nyob.
Peb tau tsim yav dhau los I2C SHIELD rau Arduino.
Yog tias koj xav tau breadboard nws xwb:
- Txuas 5.0V ntawm UNO rau VCC ntawm BRICK.
- Txuas GND ntawm UNO rau GND ntawm BRICK.
- Txuas A5 ntawm UNO rau SCL ntawm BRICK.
- Txuas A4 ntawm UNO rau SDA ntawm BRICK.
- Txuas tus 4K7 rub tawm tus tiv thaiv los ntawm SDA rau VCC.
- Txuas tus 4K7 rub tawm tus tiv thaiv los ntawm SCL rau VCC.
Khiav qhov kev xeem
- Txuas koj UNO rau koj Dev PC nrog USB.
- Xa cov cai mus rau UNO.
- Qhib Arduino Console.
- Xaiv 9600 baud (rov pib dua UNO thiab rov qhib lub console yog tias koj yuav tsum tau).
- Qhov chaw nyob ntawm tus qhev yuav luam tawm rau lub console.
- Thaum twg, nkag rau hauv lub thawv xa 2 1 (yog li 16 2 1), thiab Txais Txais LED qhib.
- Thaum twg, nkag rau hauv lub thawv xa 2 0 (yog li 16 2 0), thiab Txais Txais LED tua.
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 6: Cov Kauj Ruam Tom ntej
Kev taug qab tus neeg ua yeeb yam: HEARTBEAT 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.
Pom zoo:
Game Heartbeat-Project: 4 Kauj Ruam
Game Heartbeat-Project: Hnub no yog Tsib Hlis 20, raws li peb txhua tus paub. Nws twb dhau los ua Suav Suav Hnub Valentine. (520 hauv Suav txhais tau tias kuv hlub koj). Tam sim no, peb tab tom yuav ua cov cuab yeej sib tham hu ua lub plawv dhia ntsuas ntshav txhawm rau ntsuas ob peb lub tacit nkag siab Qhov no yog kev sim
IOT123 - ASSIMILATE ACTOR: HEARTBEAT: 4 Kauj Ruam
IOT123 - ASSIMILATE ACTOR: HEARTBEAT: Nws qhia txog kev noj qab haus huv ntawm ATTINY, I2C thiab MQTT kev mus los. Qhov kev tsim no yog ua raws I2C HEARTBEAT BRICK. ASSIMILATE ACTORS/SENSORS yog ib puag ncig cov neeg ua haujlwm/cov cim uas muaj cov cuab yeej ntxiv thiab cov txheej txheem software rho tawm, ua rau nws ua tau rau c
IOT123 - LIR2032 BATTERY BRICK: 4 Kauj Ruam
IOT123 - LIR2032 roj teeb lub teeb: IOT123 BRICKS yog DIY chav nyob sib dhos uas tuaj yeem sib xyaw ua ke 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 sib thooj protoboards nrog kev sib txuas sib txuas los ntawm qhov … Txawm hais tias cov lus qhia
IOT123 - 3.3V POWER BRICK: 4 Cov kauj ruam
IOT123 - 3.3V POWER BRICK: IOT123 BRICKS yog DIY chav nyob 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 sib thooj protoboards nrog kev sib txuas sib txuas los ntawm qhov … Txawm hais tias cov lus qhia
IOT123 - 5PIN ATTINY85 NRF24L01 BRICK: 4 Kauj Ruam
IOT123 - 5PIN ATTINY85 NRF24L01 BRICK: Hloov tshiab: Qhov teeb tsa no yog kev kawm ntau lossis lub hauv paus rau kev sim software/fais fab mov. Txawm hais tias thaum PB5 yog neeg xiam oob qhab raws li RESET, nws tsis nyeem qhov tseem ceeb raug siv analogRead: rooj plaub siv tseem ceeb rau kev nyeem ntawv sensor. Yuav saib mus rau ATTINY84 teeb tsa