If you have any questions, please contact fischertechnik-technik@fischer.de
The fischertechnik RX controller has 2 connections labeled EXT1 and EXT2 (see 4 in the picture). Both connections are connected to the internal I2C bus, see RX Controller Operating Instructions.
RX Controller | 6-pin Assigment |
---|---|
Warning
- Power supply for I2C is 3.3V
RX controller uses CircuitPython which is based on Python. However, some commands differ considerably from Python. The basic functions for I2C are listed here.
Important
- To ensure that no other function uses the I2C bus, use
i2c.trylock()
andi2c.unlock()
- Use
i2c.deinit()
to turn off the I2C bus - If you use the
with
statement (context manager), it automatically locks and unlocks the I2C interface
import board
import busio
from adafruit_bus_device.i2c_device import I2CDevice
from fischertechnik.logging import log as print
async def i2cScan():
i2c = busio.I2C(board.SCL1, board.SDA1, frequency=400000)
while not i2c.try_lock():
pass
try:
#print("I2C addresses found:", [hex(device_address) for device_address in i2c.scan()],)
i2cList = i2c.scan()
finally: # unlock the i2c bus
i2c.unlock()
i2c.deinit()
return i2cList
async def i2cWriteBuffer(i2cAdr, write_buffer):
with busio.I2C(board.SCL1, board.SDA1, frequency=400000) as i2c:
with I2CDevice(i2c, i2cAdr) as device:
device.write(bytes(write_buffer))
async def i2cReadBuffer(i2cAdr, read_length):
read_buffer = bytearray(read_length)
with busio.I2C(board.SCL1, board.SDA1, frequency=400000) as i2c:
with I2CDevice(i2c, i2cAdr) as device:
device.readinto(read_buffer)
return read_buffer
async def i2cWriteReadBuffer(i2cAdr, write_buffer, read_length):
read_buffer = bytearray(read_length)
with busio.I2C(board.SCL1, board.SDA1, frequency=400000) as i2c:
with I2CDevice(i2c, i2cAdr) as device:
device.write_then_readinto(bytes(write_buffer), read_buffer)
return read_buffer
Some examples of external I2c modules already exist. These examples can be imported with the ROBO Pro Coding app.
sensor chip | ROBO Pro Coding program name |
---|---|
test_RX_i2c_device_scan | |
test_RX_i2c_device_template | |
APDS9960 | test_RX_i2c_device_apds9960 |
Further examples of I2C modules can be found in a ROBO Pro Coding project called ft_Controller_I2C. The documentation (German) was created by the user elssner. Many thanks for the very detailed examples!
Please note that with the RX firmware 0.23.1 it is not possible to access from Blockly and Python at the same time, as the I2C instance cannot be used simultaneously.
If the following error occurs, the RX controller must be switched off and on again.
Traceback (most recent call last):
File "asyncio/core.py", line 246, in run_until_complete
File "user/mainCode.py", line 100, in run
ValueError: SCL1 in use
In RX firmware 0.27.0 it is now possible to access from Blockly and Python at the same time. Use the following function to get the I2CDevice:
global i2c
import fischertechnik.factories as rx_factory
if rx_factory.i2c_factory is None:
rx_factory.init_i2c_factory()
i2c = rx_factory.i2c_factory.get_i2c_bus(instance)._i2c
Some I2C addresses are already reserved, see e.g. here or www.i2c-bus.org. All fischertechnik I2C sensors are listed in the table below.
Sensor | Item Number | I2C Address | sensor chip | RX Controller | TXT 4.0 Controller | TXT Controller |
---|---|---|---|---|---|---|
Environmental sensor 6-pin | 182974 | 0x76 | BME680 | Yes | Yes | |
Environmental sensor 10-pin | 167358 | 0x76 | BME680 | Yes, I2C-Adapter 186150 | Yes, I2C-Adapter 186150 | Yes (C/C++) |
RGB gesture sensor 6-pin | 183267 | 0x39 | APDS9960 | Yes | Yes | |
RGB gesture sensor 10-pin | 186705 | 0x39 | APDS9960 | Yes, I2C-Adapter 186150 | Yes, I2C-Adapter 186150 | Yes |
Kombisensor 6-pin | 201257 | 0x68 | ICM42670 (GYRO + ACC) | Yes (FW>=0.26.2) | Yes | |
0x30 | MMC5603 (MAG) | ... | ... | |||
Kombisensor 10-pin | 158402 | 0x10 | BMX055 (MAG) | Yes, I2C-Adapter 186150 | Yes | |
0x18 | BMX055 (ACC) | ... | ... | |||
0x68 | BMX055 (GYRO) | ... | ... | |||
RGB color sensor | 213965 | 0x14 | Knobloch | Yes (txtapi>=6.4.0) | ||
NFC module | - | 0x24 | PN532 NFC RFID Module | Yes | Yes (C/C++) | |
AGV charging module | - | 0x26 | Knobloch | Yes | ||
RESERVED | 0x8 | RESERVED |
Warning
- Power supply for I2C is 3.3V
- No separate power supply at the plug