Programming I2C Addres

How to change address from mlx90640 at esp32, im use 2 mlx90640 for esp32 but the address its same

See datasheet section 10.7.3 You write the address to the LSByte of EEPROM address 0x240F. This is then loaded after power on and used as the I2C address. The datasheet isn't particularly clear on any limitations on the addresses used; I'd personally stick close to the default address and use 0x33 for one device and 0x34 for the other one, assuming 0x34 doesn't conflict with anything else on this bus.

do u have a full code?

No, but it seems that the EEPROM can be accessed as if you're writing to a regular I2C address. So in your place I'd try a simple sketch with a Wire.write(0x240f); followed by a Wire.write(0xbe34); Then power down the sensor and power it back up again, see if it responds to a call to I2C address 0x34 (use I2Cscanner).

PS: it might be easier to just use the 2nd I2C bus (Wire1) and connect your second sensor/camera to that one, while leaving both sensors ar their native 0x33 address.

how if i use module expander i2c

That's also an option.

That is explained in

Nick Gammon's very complete I2C tutorial.

quote (there is a picture in the tutorial)
Dedicated I2C expanders

Another (cheaper) approach is to simply use "16-port I/O expander" chips (such as the MCP23017). These connect to an I2C bus and provides 16 digital ports which can be configured as inputs or outputs depending on the chip. Most of these allow you to set some address bits (eg. via jumpers) so you might use 8 of the expanders (if you needed to!) connected to a single I2C line, with addresses like 000, 001, 010 etc.

I have seen these for sale at around $US 1.20, which is pretty cheap.

See this post for an example of driving an LCD screen with an I/O expander chip:

Alternatively, the Atmega328 chip on its own is only $6, so the suggested approach above of using another microprocessor isn't all that expensive an option.

Here is an example of an expander board (the "Centipede"). This uses 4 x MCP23017 chips to give a whopping 64 I/O ports, at the expense of only two pins on the Arduino. This board comes with headers that let you connect cables and run to other boards where you might have measuring devices, or output devices.

You might want to re-read the thread. This is not about adding GPIOs.

This is a theoretical possibility as well, but I wouldn't recommend it, even if only the ESP32 OP uses already has two I2C buses that can be used in parallel. No additional hardware required to use his two I2C devices that share the same address.

1 Like

I quoted Nick on getting I2C addresses. I thought I posted the tutorial link for full context.

I would much rather not add hardware but there's a way to get more devices on the bus. I am curious about I2C addresses, and have seen I2C expanders that are sold and recommended which tells me it's not all so nice!

I've worked on and cleaned up I2C code but the addressing was already done before I got the damned delays out! It'd be nice to know enough if it's My Money buying the parts!

Seems I went X-Y there.

Ahhh. I see.
Well, this seems to be a bit of a special case since we're dealing with a device with software-programmable I2C addresses, which means it's flexible in principle. The question is how practical that flexibility is in the real world!

1 Like

@mateusarjuna23 has been presented with two potential solutions that require no additional hardware (change device's I2C address or use 2nd I2C port on the processor) and one that requires an additional chip (I2C multiplexer). So, far, I've seen no attempt by @mateusarjuna23 to implement any of these.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.