Cov txheej txheem:

IOT123 - I2C MQ2 BRICK: 5 Kauj Ruam
IOT123 - I2C MQ2 BRICK: 5 Kauj Ruam

Video: IOT123 - I2C MQ2 BRICK: 5 Kauj Ruam

Video: IOT123 - I2C MQ2 BRICK: 5 Kauj Ruam
Video: MQ-2 датчик газов и дыма подключаем к Arduino 2024, Hlis ntuj nqeg
Anonim
IOT123 - I2C MQ2 BRICK
IOT123 - I2C MQ2 BRICK
IOT123 - I2C MQ2 BRICK
IOT123 - I2C MQ2 BRICK
IOT123 - I2C MQ2 BRICK
IOT123 - I2C MQ2 BRICK
IOT123 - I2C MQ2 BRICK
IOT123 - I2C MQ2 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 MQ2 BRICK dumps 3 cov khoom:

LPG (Tshooj Ib lab), CO (PPM), SMOKE (PPM)

Qhov ntsuas no tau muab cov xwm txheej txaus nyiam: Nws xav tau tsawg kawg 2 feeb (txog 5 feeb) kom sov, tom qab ntawd nws yuav tsum ntsuas ntsuas li 20 vib nas this ua ntej siv. Raws li tus tswv tsev MCU tsuas yog xav paub kom tau txais lub npe/tus nqi khub (thiab txuas lus ntxiv), peb tau tshaj tawm "Npaj" cov cuab yeej. Raws li nws cov lus txuas ntxiv yog "1" (ntau ntxiv tuaj), Tus Tswv MCU yuav khaws qhov kev xaiv tsa BRICK kom txog thaum nws npaj tau. Tsis tas li nws tau pom zoo kom "Hlawv-hauv" MQ2 ua ntej siv xws li tawm mus txuas rau koj li 5V Circuit rau 24 teev.

Cov Keyes hom ntsuas cib yuav raug suav daws ua ntej vim lawv tuaj nrog cov vitamins (cov khoom siv ntxiv xav tau) suav nrog thiab yog tus cheep (Kuv yuav 37 rau 10AUD). Lwm cov laug cam/kab hluav taws xob yuav raug qhia rau I2C BRICKS.

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 Khoom Siv thiab Cov Cuab Yeej

Khoom siv thiab cuab yeej
Khoom siv thiab cuab yeej
Khoom siv thiab cuab yeej
Khoom siv thiab cuab yeej
Khoom siv thiab cuab yeej
Khoom siv thiab cuab yeej

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

  1. MQ2 sensor cib (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
Npaj ATTINY85
Npaj ATTINY85

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).

Siv cov peev txheej suav nrog; suav thiab ua haujlwm rau ATtiny85.

GIST nyob ntawm no:

gist.github.com/IOT-123/4c501046d365d01a60…

Koj tuaj yeem pom cov ntsiab lus ntxiv hauv cov lus qhia no:

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

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

www.instructables.com/id/How-to-program-th…

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

www.instructables.com/id/Programming-an-At…

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 Host ua ke piv txwv li txhua qhov ntsuas kub tuaj yeem muaj tib qhov chaw nyob yog tias koj tsuas muaj ib qho ntsuas kub ntawm MCU/ntawm qhov.

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), 2P txiv neej lub taub hau (4) (5), thiab muab tso rau tom qab.
  2. Ntawm sab nraub qaum, taug ib txoj kab txiv kab ntxwv los ntawm ORANGE1 mus rau ORANGE2 thiab cov laug.
  3. Ntawm sab nraub qaum, xaim xaim xaim los ntawm BLUE1 rau BLUE2 thiab cov laug.
  4. Ntawm sab nraub qaum, taug ib txoj kab ntsuab los ntawm GREEN1 rau GREEN2 thiab cov laug.
  5. Ntawm sab nraub qaum, taug ib txoj kab liab qab ntawm SILVER1 rau SILVER2 thiab cov laug.
  6. Ntawm sab nraub qaum, taug ib txoj kab liab qab ntawm SILVER3 mus rau SILVER4 thiab cov laug.
  7. Ntawm sab nraub qaum, taug ib txoj kab dub los ntawm BLACK1 rau BLACK2 thiab cov laug.
  8. Ntawm sab nraub qaum, taug ib txoj kab dub los ntawm BLACK3 rau BLACK4 thiab cov laug.
  9. Nyob tom qab, taug ib txoj kab liab los ntawm RED1 mus rau RED2 thiab cov laug.
  10. Nyob tom qab, taug ib txoj kab liab los ntawm RED3 mus rau RED4 thiab cov laug.
  11. Sab nraub qaum, taug ib txoj kab daj los ntawm YELLOW1 mus rau YELLOW2 thiab cov laug.

