Other Parts Discussed in Thread: TXS0108E
I have been trying to connect the DLP NIRscan Nano EVM ("sensor" from now on) to an Arduino Mega over pins 3 (UART4 receive) and 4 (UART4 transmit) of the J3 connector as explained in the sensor's datasheet. Since the Arduino operates at 5v and the sensor at 3.3v, I used the ZHITING TXS0108E bidirectional logic level converter to prevent damage. The logic level converter I chose supports UART, and I could verify this myself by having the Arduino communicate over UART with a Raspberry 3B+ (also 3.3v) with the same exact circuit, so I am pretty sure that's not the issue.
The full circuit is visible in the images below:
- the Arduino hardware serial port 1 is used, just like in the code below (but I also tried other ports just in case).
- the Arduino ground and the sensor ground are connected together.
- the logic level converter is enabled since OE is connected to Arduino's 5v (with a pull-down resistor to ground); connecting it to the sensor's 3.3v does not make a difference.
- the sensor RX passes through the logic level converter and at the end connects to the Arduino TX, and viceversa; just in case I tried swapping the cables to no avail.
This is the bare-minimum code I uploaded to the Arduino (I already tried multiple variations, none of which working). As already said, it works well if I connect a Raspberry instead of the sensor. The code tries to send a "read scan time command" according to the tables in the documentation. I never got any response from the sensor, not even an error packet: reading from the serial port always returns -1 as if no data is available.
void setup() {
// open serial port in 8N1 mode: 8 data bits, no parity, 1 stop bit
// also: 115200 bits per second, no flow control, 1ms of timeout
Serial1.begin(115200, SERIAL_8N1);
Serial1.setTimeout(1); // I also tried removing this to no avail
delay(500);
uint8_t values[] = {
// A B C D
65, 66, 67, 68,
// checksum
62, 0, 0, 0,
// flags 00000011: reply requested and read mode
3,
// first and only packet of sequence
0,
// packet length: 2 bytes for command byte and group byte
2, 0,
// command byte 0x37, group byte 0x02 (NNO_CMD_READ_SCAN_TIME)
55, 2,
// D C B A
68, 67, 66, 65
};
for (uint8_t v : values) {
Serial1.write(v);
}
}
void loop() {
uint8_t received = Serial1.read();
// here received is always equal to -1 no matter how much I wait
}
The sensor works normally when using the DLP NIRscan Nano GUI. Using that same tool I updated the sensor's firmware and spectrum library to the latest versions downloaded from here, but my circuit did not work neither before nor after the update.
I found a possibly similar thread here: if you think my post is a duplicate feel free to tell me and I'll post all of my information on that other thread.