TakkTile products rely on I2C communication to transfer the pressure data from the sensors. The two main components which use this digital protocol are micro-controller and the MEMS barometers. The micro-controller is Attiny24 and the barometric sensor is MPL115A2.
MEMS barometer - MPL115A2
The important note here is that chip-select pin of the sensor (Pin 5 - RST) should be driven high. Only then the communication interface of the sensor is activated and the pressure and temperature data can be retrieved.
I2C Commands (simplified for communication)
- Device Address + write bit “To Write” = 0xC0
- Device Address + read bit “To Read” = 0xC1
- Command to Write “Convert Pressure and Temperature” = 0x12
- Command to Read “Pressure ADC High byte” = 0x00
- Command to Read “Pressure ADC Low byte” = 0x01
- Command to Read “Temperature ADC High byte” = 0x02
- Command to Read “Temperature ADC Low byte” = 0x03
- Command to Read “Coefficient data byte 1 High byte” = 0x04
The flow of steps required to read the data is summarized in the table below:
|1||Start data conversion||0xC0 0x12|
|2||Wait for data to be processed. Datasheet says 1.6ms|
|3||Read the pressure and the temperature||0xC0 0x00 0xC1 (and read 4 bytes)|
The Attiny24 micro-controller is implemented to perform the chip-select function, i.e. select the sensor which should be sampled. The micro-controller listens to the I2C lines and has its digital outputs connected to the chip-select pins of the MEMS Barometer. When the chip-select pin of the sensor is driven high by the micro-controller it's communication interface is activated and then pressure and temperature data can be retrieved.
The I2C address of the micro-controller is assigned to it when it is powered up. There could be up to 8 micro-controllers on the same line.
For example, the TakkStrip is using three dedicated pins for address assignment.
The address corresponds to the following table:
Enabling the sensors
Once the micro-controller is powered, it listens to the commands on the data lines. A custom approach was developed here to optimize the communications. In this case the I/O command is encrypted into the address. As such, the upper nibble of the address is used for addressing and the lower nibble is the command for enabling or disabling the sensor.
Even numbers are reserved for switching the sensors ON.
Odd numbers are reserved for switching the sensors OFF.
The table to illustrate the assigned commands:
|* where x is the TakkStrip address.|
Switching ON the first sensor of the TakkStrip with address 6x the master will need to send 60.
Switching OFF the first sensor, the master will need to send 61.
Enabling/Disabling all the sensors
MPL115 requires a command to start converting the pressure data. The conversion process takes about 1.6ms. An optimized approach was developed here where the micro-controller activates all the sensors together. Then the host can send the "start conversion" command, and all the activated sensors will start performing the command. Finally, the sensors could be read in a series.
The commands which are used to enable/disable all the sensors are:
ON - 0x0C
OFF - 0x0D
The process to read from a few sensors then becomes:
|1||Activate all the sensors||0x0C|
|2||Start data conversion||0xC0 0x12|
|3||Disable the sensors||0x0D|
|4||Wait for data to be processed. Datasheet says 1.6ms|
|5||Activate the first sensor (micro-controller address is 0x3x)||0x30|
|6||Read the pressure and the temperature||0xC0 0x00 0xC1 (and read 4 bytes)|
|7||Deactivate the first sensor||0x31|
|8||Activate the second sensor (micro-controller address is 0x3x)||0x32|
|9||Read the pressure and the temperature||0xC0 0x00 0xC1 (and read 4 bytes)|
|10||Deactivate the second sensor||0x33|
Contact us: here