Cov txheej txheem:

MCP23017 GPIO Tswj Via Ethernet: 5 Kauj Ruam
MCP23017 GPIO Tswj Via Ethernet: 5 Kauj Ruam

Video: MCP23017 GPIO Tswj Via Ethernet: 5 Kauj Ruam

Video: MCP23017 GPIO Tswj Via Ethernet: 5 Kauj Ruam
Video: Lesson19- how to use PCF8574 IIC extend GPIO for ESP32 multi relay 2024, Hlis ntuj nqeg
Anonim
MCP23017 GPIO Tswj ntawm Ethernet
MCP23017 GPIO Tswj ntawm Ethernet
MCP23017 GPIO Tswj ntawm Ethernet
MCP23017 GPIO Tswj ntawm Ethernet

Tswj MCP23017 IO-txuas ntxiv ntawm ethernet siv Sensor Choj thiab MCP23017 tawg tawm lub rooj tsavxwm. Cov lus txib xa los ntawm Python cov ntawv, browser URLs lossis ib qho system uas muaj peev xwm ntawm kev sib txuas lus HTTP. Tuaj yeem koom ua ke rau Tsev Pabcuam rau kev siv tshuab hauv tsev.

Cov xov hlau txuas nrog rau Phoenix Connector clamp txuas. Cov xeev GPIO tau qhia los ntawm LEDs. Qhov chaw nyob tuaj yeem xaiv los ntawm 0x20 txog 0x27. GPIO BoB tuaj yeem ntsia tau rau ntawm txoj kab tsheb ciav hlau DIN. Sensor Choj tau teeb tsa flanges.

Khoom siv

Kallio Designs - Sensor Choj Digital (Ethernet rau I2C):

Kallio Designs MCP23017 Break out Board (I2C GPIO BoB):

8 - 26 V, 2 W Fais fab mov

Ethernet cables

Kauj Ruam 1: Kev sib txuas rau Ethernet rau I2C Sensor Choj

Kev sib txuas rau Ethernet rau I2C Sensor Choj
Kev sib txuas rau Ethernet rau I2C Sensor Choj
Kev sib txuas rau Ethernet rau I2C Sensor Choj
Kev sib txuas rau Ethernet rau I2C Sensor Choj

Txuas tus pin 3 thiab 4 rau SCL thiab SDA tus pin ntawm MCP23017 txhawm rau tshem tawm lub rooj tsav tsheb rau I2C npav.

Txuas tus pin 5 thiab 6 rau +5 V thiab GND pins ntawm MCP23017 tawg tawm pawg thawj coj saib. Qhov no yuav muab lub zog rau chav nyob.

Kauj Ruam 2: Txuas Ethernet thiab Muab Lub Hwj Huam

Txuas Ethernet thiab Muab Lub Hwj Chim
Txuas Ethernet thiab Muab Lub Hwj Chim

Yog tias koj muaj lub zog hla ethernet (PoE) muaj, tsuas yog txuas lub ethernet cable. Koj kuj tuaj yeem siv lub tshuab txhaj tshuaj. Ob chav yuav tsum muaj zog, tus qauv PoE cuam tshuam tuaj yeem txhawb nqa ob chav.

Yog tias koj tsis muaj PoE, txuas lub ethernet cable thiab 8-26 V, 2 W fais fab mov rau tus pin 1 (GND) thiab 2 (Qhov zoo).

Koj yuav tsum pom lub cim ntsuab LED teeb ntxiv rau qhov chaw nres nkoj ethernet LEDs qhia txog kev mus los.

Kauj Ruam 3: Teeb

Xyuas kom tseeb tias koj lub PC lossis lwm yam khoom siv tswj hwm nyob hauv tib lub network LAN zoo li Sensor Choj.

Siv cov nqes hluav taws xob tso rau ntawm lub rooj sib tsoo tawm los teeb tsa I2C chaw nyob (lub neej ntawd hex 0x20, uas txhais ua zauv 32).

Kauj ruam 4:

Duab
Duab
Duab
Duab

Cov lus txib tau piav qhia hauv Sensor Bridge tus neeg siv phau ntawv. Qhov kev xaiv yooj yim yog siv qhov ua hauv -cov lus txib, kom tsis txhob muaj teeb tsa ntau lub npe rau lub luag haujlwm.

Tshawb nrhiav "192.168.1.195/MCP27OA41" yuav teeb tus pin A4 kom siab. Koj yuav pom LED A4 teeb ntawm sab xis sab xis LED cov tsev txhab nyiaj. Koj mus rau "192.168.1.195/MCP27IA4" yuav nyeem tib tus pin thiab tso saib nws lub xeev ntawm qhov browser. LED tseem yuav tau taws yog tias tus pin tau teeb tsa sab nraud.

Kauj Ruam 5: Sau Nrog Python lossis Lwm Yam Lus

Kev Sau Nrog Python lossis Lwm Yam Lus
Kev Sau Nrog Python lossis Lwm Yam Lus

Txhawm rau tsim cov laj thawj ntxiv rau txoj haujlwm koj tuaj yeem siv Python urllib xa cov lus txib. Txhawm rau nyeem tus pin A4 xeev:

ntshuam urllib.requestprint (urllib.request.urlopen ("https://192.168.1.190/MCP27IA4").read ()) input ("Nias nkag mus kom tawm")

Lossis koj tuaj yeem siv curl los siv I2C interface ncaj qha. Txhawm rau teeb tsa txhua tus pin hauv chaw nres nkoj A raws li cov zis:

curl 192.168.1.195/I2CSTA027curl 192.168.1.195/I2CW00curl 192.168.1.195/I2CW00curl 192.168.1.195/I2CSENDS

Tib cov lus txib tuaj yeem xa los ntawm ib qho cuam tshuam nrog cov txiaj ntsig zoo ib yam, uas puas haum rau koj txoj haujlwm zoo tshaj plaws.

Pom zoo: