Changes

Jump to: navigation, search

Orange Pi Zero 2W

1,731 bytes added, 13:50, 26 September 2023
40pin I2C test
# As can be seen from the table below, the i2c available for the 40pin interface are i2c0, i2c1 and i2c2
<div style="display: flex;">::{| class="wikitable" style="width:390px;margin-right: 20px;text-align: center;"
|-
| '''GPIO NO.'''
| '''Function'''
| '''Pin'''
|-| style="text-align: left;"|| style="text-align: left;"|| '''3.3V'''| '''1'''|-| '''<span style="color:#FF0000">264</span>'''| '''<span style="color:#FF0000">PI8</span>'''| '''<span style="color:#FF0000">TWI1-SDA</span>'''| '''<span style="color:#FF0000">3</span>'''|-| '''<span style="color:#FF0000">263</span>'''| '''<span style="color:#FF0000">v</span>'''| '''<span style="color:#FF0000">TWI1-SCL</span>'''| '''<span style="color:#FF0000">5</span>'''|-| '''269'''| '''PI13'''| '''PWM3/UART4_TX'''| '''7'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''9'''|-| '''226'''| '''PH2'''| '''UART5_TX'''| '''11'''|-| '''227'''| '''PH3'''| '''UART5_RX'''| '''13'''|-| '''<span style="color:#FF0000">261</span>'''| '''<span style="color:#FF0000">PI5</span>'''| '''<span style="color:#FF0000">TWI0_SCL</span>/UART2_TX'''| '''<span style="color:#FF0000">15</span>'''|-| style="text-align: left;"|| style="text-align: left;"|| '''3.3V'''| '''17'''|-| '''231'''| '''PH7'''| '''SPI1_MOSI'''| '''19'''|-| '''232'''| '''PH8'''| '''SPI1_MISO'''| '''21'''|-| '''230'''| '''PH6'''| '''SPI1_CLK'''| '''23'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''25'''|-| '''<span style="color:#FF0000">266</span>'''| '''<span style="color:#FF0000">PI10</span>'''| '''<span style="color:#FF0000">TWI2-SDA</span>/UART3_RX'''| '''<span style="color:#FF0000">27</span>'''|-| '''256'''| '''PI0'''| style="text-align: left;"|| '''29'''|-| '''271'''| '''PI15'''| style="text-align: left;"|| '''31'''|-| '''268'''| '''PI12'''| '''PWM2'''| '''33'''|-| '''258'''| '''PI2'''| style="text-align: left;"|| '''35'''|-| '''272'''| '''PI16'''| style="text-align: left;"|| '''37'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''39'''|}{| class="wikitable" style="width:390px;margin-right: 20px;text-align: center;"|-
| '''Pin'''
| '''Function'''
| '''GPIO NO.'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''3.3V'''
| '''1'''
|
| '''2'''
| '''5V'''
| style="text-align: left;"|
|-
| '''264'''
| '''PI8'''
| '''TWI1-SDA'''
| '''3'''
|
| '''4'''
| '''5V'''
| style="text-align: left;"|
|-
| '''263'''
| '''PI7'''
| '''TWI1-SCL'''
| '''5'''
|
| '''6'''
| '''GND'''
| style="text-align: left;"|
|-
| '''269'''
| '''PI13'''
| '''PWM3/UART4_TX'''
| '''7'''
|
| '''8'''
| '''UART0_TX'''
| '''224'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''GND'''
| '''9'''
|
| '''10'''
| '''UART0_RX'''
| '''225'''
|-
| '''226'''
| '''PH2'''
| '''UART5_TX'''
| '''11'''
|
| '''12'''
| style="text-align: left;"|
| '''257'''
|-
| '''227'''
| '''PH3'''
| '''UART5_RX'''
| '''13'''
|
| '''14'''
| '''GND'''
| style="text-align: left;"|
|-
| '''261'''
| '''PI5'''
| '''TWI0_SCL/UART2_TX'''
| '''15'''
|
| '''16'''
| '''PWM4/UART4_RX'''
| '''270'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''3.3V'''
| '''17'''
|
| '''18'''
| style="text-align: left;"|
| '''228'''
|-
| '''231'''
| '''PH7'''
| '''SPI1_MOSI'''
| '''19'''
|
| '''20'''
| '''GND'''
| style="text-align: left;"|
|-
| '''232'''| '''PH8'''| '''SPI1_MISO'''| '''21'''|| '''<span style="color:#FF0000">22</span>'''| '''<span style="color:#FF0000">TWI0_SDA</span>/UART2_RX'''| '''<span style="color:#FF0000">PI6</span>'''| '''<span style="color:#FF0000">262</span>'''
|-
| '''230'''
| '''PH6'''
| '''SPI1_CLK'''
| '''23'''
|
| '''24'''
| '''SPI1_CS0'''
| '''229'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''GND'''
| '''25'''
|
| '''26'''
| '''SPI1_CS1'''
| '''233'''
|-
| '''266'''| '''PI10'''| '''TWI2-SDA<span style="color:#FF0000">28</UART3_RX'''| '''27'''|| '''28span>'''| '''<span style="color:#FF0000">TWI2-SCL</span>/UART3_TX'''| '''<span style="color:#FF0000">PI9</span>'''| '''<span style="color:#FF0000">265</span>'''
|-
| '''256'''
| '''PI0'''
| style="text-align: left;"|
| '''29'''
|
| '''30'''
| '''GND'''
| style="text-align: left;"|
|-
| '''271'''
| '''PI15'''
| style="text-align: left;"|
| '''31'''
|
| '''32'''
| '''PWM1'''
| '''267'''
|-
| '''268'''
| '''PI12'''
| '''PWM2'''
| '''33'''
|
| '''34'''
| '''GND'''
| style="text-align: left;"|
|-
| '''258'''
| '''PI2'''
| style="text-align: left;"|
| '''35'''
|
| '''36'''
| style="text-align: left;"|
| '''76'''
|-
| '''272'''
| '''PI16'''
| style="text-align: left;"|
| '''37'''
|
| '''38'''
| style="text-align: left;"|
| '''260'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''GND'''
| '''39'''
|
| '''40'''
| style="text-align: left;"|
| '''259'''
|}
</div>
<ol start="2" style="list-style-type: decimal;">
<li><p>i2c is turned off by default in Linux systems and needs to be turned on manually to use it. The opening steps are as follows:</p>
<ol style="list-style-type: lower-alpha;">
<li><p>First run '''orangepi-config'''. Ordinary users remember to add &gt; '''sudo''' permissions.</p>{| class="wikitable" style="width:800px;" |-| <p>orangepi@orangepi:~$ '''sudo orangepi-config'''</p>|}</li>
<li><p>Then select '''System'''</p>
<p>[[File:zero2w-img80.png]]</p></li>
<li><p>Then select '''Hardware'''</p>
<p>[[File:zero2w-img81.png]]</p></li>
<li><p>Then use the keyboard's arrow keys to locate the position shown &gt; in the picture below, and then use the '''space''' to select the &gt; corresponding i2c configuration in the picture below.</p></li></ol></li></ol>
{| class="wikitable" style="width:800px;text-align: center;"
|-
| '''Multiplexing function in 40pin'''
[[File:zero2w-img173.png]]
</ol>
<ol start="5" style="list-style-type: lower-alpha;">
<li><p>Then select <span class="mark">&lt;Save&gt;</span> to save</p>
<li><p>Then select <span class="mark">&lt;Back&gt;</span></p>
<p>[[File:zero2w-img84.png]]</p></li>
<li><p>Then select <span class="mark">&lt;Reboot&gt;</span> to restart the system to make the &gt; configuration take effect.</p>
<p>[[File:zero2w-img85.png]]</p></li></ol>
</li></ol>
<!-- -->
<ol start="3" style="list-style-type: decimal;">
<li><p>After starting the Linux system, first confirm that there is an open i2c device node under <span class="mark">/dev</span></p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:~$ '''ls /dev/i2c-*'''</p>
<p>'''/dev/i2c-*'''</p>
|}{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big>'''注意,这里说的Linux镜像具体指的是从Orange Pi资料下载页面下载的Debian或者Ubuntu这样的Linux发行版镜像。'''</big>|}{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big><p>'''Sometimes the i2c device node and the i2c bus serial number do not correspond one to one. For example, the i2c device node of the i2c1 bus may be /dev/i2c-3.'''</p><p>'''The method to accurately confirm the device node under /dev corresponding to the i2c bus is:'''</p></li></olbig
<!-- --><ol start="3" style="list-style-type: lower-alpha;">
<li><p>'''First run the following command to check the corresponding relationship of i2c'''</p>
<p>orangepi@orangepizero2w:~$ '''ls /sys/devices/platform/soc*/*/i2c-* | grep &quot;i2c-[0-9]&quot;'''</p>
<p>/sys/devices/platform/soc/6000000.hdmi/i2c-2:</p>
<p>/sys/devices/platform/soc/7081400.i2c/i2c-1:</p></li>
<li><p>'''In the above output'''</p></li></ol>
<!-- -->
<ol start="4" style="list-style-type: lower-alpha;">
<li><p>002000 is the register base address of the i2c0 bus, and i2c-0 shown behind it is its corresponding i2c device node</p></li>
<li><p>5002400 is the register base address of the i2c1 bus, and i2c-3 shown behind it is its corresponding i2c device node</p></li>
<li><p>5002800 is the register base address of the i2c2 bus, and i2c-4 shown behind it is its corresponding i2c device node</p></li></ol>
<!li><p>'''In the above output'''</p><ol style="list-style- type: none;"><li><p>a) 5002000 is the register base address of the i2c0 bus, and i2c-0 shown behind it is its corresponding i2c device node</p></li><li><p>b) 5002400 is the register base address of the i2c1 bus, and i2c-3 shown behind it is its corresponding i2c device node</p></li><li><p>c) 5002800 is the register base address of the i2c2 bus, and i2c-4 shown behind it is its corresponding i2c device node</p></li></ol></li></ol>|}</li></ol>
<ol start="4" style="list-style-type: decimal;">
<li><p>Then start testing i2c, first install i2c-tools</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:~$ '''sudo apt-get update'''</p>
<p>orangepi@orangepi:~$ '''sudo''' '''apt-get install -y i2c-tools'''</p>|}</li>
<li><p>Then connect an i2c device to the i2c pin of the 40pin connector. Here we take the DS1307 RTC module as an example.</p>
<p>[[File:zero2w-img178.png]]</p></li>
<li><p>Then use the '''i2cdetect -y x'''command. If the address of the connected i2c device can be detected, it means that the i2c device is connected correctly.</p>
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big>'''<p>'''Note that x in the i2cdetect -y x command needs to be replaced with the serial number of the device node corresponding to the i2c bus.'''</p>'''</li></olbig>|}
[[File:zero2w-img179.png]]
</li></ol>
<ol start="7" style="list-style-type: decimal;">
<li><p>Then you can run the '''ds1307.py''' test program in '''examples''' to read the RTC time</p>
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big><p>'''Note that the x in i2c-x in the following command needs to be replaced with the serial number of the device node corresponding to the i2c bus.'''</p></big>|}{| class="wikitable" style="width:800px;" |-|
<p>root@orangepi:~/wiringOP-Python# '''cd examples'''</p>
<p>root@orangepi:~/wiringOP-Python/examples# '''python3 ds1307.py --device \'''</p>
<p>Thu 2022-06-16 04:35:48</p>
<p>^C</p>
<p>exit</p>|}</li></ol>
<span id="pin-uart-test-1"></span>
 
=== 40pin UART test ===

Navigation menu