I’m currently using a VL6180X distance sensor attached to an Adafruit Trinket 3V. The connection works pretty well. Basically because there is no serial port I get a signal with the LED which is pulsing as soon as there is an object in the range of the distance sensor. Still there are two problems I have to handle right now.
Sometimes the VL6180X doesn’t start as soon as I connect it to the microcontroller. This can be fixed if I switch the power off and on multiple times on the microcontroller. But because this will be very difficult to do in the final arrangement I would like to know if there is some sort of restart option for the VL6180X.
2)This gets a little complicated, but:
The next step would be to send the distance data from the trinket to another Microcontroller (for instance an arduino micro) that can read the value from the trinket via an I2C Bus and print the Data in the serial monitor.
(I know it would be easier to connect the sensor directly to the arduino, but I need it to work with other microcontrollers that aren’t compatible with the sensor and I encountered the same problems regardless which microcontroller I’m using, wheter Arduino or something else)
Because of the nature of the I2C protocoll (at least I think so, correct me if I’m wrong) it is impossible to establish a connection between two masters. So I have to use two different I2C Busses (one where the trinket is a master and reads the data from the sensor and one where the trinket is a slave and sends the data to an arduino).
This is possible by bitbanging two digital pins and it works fine for some minutes, afterwards it just stops. So maybe it doesn’t work so well.
Another approach I would like to test, if its possible to do everything with the original I2C Bus, by switching between two different addresses and switching between slave and master after each interval. I know that probably it has to do with the microcontroller rather than the distance sensor, so I will try to look around in the internet. My question is if the sensor still works if I switch connection or if it has to have a continuous sstable connection to work properly.
The second question is very specific, but it would be a great help if someone knew an approach or a solution to this problem. Thanks in advance!