I2caddress is like the address in your home. Each slave has its own address. Since there is only one master on the line, and the slave can only communicate with the master, the master does not need an address.
There is basically no limit to setting the i2c address, as long as there is no duplication on the same line.
To set the address of the slave board, you only need to execute Wire.begin ("Address"); and the master does not need an address, as long as Wire.begin() is fine.
The following is an example of a slave setting. Set the address of the slave board to 0x12 and upload it to the slave board to execute it.
[pre lang="arduino" line=“1†file=“slave_01.inoâ€]#include “Wire.hâ€
#define SLAVE_ADDRESS 0x12
Void setup() {
Wire.begin (SLAVE_ADDRESS); // join I2C bus as a slave with address 0x12
}
Void loop() {
}[/code]
I2c address scanAfter the slave is created, it is necessary to look at the master if it is found.
The i2c scanner is arguably the most basic example of a master board that can be used to test the existence of connected devices on a line (testing for existence only, not testing its functionality).
The i2c_scanner is also very simple. The master sends a beginTransmission to all addresses and then endTransmission, trying to establish a connection. By entering the address of the slave in the beignTransmission, you can test the device for that address.
If error = 0 (no error), it means that there is device registration at this address.
If rror = 4 (this is the setting of the Wire library, don't ask me why it is 4), that means there may be devices on this address, but there are errors.
Otherwise, there is no device used on behalf of the address.
Here is a simple i2c scanner program:
[pre lang="arduino" line=“1†file=“i2c_scanner.inoâ€]#include “Wire.hâ€
#define SERIAL_BAUD 57600
Void setup()
{
Wire.begin();
Serial.begin(SERIAL_BAUD);
Serial.println("I2C Scanner started");
Serial.println();
}
Void loop()
{
Uint8_t error, i2cAddress, devCount, unCount;
Serial.println("Scanning..");
devCount = 0;
unCount = 0;
for (i2cAddress = 1; i2cAddress "127; i2cAddress ++)
{
Wire.beginTransmission(i2cAddress);
Error = Wire.endTransmission();
If (error == 0)
{
Serial.print("I2C device found at 0x");
If (i2cAddress "16) Serial.print("0");
Serial.println(i2cAddress,HEX);
devCount++;
}
Else if (error==4)
{
Serial.print("Unknow error at 0x");
If (i2cAddress "16) Serial.print("0");
Serial.println(i2cAddress,HEX);
unCount++;
}
}
If (devCount + unCount == 0)
Serial.println("No I2C devices found");
Else {
Serial.print(devCount);
Serial.print("device(s) found");
If (unCount 》 0) {
Serial.print(", and unknown error in â€);
Serial.print(unCount);
Serial.print(" address");
}
Serial.println();
}
Serial.println();
Delay(5000);
}
[/code]
In this example, you should get the following results:
I2C Scanner started
Scanning. .
I2C device found at 0x12
1 device(s) found
The Puff Bar XXL Disposable Vape is one of the new portable and slim devices from the PUFF BAR. It is more exotic and more popular than the previous versions in the puff lineup. The device comes with 1600 puffs. Puff XXL come with 1600 Puffs device that lasts longer than any Puff Disposable E Cigarette on the market, such as puff bar, puff plus etc. The flavour of Puff XXL 1600 Disposable Vape Pen is printed on the front of the packaging, and the colour of the PUFF XXL also indicates puff xxl all flavours.The puff bar xxl features a 1600 puffs, a huge 17350 powered battery and a big 3.5 ml tank. The puff bar xxl vape comes in a rich kinds of flavors.
Tested and formulated according to the Industry standards, puff xxl bar disposable vape is truly a steal for those looking to drop out smoking and finding another safer way. xxl Puff Plus Available in more than 30 refreshing and jolly flavours, leaving your mouth both sweet and cool at the same time.Which is enough to stay satisfied and pleased for the whole day.
Puff Bar Xxl,Puff Bar Xxl Vape,Puff Bar Flavours,Puff Xxl Disposable
Shenzhen Kate Technology Co., Ltd. , https://www.katevape.com