Tam sim no lub ntsuas hluav taws xob 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

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 qhov ntsuas ntsuas: txheeb xyuas UNO qhov kev thov/lus teb kom txog thaum tag nrho cov ntaub ntawv raug pov tseg, tom qab ntawd tsis quav ntsej I2C qhev.

  1. Tshaj tawm UNO code rau koj li UNO cov hlua ntsuas. Xyuas kom ADDRESS_SLAVE phim rau BRICK qhov I2C chaw nyob.
  2. Txuas 5.0V ntawm UNO rau VCC ntawm BRICK.
  3. Xyuas kom lub jumper rau tus pin ntawd nyob.
  4. Txuas GND ntawm UNO rau GND ntawm BRICK.
  5. Txuas A5 ntawm UNO rau SCL ntawm BRICK.
  6. Txuas A4 ntawm UNO rau SDA ntawm BRICK.
  7. Txuas tus 4K7 rub tawm tus tiv thaiv los ntawm SDA rau VCC.
  8. Txuas tus 4K7 rub tawm tus tiv thaiv los ntawm SCL rau VCC.
  9. Txuas koj UNO rau koj Dev PC nrog USB.
  10. Qhib Arduino Console. Choose 9600 baud (rov pib dua UNO thiab rov qhib lub console yog tias koj yuav tsum tau).
  11. Cov Khoom Npe thiab cov txiaj ntsig yuav tsum tau luam tawm rau lub console ib zaug ces lo lus pw tsaug zog tau rov ua dua.

Yog tias koj pom "teeb tsa" ces 3 kab ntawm cov khib nyiab rov ua dua koj yuav muaj koj li SDA thiab SCL kab rov qab rau pem hauv ntej.

I2C Master nkag los ntawm I2C qhev nrog cov phiaj xwm/metadata txhawb nqa

#suav nrog
#defineADDRESS_SLAVE10
bool _outputPlotterOnly = tsis tseeb;
bool _confirmedMetadata = tsis tseeb;
int _packetSegment = 0;
bool _i2cNodeProcessed = tsis tseeb;
char _property [2] [24] = {"lub npe", "tus nqi"};
voidsetup () {
Hlau.begin (); // koom nrog i2c npav (chaw nyob yeem rau tus tswv)
Serial.begin (9600); // pib serial rau cov zis
ncua (1000);
yog (! _outputPlotterOnly) {
Serial.println ("teeb tsa");
Serial.println ();
}
}
voidloop () {
yog (_i2cNodeProcessed) {
yog (! _confirmedMetadata) {// qhia rau tus qhev paub pib xa cov ntaub ntawv sensor
ncua (1);
Wire.beginTransmission (ADDRESS_SLAVE);
Hlau.write (1);
Wire.endTransmission ();
ncua (100);
_confirmedMetadata = muaj tseeb;
}
_i2cNodeProcessed = tsis tseeb;
yog (! _outputPlotterOnly) {
Serial.println ();
}
rov qab;
}
Wire.requestFrom (ADDRESS_SLAVE, 16);
_packetSegment ++;
pob ntawv [16];
intindex = 0;
bool isContinueSegment = tsis tseeb; // txuas ntxiv (ntu thib 3) 1 = ntau dua, 0 = zaum kawg
thaum (Wire.available ()) {// qhev yuav xa tsawg dua qhov tau thov
char c = Hlau.read ();
pob [index] = int (c)> -1? c: ''; // hloov cov ntawv tsis raug nrog qhov chaw
yog (_packetSegment == 3) {
_packetSegment = 0;
isContinueSegment = muaj tseeb;
//Serial.println("------------- ");
//Serial.println(int (c));
//Serial.println("------------- ");
yog (int (c) == 48 || int (c) == 86) {// 0 ntawm cov khoom kawg
_i2cNodeProcessed = tseeb;
// xa qhov tseem ceeb rau MQTT
tawg;
}
}
index ++;
}
yog (! isContinueSegment) {
yog (! _outputPlotterOnly) {
Serial.println (pob ntawv);
}
strcpy (_property [_packetSegment - 1], pob ntawv); // teeb tsa lub zos var nrog lub npe/tus nqi
lwm yam {
yog (_outputPlotterOnly && _confirmedMetadata) {
yog (_i2cNodeProcessed) {
Serial.println (_ khoom [1]);
lwm yam {
Serial.print (_property [1]);
Serial.print ("");
}
}
}
}

saib rawuno_i2c_generic_sensor_test_w_plotter_v2.ino tuav nrog ❤ los ntawm GitHub

Kauj Ruam 5: Cov Kauj Ruam Tom ntej

Cov txheej txheem yooj yim ntawm Circuit Court thiab I2C txheej ntawm software yog cuam tshuam-muaj peev xwm rau ntau qhov sib txawv. Qhov tseem ceeb kom tau txais txoj cai pib nrog, yog daim ntawv cog lus ntawm tus tswv thiab qhev.

Kuv tau tshaj tawm/pib ua (3D luam tawm) ntim cov network ntawm cov ntsuas uas siv lub moj khaum no thiab yuav txuas rau nws raws li ntu tau tshaj tawm.

Qhov BLOCK no yog siv los ntawm MQ2 ASSIMILATE SENSOR.

Pom zoo: