Cov txheej txheem:
- Kauj Ruam 1: Cov Ntaub Ntawv thiab Cov Cuab Yeej
- Kauj Ruam 2: Sib dhos Circuit
- Kauj Ruam 3: Teeb lub MCU
- Kauj Ruam 4: Sib dhos Circuit Casing
- Kauj Ruam 5: Txuas Rig Ua Rau Tus Tswj
- Kauj Ruam 6: Kuaj Tus Tswj
- Kauj Ruam 7: Kho Via I2C Siv Console Input
- Kauj Ruam 8: Cov Kauj Ruam Tom ntej
Video: IOT123 - SOLAR TRACKER - CONTROLLER: 8 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Nov yog qhov txuas ntxiv ntawm Cov Lus Qhia
IOT123 - SOLAR TRACKER - TILT/PAN, PANEL FRAME, LDR MOUNTTS RIG. Ntawm no peb tsom mus rau tus tswj hwm ntawm servos, thiab cov ntsuas ntawm lub hnub txoj haujlwm. Nws yog ib qho tseem ceeb kom taw qhia tias qhov kev tsim qauv no kwv yees 2 MCUs yuav ua haujlwm: ib qho (3.3V 8mHz Arduino Pro Mini) rau lub hnub ci tracker, thiab ib qho MCU ywj pheej rau koj cov ntsuas/ua yeeb yam.
Nov yog Version 0.3
Ntau dua li tshaj tawm txhua qhov haujlwm tom qab ua tiav qhov kev txaus siab, Kuv yuav xyaum ua ntu zus thiab xa qee yam ntau dua, hloov kho qhov kuv tau xa raws li kuv xav tau. Kuv yuav sau lwm cov lus qhia rau lub roj teeb them, _ thaum twg qhov kev ua kom zoo ntawm cov tswj software/kho vajtse tiav. Kuv yuav taw qhia qhov xav tau qhov kev xav tau zoo thaum peb nqis los ntawm qhov no.
Ib feem ntawm qhov laj thawj rau txoj hauv kev no yog kev tawm tswv yim ntawm cov neeg siv khoom. Yog tias koj pom qhov xav tau lossis muaj txoj hauv kev zoo dua, thov tawm tswv yim, tab sis nco ntsoov tias kuv tsis tuaj yeem xa txhua yam thiab tej zaum tsis yog rau lub sijhawm uas haum rau koj. Raws li cov lus piav qhia zoo li cuam tshuam tsawg dua lawv yuav raug tshem tawm ntawm kab lus no.
Qhov no suav nrog:
- Siv cov LDRs los ntawm tus Thawj Qhia Qhia kom paub lub hnub nyob ze thaj chaw.
- Tsiv cov servos kom ntsib lub hnub.
- Cov kev xaiv rau kev nkag siab ntawm kev txav mus los.
- Cov kev xaiv rau qib loj thaum txav mus rau lub hnub.
- Kev xaiv rau qhov txwv tsis pub siv ntawm cov servos.
- Kev xaiv rau kev ncua ntawm kev txav mus los.
- I2C interface rau teeb tsa/tau txais qhov tseem ceeb ntawm MCUs.
- Pw tsaug zog ntawm kev txav mus los.
Qhov no tsis suav nrog (thiab yuav hais raws li lub sijhawm tso cai):
- Tsuas yog siv lub zog thaum nruab hnub nruab hnub.
- Nco txog txoj haujlwm kaj ntug thiab mus rau ntawd thaum tsaus ntuj kaw.
- Tshem tus tswj hwm los ntawm MCU.
- Xauv lub LED (s) ntawm MCU.
- Hloov pauv lub zog los ntawm VCC ntau dua li RAW.
- Muab cov kev daws teeb meem rau teeb nyem yam tsis muaj kev tswj hwm lub zog los ntawm USB rau Serial TTL hloov pauv.
- Roj teeb qhov ntsuas hluav taws xob.
Keeb Kwm
Kaum Ob Hlis 20, 2017 V0.1 CODE
Thawj version taug qab lub teeb ci, ib txwm nyob, tsis them nyiaj
Lub Ib Hlis 7, 2018 V0.2 CODE
-
HARDWARE CHANGES
- Ntxiv I2C pins
- Ntxiv hloov mus rau servo GNDs
- Luam Ntawv Sau rau ntawm lub thawv tswj fascia
-
SOFTWARE CHANGES
- Nyeem teeb tsa los ntawm EEPROM
- I2C tsheb npav txhawb nqa ua qhev rau lwm MCU (3.3V)
- Teeb teeb tsa ntawm I2C
- Teeb Enabled ntawm I2C
- Tau txais kev teeb tsa ntawm I2C
- Tau txais cov khoom siv sijhawm ntawm I2C (tam sim no tau qhib, thiab Tam Sim No Teeb Pom Kev Zoo)
- Tshem tawm cov ntawv teev npe (nws cuam tshuam rau I2C qhov tseem ceeb)
Lub Ib Hlis 19, 2018 V0.3 CODE
-
HARDWARE
Hloov kho daim ntawv lo Tam sim no Hloov tau siv los xaiv CONFIG lossis TRACK hom
-
SOFTWARE
- I2C tsuas yog siv rau kev teeb tsa
- Tus tswj hwm tos 5 vib nas this ua ntej pib taug qab, tso cai rau txav tes
- Txhawm rau siv I2C teeb tsa, SPDT yuav tsum yog ntawm CONFIG raws li chav khau
- Hauv nruab nrab ntawm kev taug qab txav mus los, chav nyob hauv hom pw tsaug zog zoo rau teeb tsa tus nqi SLEEP MINUTES (default 20 feeb).
Kauj Ruam 1: Cov Ntaub Ntawv thiab Cov Cuab Yeej
Tam sim no muaj tag Nrho Cov Nqi Ntawm Cov Khoom Siv thiab Cov Npe.
- 3D luam qhov.
- Arduino Pro Mini 3.3V 8mHz
- 1 ntawm 4x6cm Ob Sab Sab Prototype PCB Universal Luam Luam Circuit Board (kom txiav ib nrab)
- 1 tawm 40P txiv neej lub taub hau (kom txiav kom loj).
- 1 tawm 40P poj niam lub taub hau (kom txiav kom loj).
- 4 tawm 10K 1/4W cov neeg kho vajtse.
- Hookup hlau.
- Solder thiab Iron.
- 20 tawm 4G x 6mm stainless lauj kaub taub hau tus kheej tapping screws.
- 4 tawm 4G x 6mm stainless countersunk tus kheej tapping screws.
- 1 tawm 3.7V LiPo roj teeb thiab tus tuav (txiav tawm hauv 2P dupont txuas).
- 1 tawm 2P txiv neej txoj cai kaum lub taub hau
- 1 tawm SPDT hloov 3 tus pin 2.54mm suab
- Muaj zog Cyanoacrylate kua nplaum
- Dupont txuas poj niam 1P header (1 tawm xiav, 1 tawm ntsuab).
Kauj Ruam 2: Sib dhos Circuit
Tam sim no lub Circuit Court tsis muaj Voltage Divider Circuit (volt meter).
- Txiav 4x6cm Ob Sab Sab Qauv Prototype PCB Universal Printed Circuit Board hauv ib nrab hla txoj kab ntev.
-
Txiav 40P txiv neej lub taub hau ua tej daim:
- 2 ua 12p
- 3 ua 3p
- 6 ua 2p.
-
Txiav 40P poj niam lub taub hau ua tej daim:
- 2 ua 12p
- 1 ua 6p
- Solder 2 tawm 12Pfemale header raws li qhia.
- Muab cov kua nplaum tshem tawm ntawm 3P txiv neej (ntxiv) lub taub hau mus rau sab hauv qab ntawm SPDT Hloov nrogCyanoacrylate kua nplaum
- Ntawm lwm qhov chaw tom qab ntawd muab cov laug 6 tawm 2P, 2 tawm 3Pmale lub taub hau thiab hloov SPDT raws li qhia.
- Solder 4 tawm 10K resistors (A, B, C, D dub) ntawm cov hlau lead mus rau GND tus pin header (#2 dub) thiab rau A0 - A3 header pins (#5, #6, #7, #8) tom qab ntawd los ntawm qhov (daj) raws li qhia (3 duab + 1 daim duab).
- Taug qab 3.3V los ntawm LDR PINS soldering PINS #4, #6, #8, #10 thiab xov txawm tias qhov rau feamale header VCC tus pin (ntsuab).
- Ua raws 3.3V ntawm tus poj niam lub taub hau sab raws li qhia (liab) txuas rau PINS #1, #12, #15.
- 3.3V los ntawm lub qhov hla ntawm sab (liab) RAW header PIN #1.
- Lw tus txiv kab ntxwv txuas los ntawm tus lej #11 los ntawm lub qhov mus rau tus poj niam tus pin ntawm lwm sab raws li qhia.
- Nrhiav thiab xaim xaim xaim txuas txuas txuas ntawm #20 txog #30 thiab los ntawm #31 txog #13 thiab #16.
- Solder Poj Niam Header PIN #11 rau Txiv Neej Header PIN #11 los ntawm qhov.
- Npaj 2 dupont txuas 30 hli ntev nrog poj niam 1P header (1 tawm xiav, 1 tawm ntsuab). Sawb thiab tin lwm qhov kawg.
- Solder xiav Dupont xaim rau #28; solder ntsuab Dupont xaim rau #29.
- Nyob rau sab saum toj ntawm Arduino txhim kho 6P poj niam lub taub hau tom qab ntawd muab tshuaj txhuam.
- Nyob rau sab saum toj ntawm Arduino txhim kho 2P txoj cai kaum tus poj niam header int #29 thiab #30 ces laug.
- Hauv qab ntawm Arduino txhim kho 2 ntawm 12P thiab 1 tawm 3P txiv neej tus pin ces tus laug laug.
- Ntxig Arduino txiv neej 12P tus pin rau hauv PCB 12P poj niam lub taub hau.
Kauj Ruam 3: Teeb lub MCU
Arduino Pro Mini tau yooj yim flashed siv FTDI232 USB rau TTL hloov pauv siv 6P poj niam lub taub hau. Saib daim duab saum toj no rau kev ua kom sib haum ntawm 2 cov laug cam.
Xyuas kom 3.3V teeb tsa tau xaiv ntawm koj li FTDI232. Ua raws cov lus qhia ntawm no siv tus lej hauv qab no (siv txuas rau GIST).
Lub tsev qiv ntawv qis zog (txuas thiab https://github.com/rocketscream/Low-Power) xav tau kev teeb tsa.
Thaum lub Arduino Pro Mini + PCB tau teeb tsa hauv lub casing nws tseem tuaj yeem flashed raws li lub taub hau pins raug. Tsuas yog txiav tawm Lub Chaw Tswj Xyuas los ntawm Cov Vaj Huam Sib Luag nthuav tawm lub taub hau.
Tilt pan solar tracker nrog I2C/EEPROM teeb tsa thiab pw tsaug zog ntawm kev txav mus los. Lub sijhawm pw tsaug zog lub sijhawm raug txo qis raws li lub sijhawm nce, tab sis txaus rau lub hom phiaj no
/* |
* hloov kho los ntawm cov cai |
* los ntawm Mathias Leroy |
* |
* V0.2 Hloov kho |
** I2C SET Tau |
** EEPROM SET Tau |
** ROV QAB RAWS LI QHOV TSEEB - cuam tshuam I2C |
** KEV TSHAWB XEEB/QHOV TSEEM CEEB |
** Qhib cov kev pabcuam rau LIMITS VIA I2C |
** Nyeem tam sim no AVG INTENSITY VIA I2C |
* V0.3 Hloov kho |
** Hloov rau 2 Hom - Taug Qab (Tsis Muaj I2C) thiab teeb tsa (Siv I2C) |
** QHOV TSEEB QHOV TSEEB QHOV TSEEB (QAUV QHOV TSEEB QHOV TSEEB YUAV TSUM MUAJ 8 CHUNKS) |
** DETACH/ATTACH SERVOS ON SLEEP/WAKE (tus neeg xa khoom siv tas li) |
** REMOVE CONFIGURABLE INITIAL POSITION (REDUNDANT) |
** Tshem tawm WAKE SECONDS (REDUNDANT) |
** REMOVE CONFIGURABLE ENABLE/DISABLE (REDUNDANT) |
** REMOVE CONFIGURABLE TRACKER ENABLED (Siv HARDWARE SWITCH) |
** ROV QAB VOLTAGE GETTER - Yuav siv cais I2C COMPONENT |
** Ntxiv LOGGING thaum tsis siv I2C |
*/ |
#suav nrog |
#suav nrog |
#suav nrog |
#suav nrog |
#suav nrog |
#defineEEPROM_VERSION1 |
#defineI2C_MSG_IN_SIZE3 |
#definePIN_LDR_TL A0 |
#definePIN_LDR_TR A1 |
#definePIN_LDR_BR A3 |
#definePIN_LDR_BL A2 |
#definePIN_SERVO_V11 |
#definePIN_SERVO_H5 |
#defineIDX_I2C_ADDR0 |
#defineIDX_V_ANGLE_MIN1 |
#defineIDX_V_ANGLE_MAX2 |
#defineIDX_V_SENSITIVITY3 |
#defineIDX_V_STEP4 |
#defineIDX_H_ANGLE_MIN5 |
#defineIDX_H_ANGLE_MAX6 |
#defineIDX_H_SENSITIVITY7 |
#defineIDX_H_STEP8 |
#defineIDX_SLEEP_MINUTES9 |
#defineIDX_V_DAWN_ANGLE10 |
#defineIDX_H_DAWN_ANGLE11 |
#defineIDX_DAWN_INTENSITY12 // nruab nrab ntawm txhua LDRS |
#defineIDX_DUSK_INTENSITY13 // nruab nrab ntawm txhua LDRS |
#defineIDX_END_EEPROM_SET14 |
#defineIDX_CURRENT_INTENSITY15 // nruab nrab ntawm txhua LDRS - siv rau xam IDX_DAWN_INTENSITY ambiant tsis ncaj qha teeb |
#defineIDX_END_VALUES_GET16 |
#defineIDX_SIGN_117 |
#defineIDX_SIGN_218 |
#defineIDX_SIGN_319 |
Servo _servoH; |
Servo _servoV; |
byte _i2cVals [20] = {10, 10, 170, 20, 5, 10, 170, 20, 5, 20, 40, 10, 30, 40, 0, 0, 0, 0, 0, 0, 0} |
int _servoLoopDelay = 10; |
int _slowingDelay = 0; |
int _angleH = 90; |
int _angleV = 90; |
int _averageTop = 0; |
int _averageRight = 0; |
int _averageBottom = 0; |
int _averageLeft = 0; |
byte _i2cResponse = 0; |
bool _inConfigMode = tsis tseeb; |
voidsetup () |
{ |
Serial.begin (115200); |
getFromEeprom (); |
yog (inConfigMode ()) { |
Serial.println ("Config Mode"); |
Serial.print ("I2C Chaw Nyob:"); |
Serial.println (_i2cVals [IDX_I2C_ADDR]); |
Wire.begin (_i2cVals [IDX_I2C_ADDR]); |
Wire.onReceive (receiveEvent); |
Wire.onRequest (requestEvent); |
lwm yam { |
Serial.println ("Hom Nrhiav"); |
ncua (5000); // sijhawm kom tau txhais tes tawm ntawm txoj kev yog txuas lub roj teeb thiab lwm yam. |
} |
} |
voidloop () |
{ |
getLightValues (); |
yog (! _inConfigMode) { |
// ToDo: TUG RAU TRANSISTOR SWITCH |
_servoH.attach (PIN_SERVO_H); |
_servoV.attach (PIN_SERVO_V); |
rau (int kuv = 0; kuv <20; kuv ++) { |
yog tias (kuv! = 0) { |
getLightValues (); |
} |
moveServos (); |
} |
ncua (500); |
_servoH.detach (); |
_servoV.detach (); |
// ToDo: TAWM TUS NEEG SIV TRANSISTOR SWITCH |
ncua (500); |
tsaug zog ((_ i2cVals [IDX_SLEEP_MINUTES] * 60) / 8); |
} |
} |
// --------------------------------- QAUV QAUV |
boolinConfigMode () { |
pinMode (PIN_SERVO_H, INPUT); |
_inConfigMode = digitalRead (PIN_SERVO_H) == 1; |
rov _inConfigMode; |
} |
// --------------------------------- EEPROM |
voidgetFromEeprom () { |
yog tias ( |
EEPROM.read (IDX_SIGN_1)! = 'S' || |
EEPROM.read (IDX_SIGN_2)! = 'T' || |
EEPROM.read (IDX_SIGN_3)! = EEPROM_VERSION |
) EEPROM_write_default_configuration (); |
EEPROM_read_configuration (); |
} |
voidEEPROM_write_default_configuration () { |
Serial.println ("EEPROM_write_default_configuration"); |
rau (int i = 0; i <IDX_END_EEPROM_SET; i ++) { |
EEPROM.update (kuv, _i2cVals ); |
} |
EEPROM.update (IDX_SIGN_1, 'S'); |
EEPROM.update (IDX_SIGN_2, 'T'); |
EEPROM.update (IDX_SIGN_3, EEPROM_VERSION); |
} |
voidEEPROM_read_configuration () { |
Serial.println ("EEPROM_read_configuration"); |
rau (int i = 0; i <IDX_END_EEPROM_SET; i ++) { |
_i2cVals = EEPROM.read (i); |
//Serial.println(String(i) + "=" + _i2cVals ); |
} |
} |
// --------------------------------- I2C |
voidreceiveEvent (int suav) { |
yog (suav == I2C_MSG_IN_SIZE) |
{ |
char cmd = Hlau.read (); |
byte ntsuas = Wire.read (); |
byte tus nqi = Wire.read (); |
hloov (cmd) { |
cas G ': |
yog (index <IDX_END_VALUES_GET) { |
_i2cResponse = _i2cVals [index]; |
} |
tawg; |
Cas ': |
yog (index <IDX_END_EEPROM_SET) { |
_i2cVals [index] = tus nqi; |
EEPROM.update (index, _i2cVals [index]); |
} |
tawg; |
neej ntawd hais: |
rov qab; |
} |
} |
} |
voidrequestEvent () |
{ |
Wire.write (_i2cResponse); |
} |
// --------------------------------- LDRs |
voidgetLightValues () { |
int valueTopLeft = analogRead (PIN_LDR_TL); |
int valueTopRight = analogRead (PIN_LDR_TR); |
int valueBottomRight = analogRead (PIN_LDR_BR); |
int valueBottomLeft = analogRead (PIN_LDR_BL); |
_averageTop = (valueTopLeft + valueTopRight) / 2; |
_averageRight = (valueTopRight + valueBottomRight) / 2; |
_averageBottom = (valueBottomRight + valueBottomLeft) / 2; |
_averageLeft = (valueBottomLeft + valueTopLeft) / 2; |
int avgIntensity = (valueTopLeft + valueTopRight + valueBottomRight + valueBottomLeft) / 4; |
_i2cVals [IDX_CURRENT_INTENSITY] = daim ntawv qhia (avgIntensity, 0, 1024, 0, 255); |
} |
// --------------------------------- SERVOS |
voidmoveServos () { |
Serial.println ("moveServos"); |
yog ((_averageLeft-_averageRight)> _ i2cVals [IDX_H_SENSITIVITY] && (_angleH-_i2cVals [IDX_H_STEP])> _ i2cVals [IDX_H_ANGLE_MIN]) { |
// mus sab laug |
Serial.println ("moveServos mus rau sab laug"); |
ncua (_slowingDelay); |
rau (int i = 0; i <_i2cVals [IDX_H_STEP]; i ++) { |
_servoH.write (_angleH--); |
ncua (_servoLoopDelay); |
} |
} |
elseif ((_averageRight-_averageLeft)> _ i2cVals [IDX_H_SENSITIVITY] && (_angleH+_i2cVals [IDX_H_STEP]) <_ i2cVals [IDX_H_ANGLE_MAX]) { |
// mus lawm |
Serial.println ("moveServos mus rau sab laug"); |
ncua (_slowingDelay); |
rau (int i = 0; i <_i2cVals [IDX_H_STEP]; i ++) { |
_servoH.write (_angleH ++); |
ncua (_servoLoopDelay); |
} |
} |
lwm tus { |
// tsis ua dab tsi |
Serial.println ("moveServos tsis ua dab tsi"); |
ncua (_slowingDelay); |
} |
yog ((_averageTop-_averageBottom)> _ i2cVals [IDX_V_SENSITIVITY] && (_angleV+_i2cVals [IDX_V_STEP]) <_ i2cVals [IDX_V_ANGLE_MAX]) { |
// nce |
Serial.println ("moveServos nce mus"); |
ncua (_slowingDelay); |
rau (int kuv = 0; kuv <_i2cVals [IDX_V_STEP]; kuv ++) { |
_servoV.write (_angleV ++); |
ncua (_servoLoopDelay); |
} |
} |
elseif ((_averageBottom-_averageTop)> _ i2cVals [IDX_V_SENSITIVITY] && (_angleV-_i2cVals [IDX_V_STEP])> _ i2cVals [IDX_V_ANGLE_MIN]) { |
// mus lawm |
Serial.println ("moveServos nqis mus"); |
ncua (_slowingDelay); |
rau (int kuv = 0; kuv <_i2cVals [IDX_V_STEP]; kuv ++) { |
_servoV.write (_angleV--); |
ncua (_servoLoopDelay); |
} |
} |
lwm tus { |
Serial.println ("moveServos tsis ua dab tsi"); |
ncua (_slowingDelay); |
} |
} |
// --------------------------------- SLEEP |
voidasleepFor (unsignedint yimSecondSegments) { |
Serial.println ("pw tsaug zog rau"); |
rau (unsignedint sleepCounter = yimSecondSegments; sleepCounter> 0; sleepCounter--) |
{ |
LowPower.powerDown (SLEEP_8S, ADC_OFF, BOD_OFF); |
} |
} |
saib rawtilt_pan_tracker_0.3.ino tuav nrog ❤ los ntawm GitHub
Kauj Ruam 4: Sib dhos Circuit Casing
- Xyuas kom Ardiuno Pro Mini tau ntxig rau hauv lub hau ntawm PCB.
- Ntxig SOLAR TRACKER lub thawv tswj lub hauv paus rau SOLAR TRACKER tus tswj lub thawv phab ntsa thiab txuas nrog 2 tawm 4G x 6mm stainless countersunk tus kheej tapping screws.
- Ntxig Ardiuno Pro Mini + PCB nrog 6P Header slotting rau hauv qhov khoob hauv SOLAR TRACKER maub los lub thawv puag.
- Ntxig SOLAR TRACKER lub thawv tswj lub hau rau hauv SOLAR TRACKER tus tswj lub thawv phab ntsa thiab txuas nrog 2 tawm 4G x 6mm stainless countersunk tus kheej tapping screws.
- Kev sib dhos ua ke saum toj no mus rau lub hauv paus ntawm Cov Vaj Huam Sib Luag nrog 4 tawm 4G x 6mm stainless countersunk tus kheej tapping screws.
Kauj Ruam 5: Txuas Rig Ua Rau Tus Tswj
Cov kev sib txuas uas tsim nyog tau npaj los ntawm Cov Lus Qhia yav dhau los, yog 4 tawm 2P LDR kev sib txuas thiab 2 tawm 3P kev sib txuas los ntawm servos. Dab tsi yog ib ntus kom txog thaum rov them rov qab yog lub roj teeb. Siv 3.7V LiPo uas xaus rau hauv 2P DuPont kev txuas rau tam sim no.
-
Ntxig rau LDR kev sib txuas (tsis muaj polarity) los ntawm sab saud:
- Sab xis
- Sab laug
- Qab Txoj Cai
- Hauv qab Sab laug
-
Ntxig rau Servo kev sib txuas (nrog lub teeb liab xaim mus rau sab laug) los ntawm sab saud:
- Kab rov tav
- Ntsug
- TSEEM NYEEM TSEEM NYEEM NTXIV NTXIV: Ntxig rau 3.7V DC Lub Hwj Huam Hluav Taws Xob +ua rau saum, -v mus rau hauv qab.
Kauj Ruam 6: Kuaj Tus Tswj
Raws li tau hais ua ntej, cov software tsis tau ua kom zoo dua rau Hnub Ci Them Nyiaj Ua Haujlwm. Nws tuaj yeem raug sim thiab hloov kho siv lub ntuj (lub hnub) thiab lub teeb ci tsis zoo ib yam nkaus.
Txhawm rau ntsuas kev taug qab hauv ib puag ncig tswj hwm nws yuav yooj yim los teeb tsa SLEEP MINUTES rau tus nqi qis (saib cov kauj ruam tom ntej).
Kauj Ruam 7: Kho Via I2C Siv Console Input
Qhov no piav qhia teeb tsa tus tswj hwm ntawm MCU thib ob, nkag mus rau qhov chaw nkag mus rau hauv lub qhov rai console.
- Rub cov ntawv hauv qab no mus rau D1M WIFI BLOCK (lossis Wemos D1 Mini).
- Disconnect USB los ntawm PC
-
Kev Txuas Tus PIN: -ve (Tus Tswj) => GND (D1M)+ve (Tus Tswj) => 3V3 (D1M) SCL (Tus Tswj) => D1 (D1M)
SDA (Xws li) => D2 (D1M)
- Tig SPDT hloov mus rau CONFIG
- Txuas USB rau PC
- Los ntawm Arduino IDE pib lub qhov rai console nrog qhov raug COM Port
- Nco ntsoov "Newline" thiab "9600 baud" raug xaiv
- Cov lus txib tau nkag mus rau hauv Send Textbox ua raws los ntawm Enter qhov tseem ceeb
- Cov lus txib yog nyob hauv hom Cim byte byte
- Yog tias qhov thib ob byte (ntu thib peb) tsis suav nrog 0 (xoom) raug xa los ntawm tsab ntawv
- Ceev faj siv cov ntawv nkag; tshuaj xyuas qhov koj tau nkag mus ua ntej ntaus "Enter" qhov tseem ceeb. Yog tias koj raug kaw (piv txwv hloov I2C chaw nyob mus rau tus nqi uas koj tau hnov qab) koj yuav tsum nyem nyem lub khoos phis tawj ntxiv.
Cov kev txhawb nqa sib txawv hauv cov lus txib thawj tus cim yog:
- E (Pab kom taug qab qhov kev pabcuam servo) muaj txiaj ntsig zoo rau nres kev txav mus los thaum teeb tsa. Qhov no yog cov tswv yim siv: E 0
- D (Lov tes taw servo mus txog qhovtwg) muaj txiaj ntsig los pib siv lub cuab yeej yog tias tsis rov pib dua lub cuab yeej. Qhov no yog cov tswv yim siv: D 0
- G (Tau txais tus nqi teeb tsa) nyeem qhov tseem ceeb los ntawm EEPROM thiab IN -MEMORY: Qhov no yog cov tswv yim siv: G (qhov ntsuas tau siv tau byte qhov tseem ceeb 0 - 13 thiab 15)
- S (Teeb EEPROM tus nqi) teeb tsa tus nqi rau EEPROM uas muaj tom qab rov pib dua. Qhov no yog kev siv tswv yim: S (qhov ntsuas tau siv tau byte qhov tseem ceeb 0 - 13, tus nqi siv tau byte qhov tseem ceeb thiab sib txawv ntawm ib lub tsev)
Txoj cai yog lub ntsiab lus tseeb rau qhov ntsuas tab sis cov hauv qab no yog siv rau cov lus qhia rau qhov siv tau/cov lus pom:
- I2C ADDRESS 0 - tus tswj chaw nyob tus tswv, tus tswv xav tau qhov no los tham nrog tus tswj (lub neej ntawd 10)
- QHOV TSEEB TSHAJ PLAWS TSEV KAWM NTAWV 1 - lub kaum sab xis ntsug servo qis txwv (default 10, range 0 - 180)
- MAXIMUM VERTICAL ANGLE 2 - lub kaum sab xis ntsug servo sab saud txwv (default 170, thaj tsam 0 - 180)
- SENSITIVITY VERTICAL LDR 3 - Ntsug LDR nyeem npoo (default 20, range 0 - 1024)
- VERTICAL ANGLE STEP 4 - lub kaum ntse ntse ntsug servo cov kauj ruam ntawm txhua qhov kev hloov pauv (default 5, range 1 - 20)
- MINIMUM HORIZONTAL ANGLE 5 - kaum kab rov tav servo qis txwv (default 10, thaj tsam 0 - 180)
- MAXIMUM HORIZONTAL ANGLE 6 - kaum kab rov tav servo sab saud txwv (default 170, thaj tsam 0 - 180)
- SENSITIVITY HORIZONTAL LDR 7 - Kab rov tav LDR nyeem kab ntawv (default 20, range 0 - 1024)
- HORIZONTAL ANGLE STEP 8 - kaum kab rov tav servo cov kauj ruam ntawm txhua qhov kev hloov pauv (default 5, range 1 - 20)
- QHOV TSEEB TSHIAB 9 - lub sijhawm kwv yees pw tsaug zog ntawm kev taug qab (default 20, range 1 - 255)
- VERTICAL DAWN ANGLE 10 - FUTURE USE - lub kaum sab xis rov qab los thaum lub hnub poob qis
- HORIZONTAL DAWN ANGLE 11 - Siv yav tom ntej - lub kaum sab xis rov qab los thaum lub hnub poob qis
- DAWN INTENSITY 12 - Siv Yav Tom Ntej - qhov nruab nrab yam tsawg kawg ntawm txhua qhov LDRs uas ua rau pib pib hnub taug qab hnub.
- DUSK INTENSITY 13 - Siv Yav Tom Ntej - qhov nruab nrab yam tsawg kawg ntawm txhua LDRs uas ua rau qhov kawg ntawm kev saib xyuas lub hnub txhua hnub
- KAWG EEPROM VALUES MARKER 14 - Tus nqi tsis siv
- ZOO TSHAJ PLAWS 15 - tam sim no feem pua nruab nrab ntawm lub teeb siv
- KAWG NYOB HAUV NTAWV -MEMORY VALUES MARKER 16 - Tus nqi tsis siv.
Captures serial input (keyboard input in the console window) thiab xa mus rau I2C qhev hauv hom ntawv char, byte, byte
#suav nrog |
#defineI2C_MSG_IN_SIZE2 |
#defineI2C_MSG_OUT_SIZE3 |
#defineI2C_SLAVE_ADDRESS10 |
boolean _newData = tsis tseeb; |
const byte _numChars = 32; |
char _receivedChars [_numChars]; // ib qho array khaws cov ntaub ntawv tau txais |
voidsetup () { |
Serial.begin (9600); |
Wire.begin (D2, D1); |
ncua (5000); |
} |
voidloop () { |
recvWithEndMarker (); |
parseSendCommands (); |
} |
voidrecvWithEndMarker () { |
zoo li qub byte ndx = 0; |
char endMarker = '\ n'; |
caj rc; |
thaum (Serial.available ()> 0 && _newData == tsis tseeb) { |
rc = Serial.read (); |
yog (rc! = endMarker) { |
_receivedChars [ndx] = rc; |
ndx ++; |
yog (ndx> = _numChars) { |
ndx = _numChars - 1; |
} |
lwm yam { |
_receivedChars [ndx] = '\ 0'; // txiav txoj hlua |
nnx = 0; |
_newData = tseeb; |
} |
} |
} |
voidparseSendCommands () { |
yog (_newData == muaj tseeb) { |
constchar delim [2] = ""; |
cim *cim; |
token = strtok (_receivedChars, delim); |
char cmd = _receivedChars [0]; |
byte qhov ntsuas = 0; |
byte tus nqi = 0; |
int kuv = 0; |
thaum (token! = NULL) { |
//Serial.println(token); |
kuv ++; |
hloov (i) { |
rooj plaub 1: |
token = strtok (NULL, delim); |
index = atoi (tus cim); |
tawg; |
rooj plaub 2: |
token = strtok (NULL, delim); |
yog (token! = NULL) { |
tus nqi = atoi (token); |
} |
tawg; |
neej ntawd hais: |
token = NULL; |
} |
} |
sendCmd (cmd, ntsuas, tus nqi); |
_newData = cuav; |
} |
} |
voidsendCmd (char cmd, byte index, byte tus nqi) { |
Serial.println ("-----"); |
Serial.println ("Xa cov lus txib:"); |
Serial.println ("\ t" + String (cmd) + "" + String (index) + "" + String (value)); |
Serial.println ("-----"); |
Wire.beginTransmission (I2C_SLAVE_ADDRESS); // xa mus rau lub cuab yeej |
Hlau.write (cmd); // xa char |
Wire.write (qhov ntsuas); // xa ib byte |
Wire.write (tus nqi); // xa ib byte |
Wire.endTransmission (); |
byte teb = 0; |
bool hadResponse = tsis tseeb; |
yog tias (cmd == 'G') { |
Wire.requestFrom (I2C_SLAVE_ADDRESS, 1); |
thaum (Wire.available ()) // qhev yuav xa tsawg dua qhov tau thov |
{ |
hadResponse = muaj tseeb; |
teb = Wire.read (); |
} |
yog (hadResponse == muaj tseeb) { |
Serial.println ("Tau txais cov lus teb:"); |
Serial.println (teb); |
lwm yam { |
Serial.println ("Tsis teb, txheeb xyuas qhov chaw nyob/txuas"); |
} |
} |
} |
saib rawd1m_serial_input_i2c_char_byte_byte_v0.1.ino tuav nrog ❤ los ntawm GitHub
Kauj Ruam 8: Cov Kauj Ruam Tom ntej
Txheeb rov qab ib ntus txhawm rau txheeb xyuas kev hloov pauv hauv software/kho vajtse.
Hloov kho software/kho vajtse raws li koj xav tau.
Tawm tswv yim rau txhua qhov kev thov/ua kom zoo dua qub.
Pom zoo:
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom - Cov Kauj Ruam ntawm Kauj Ruam: 4 Kauj Ruam
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom | Cov kauj ruam ib kauj ruam: Hauv txoj haujlwm no, kuv yuav tsim qhov yooj yim Arduino Tsheb Rov Qab Tsheb Nres Tsheb Nres Sensor Siv Arduino UNO thiab HC-SR04 Ultrasonic Sensor. Qhov no Arduino raws Lub Tsheb Rov Qab ceeb toom tuaj yeem siv rau Kev Tshawb Fawb Txog Tus Kheej, Robot Ranging thiab lwm yam
Desktop COVID19 Tracker Nrog Moos! Raspberry Pi Powered Tracker: 6 Kauj Ruam
Desktop COVID19 Tracker Nrog Moos! Raspberry Pi Powered Tracker: Peb paub tias peb tuaj yeem tuag txhua lub sijhawm, txawm tias kuv tuaj yeem tuag thaum sau cov ntawv no, tom qab tag nrho, kuv kuv, koj, peb txhua tus yog neeg tuag. Tag nrho lub ntiaj teb tau tshee vim yog COVID19 muaj thoob qhov txhia chaw. Peb paub yuav tiv thaiv qhov no li cas, tab sis hav! peb paub yuav thov li cas thiab vim li cas thiaj thov ntuj, peb puas ua
Tsev Automation Kauj Ruam ntawm Kauj Ruam Siv Wemos D1 Mini Nrog PCB Tsim: 4 Kauj Ruam
Tsev Automation Kauj Ruam Ib Leeg Siv Wemos D1 Mini Nrog PCB Tsim: Tsev Automation Kauj Ruam los ntawm Kauj Ruam siv Wemos D1 Mini nrog PCB Tsim cov tub ntxhais kawm ntawv qib siab. Tom qab ntawd ib tus ntawm peb cov tswv cuab tuaj
RC Taug Qab Neeg Hlau Siv Arduino - Kauj Ruam Ib kauj ruam: 3 Kauj Ruam
RC Tracked Robot Siv Arduino - Kauj Ruam Ib Nrab: Hav guys, Kuv rov qab los nrog lwm tus neeg hlau txias chassis los ntawm BangGood. Vam tias koj tau dhau los ntawm peb cov phiaj xwm yav dhau los - Spinel Crux V1 - Tus Cwj Pwm Tswj Tus Neeg Hlau, Spinel Crux L2 - Arduino Xaiv thiab Muab Neeg Hlau nrog Robotic caj npab thiab Badland Braw
Movie Tracker - Raspberry Pi Powered Theatrical Release Tracker: 15 Cov Kauj Ruam (nrog Duab)
Movie Tracker - Raspberry Pi Powered Theatrical Release Tracker: Movie Tracker yog cov duab clapperboard, Raspberry Pi -powered Release Tracker. Nws siv TMDb API los luam daim ntawv tshaj tawm, lub npe, hnub tso tawm thiab cov lus pom ntawm cov yeeb yaj kiab yuav los tom ntej hauv koj cheeb tsam, nyob rau lub sijhawm tshwj xeeb ncua sijhawm (piv txwv li kev ua yeeb yaj kiab tso tawm lub lim tiam no) ntawm