Major site overhaul: resources hub, content migration, new blog posts, forms
- Redesign /resources as sectioned hub with category pages - Migrate 645 Squarespace CDN images to local /images/content/ - Create 9 new news/blog posts with event photos - Fix blog post slugs (rename gibberish filenames) - Rename Design Blog to Design Blogs across site - Remove education page, replace with Platform in nav - Redesign rover repair request form with dynamic rover entries - Add school search combobox to contact, store, and repair forms - Extract shared KNOWN_SCHOOLS data - Make /rover-expansion-3d-printing dynamically pull from MDX - Add related resources sections to product pages - Fix homepage broken /quote links to /store - Store page: sample kit cards, inline quote builder, mailing list opt-in
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: "How to use I2C"
|
||||
date: "2024-12-31"
|
||||
categories: ["Guides"]
|
||||
categories: ["Advanced Guides"]
|
||||
tags: ["Guide", "Guides"]
|
||||
excerpt: "I2C (I-squared-C) is a communication technique used between multiple integrated circuits. The Micromelon Rover can use the I2C protocol to communicate with other I2C-compatible devices. This can expand the rover's capabilities, like using external se"
|
||||
featuredImage: "/images/resources/how-to-use-i2c.PNG"
|
||||
@@ -13,13 +13,13 @@ I2C (I-squared-C) is a communication technique used between multiple integrated
|
||||
|
||||
Before using I2C on the rover, it is recommended to understand how it works at a basic level.
|
||||
|
||||

|
||||

|
||||
|
||||
*Credit: Scott Campbell - Basics of the I2C Communication Protocol*
|
||||
|
||||
I2C communication is used between a master and a slave IC (integrated circuit). The clock line (SCL) synchronises the timing of the data sent over the data line (SDA). The data can be sent back and forth between master and slave, but this cannot happen simultaneously. We refer to this as half-duplex. Multiple slaves and masters can be used with I2C, but all require a unique address.
|
||||
|
||||

|
||||

|
||||
|
||||
*Credit: Scott Campbell - Basics of the I2C Communication Protocol*
|
||||
|
||||
@@ -29,21 +29,21 @@ I2C devices have an address, which is used as an identifier. They also have regi
|
||||
|
||||
#### Writing to an I2C slave:
|
||||
|
||||

|
||||

|
||||
|
||||
*Credit: Texas Instruments - Understanding the I2C Bus*
|
||||
|
||||
When writing to an I2C device, the master first sends the start signal, followed by the 7-bit address of the slave. Next comes the read/write bit, 0 if the master will write and 1 if it will read. The master waits until the slave sends an acknowledge (ACK) bit on the SDA line. Then the master sends through the register address it wishes to write to. Again, the slave must acknowledge the request. The master then transmits through the data, with the slave sending an ACK on each byte. The stop condition is sent to end the transmission.
|
||||
|
||||
**Start and End condition - **To signal a start, SDA is changed from high to low while SCL stays high. SDA changes from low to high while SCL remains high to signal a stop.
|
||||
**Start and End condition -** To signal a start, SDA is changed from high to low while SCL stays high. SDA changes from low to high while SCL remains high to signal a stop.
|
||||
|
||||
**Read and Write bit - **This specifies whether the master wants to read or write data. Read is a 1, and write a 0.
|
||||
**Read and Write bit -** This specifies whether the master wants to read or write data. Read is a 1, and write a 0.
|
||||
|
||||
**ACK/NACK bit - **These signal the device has received or has not received a byte of data. ACK is 0 and NACK is 1.
|
||||
**ACK/NACK bit -** These signal the device has received or has not received a byte of data. ACK is 0 and NACK is 1.
|
||||
|
||||
#### Reading from an I2C slave:
|
||||
|
||||

|
||||

|
||||
|
||||
*Credit: Texas Instruments - Understanding the I2C Bus*
|
||||
|
||||
@@ -55,25 +55,25 @@ The master sends the start condition again, followed by the slave's address and
|
||||
|
||||
Fortunately, the protocols are taken care of when using I2C on the rover. To wire an I2C device correctly to the rover, use the pinout below and connect SDA and SCL to the respective SDA and SCL on the device you are connecting to.
|
||||
|
||||

|
||||

|
||||
|
||||
Once connected, the coding is pretty simple regarding reading, writing and scanning.
|
||||
|
||||
#### I2C Scan:
|
||||
|
||||

|
||||

|
||||
|
||||
This code returns a list containing the addresses of all I2C devices currently connected to the rover.
|
||||
|
||||
#### I2C Read:
|
||||
|
||||

|
||||

|
||||
|
||||
This block reads from a slave device. You must specify the slave address, the register to read from, and the number of bytes to read. This code returns a list containing each byte of data read from the slave device. The data you wish to read can be greater than 1 byte.
|
||||
|
||||
#### I2C Write:
|
||||
|
||||

|
||||

|
||||
|
||||
This block writes to a slave device. You must specify the slave address, the register to write to, the data you wish to write, and the data length in bytes. The data you wish to write can be greater than 1 byte.
|
||||
|
||||
@@ -81,16 +81,12 @@ This block writes to a slave device. You must specify the slave address, the reg
|
||||
|
||||
#### Rover with PCA9685 Servo Driver:
|
||||
|
||||

|
||||

|
||||
|
||||
The PCA9686 servo driver is a device that allows 16 servos to be controlled using I2C communication. With this device attached, the rover can control up to 18 servos.
|
||||
|
||||
#### Rover with Arduino Nano:
|
||||
|
||||

|
||||

|
||||
|
||||
The Arduino Nano is a highly adaptable microcontroller with many I/O ports. The default I2C ports on the Nano are A4 (SDA) and A5 (SCL). The rover can use I2C to easily communicate with an Arduino. This enables the rover to access all of the I/O ports on the Nano and use these as external sensor ports. In the example above, the rover uses an Arduino Nano to receive data from a line sensor array. For more info on this project, click the button below:
|
||||
|
||||
[
|
||||
Showcase: Rover and Arduino Line Follow
|
||||
](showcase-rover-and-arduino-line-follow)
|
||||
The Arduino Nano is a highly adaptable microcontroller with many I/O ports. The default I2C ports on the Nano are A4 (SDA) and A5 (SCL). The rover can use I2C to easily communicate with an Arduino. This enables the rover to access all of the I/O ports on the Nano and use these as external sensor ports. In the example above, the rover uses an Arduino Nano to receive data from a line sensor array. For more info on this project, click the button below:[Showcase: Rover and Arduino Line Follow](showcase-rover-and-arduino-line-follow)
|
||||
|
||||
Reference in New Issue
Block a user