For many projects, you just need to see the responds of your sensors immediately. In my project, I had to use several other I2C devices, so I went for the "DM43B04 4 Digit 7 Segment 4 Digit I2C LED Module LED Digital Display Module Tube Module LED Display Module I2C Interface DC 5V/3.3V". No I2C address was given by the distributor, and an I2C scanner got responses from 1 to 127. The chip was labelled AIP650, which is compatible to TM1650. The module was working when alone on the I2C bus, but not in connection with others. I should have read this (german) before. So what I needed was an I2C multiplexer.
The simplest way to do it seemed to be using an SN7432 to disable the SCL signal of the module you actually won't address.
In case you do not find an SN7432 in your box you can go using an SN7402:
And this is how it worked together with a VL53L0X ToF sensor module.
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
#include <TM1650.h>
TM1650 display;
const byte TOF_SEL = A2;
const byte LED_SEL = A3;
#define SENSOR true
#define LED false
void setup() {
Serial.begin(9600);
Serial.println(__FILE__ __TIME__);
pinMode(TOF_SEL, OUTPUT);
pinMode(LED_SEL, OUTPUT);
I2Cselect(LED);
Wire.begin();
display.init();
display.displayString("test");
/* --------------------------- */
I2Cselect(SENSOR);
sensor.setTimeout(500);
if (!sensor.init()) {
Serial.println("Failed to detect and initialize sensor!");
while (true);
}
sensor.setMeasurementTimingBudget(200000);
}
void loop() {
I2Cselect(SENSOR);
int d = sensor.readRangeSingleMillimeters();
d = constrain(d, 0, 1500);
Serial.print(d);
Serial.print(" ");
if (sensor.timeoutOccurred())
Serial.print(" TIMEOUT");
Serial.println();
char buff[6];
itoa(10000 + d, buff, 10);
I2Cselect(LED);
display.displayString(&buff[1]);
delay(100);
}
void I2Cselect(boolean b) {
digitalWrite(TOF_SEL, !b);
digitalWrite(LED_SEL, b);
}
The Correct SolutionI should have known better ... Modules containing a TM1650 controller (and possibly others) can be connected to the I2C pins but they should not. Among that many TM1650 libraries I found only one which supports connection to any pair of two Arduino pins. It was published by a company called Maker Studio. It really works but it is not very comfortable to use it. Essentially functions are missing but they could be added in a short time. You will find my version of that library in the attachments.
Comments
Please log in or sign up to comment.