Table of Contents
Introduction
Once the elevator starts moving, we need to know at which point the elevator should land and for that we need to measure the distance of the elevator from a fixed point. Since we will be designing for three elevators that will run side by side, we should aim to reduce the number of wirings as well. In this post, I will cover how we are going to measure the distance and the sensor arrangement.
TOF sensor
Typically, we could use Ultrasonic sensor, but I felt they are slightly bulky for this project and it needs a separate 5v for each node. So, I decided to use ToF sensors. ToF sensors are lot smaller, consumes less power and can be operated over I2C.

ToF sensors works in a way similar to ultrasonic sensor, except it measures the time it takes for IR/light to strike the target and reflect back.

In this project we will be using a VL530x based ToF sensor which can measure up to 200cm. We just need the sensor to read the distance accurately up to 40cm.
Interfacing multiple TOF sensor
Since we need 3 ToF sensors, we can’t interface them all directly we won’t have enough FlexComm peripheral for UART. So, I decided to use an I2C multiplexer. Using which we can connect up to 8 I2C devices.

My initial plan was to interface the I2C multiplexer with A153 board, unfortunately I could not establish the I2C communication between them. I have tried to port different libraries available, but none of them seemed to work.
Using ESP32 for interfacing with i2c
Since I have already planned to use ESP32 to transmit lift telemetry, I have decided to expand the scope of ESP32 by interfacing it with ToF sensors and transmit the distances to N236 board using UART.


Failed Communication attempts
SPI interface
Even though I know it will take lots of wiring, I decided to give a try for SPI communication between N236 (master) and A153 (slave) boards. Although I could get the communication working between them, there was a lot of workarounds and required master to initiate the conversation always. Which became a bothersome point, I decided to drop A153 altogether. N236 is powerful enough to do the work of A153 board which originally just required monitoring sensors and GPIOs.
CAN interfacing
N236 board comes with a CAN transceiver. Since ESP32 supports CAN communication, I wanted to interface them together. I was actually surprised to see that I could recreate the "LoopBack example" provided by NXP. Unfortunately, I ran into issue with ESP32 this time. ESP32 has introduced some breaking changes with their latest release and my old which I used as reference started throwing multiple build errors. At the end, I decided to keep the communication simple and decided to go with UART interface.
Conclusion
This is my final forum post. So far, we have seen how the boards work, what are all the issues I have faced, and how to mitigate them. Throughout these trials and errors, I have to make changes in the original architecture I planned and adapt according to the new issues. In the last project article, we will conclude with our final demo model.
