These libraries are required for programming models with the RX Controller.
After the imports, the components are initialized using various functions. These initializations are crucial to configure the system correctly and to ensure that each sensor and actuator is ready for operation. Without these initializations, the program would not be able to communicate with the hardware components and operations such as reading sensors or activating actuators would not be possible.
rx_factory.init_controller_factory()
rx_factory.init_input_factory()
rx_factory.init_output_factory()
rx_factory.init_motor_factory()
rx_factory.init_i2c_factory()
The fischertechnik RX Controller enables the connection and disconnection of various sensors and actuators to different ports and thus offers great flexibility in the design and construction of projects. The following describes the types of sensors that can be connected, how they are configured and initialized, and what they are used for.
Initialization:
RX_I5_photo_resistor = rx_factory.input_factory.create_photo_resistor(controller, 5)
Initialization:
RX_I7_ultrasonic_distance_meter = rx_factory.input_factory.create_ultrasonic_distance_meter(controller, 7)
Initialization:
RX_I6_color_sensor = rx_factory.input_factory.create_color_sensor(controller, 6)
Initialization:
RX_I1_ntc_resistor = rx_factory.input_factory.create_ntc_resistor(controller, 1)
Initialization:
RX_I3_trail_follower = rx_factory.input_factory.create_trail_follower(controller, 3)
RX_I4_trail_follower = rx_factory.input_factory.create_trail_follower(controller, 4)
Initialization:
RX_I4_photo_transistor = rx_factory.input_factory.create_photo_transistor(controller, 4)
Initialization:
RX_I8_mini_switch = rx_factory.input_factory.create_mini_switch(controller, 8)
Initialization:
RX_I2_reed_switch = rx_factory.input_factory.create_mini_switch(controller, 2)
Initialization:
RX_I2C_1_gesture_sensor = rx_factory.i2c_factory.create_gesture_sensor(controller, 1)
Initialization:
RX_I2C_2_environment_sensor = rx_factory.i2c_factory.create_environment_sensor(controller, 2)
Initialization:
RX_I2C_3_combined_sensor = rx_factory.i2c_factory.create_combined_sensor(controller, 3)
Summary: For each sensor type, the correct port must be selected based on the application configuration and the sensor initialized using the factories provided. This initial configuration is essential to ensure that the sensors function correctly and provide accurate data. In the next part, we will cover how to use these sensors and interpret their data.
The sensors connected to the fischertechnik RX Controller can be divided into digital and analog sensors depending on the type of signal generated and the information provided. The following describes what information can be obtained from these sensors and how this data can be used.
Digital sensors: Digital sensors provide discrete values, usually "on" or "off" (1 or 0), "open" or "closed" or some other form of binary value.
Analog sensors: Analog sensors provide continuous values that can vary within a certain range and represent physical quantities such as light, temperature, distance, etc.
Summary: Digital and analog sensors provide a variety of data that can be used to interact with the environment, control automated systems or collect data for analysis. Digital sensors provide binary values that are useful for simple control decisions, while analog sensors provide continuous values that enable precise measurement of physical quantities. The correct interpretation of this data is crucial for the efficient functioning of any system based on the fischertechnik RX Controller.
The RGB gesture sensor is an advanced device that combines several functions in a single chip. It can recognize gestures and measure ambient light, RGB light (red, green, blue) and proximity. Below you will find a detailed description of the sensor's capabilities, the available functions and the values that can be retrieved.
Initialization of the sensor: In order to use the RGB gas sensor, it must first be initialized correctly. This is done by creating an instance of the sensor via the I2C factory.
RX_I2C_1_gesture_sensor = rx_factory.i2c_factory.create_gesture_sensor(controller, 1)
This code creates the object RX_I2C_1_gesture_sensor, which is assigned to I2C port 1. After initialization, you can start configuring the various functions and retrieve data from the sensor.
Gesture recognition: The RGB gesture sensor can recognize various hand movements such as up, down, left and right. This function is useful for controlling devices without physical contact.
Activation of gesture recognition:
RX_I2C_1_gesture_sensor.enable_gesture()
Recall recognized gestures:
gesture = RX_I2C_1_gesture_sensor.get_gesture()
print(gesture)
Deactivation of gesture recognition:
RX_I2C_1_gesture_sensor.disable_gesture()
Measurement of RGB light: The sensor can detect the intensity of the light in the RGB color components and thus provide an accurate representation of the ambient light color.
Activation of the light sensor:
RX_I2C_1_gesture_sensor.enable_light()
Retrieve RGB data:
rgb_values = RX_I2C_1_gesture_sensor.get_rgb() print(f "Red: {rgb_values[0]}, Green: {rgb_values[1]}, Blue: {rgb_values[2]}")
Retrieve HEX values:
hex_value = RX_I2C_1_gesture_sensor.get_hex()
print(f "Color in HEX format: {hex_value}")
Retrieve HSV values:
hsv_values = RX_I2C_1_gesture_sensor.get_hsv()
print(f "Hue: {hsv_values[0]}, saturation: {hsv_values[1]}, value: {hsv_values[2]}")
Deactivation of the light sensor:
RX_I2C_1_gesture_sensor.disable_light()
Ambient light measurement: In addition to RGB measurements, the sensor can provide an ambient light measurement, which is useful for determining the general lighting conditions.
Calling up the ambient light:
ambient_light = RX_I2C_1_gesture_sensor.get_ambient()
print(f "Ambient light: {ambient_light}")
Proximity detection: The RGB gas sensor can detect the proximity of objects based on the amount of reflected infrared light.
Activation of proximity detection:
RX_I2C_1_gesture_sensor.enable_proximity()
Retrieve approximate data:
proximity = RX_I2C_1_gesture_sensor.get_proximity()
print(f "Proximity: {proximity}")
Deactivation of proximity detection:
RX_I2C_1_gesture_sensor.disable_proximity()
Summary: The RGB gesture sensor is a versatile device that combines gesture detection, RGB light and ambient light measurement and proximity detection in a single chip. This makes it ideal for applications with advanced user interfaces, automatic light adaptation and security systems. The sensor provides a rich interface to interact with the environment through detailed and precise data.
The BME680 is an integrated environmental sensor that can measure various parameters such as temperature, relative humidity, air pressure and air quality. These features make it ideal for environmental monitoring applications, HVAC systems, weather stations and other IoT (Internet of Things) devices. The capabilities of the sensor, its initialization and the acquisition of the various data are described below.
Initializing the Environmental Sensor: In order to use the environmental sensor, it must first be initialized correctly. This is done by creating an instance of the sensor via the I2C factory.
RX_I2C_2_environment_sensor = rx_factory.i2c_factory.create_environment_sensor(controller, 2)
This code creates the object RX_I2C_2_environment_sensor, which is assigned to I2C port 2. After initialization, the environmental data provided by the sensor can be retrieved.
Functions of the sensor
Retrieve the temperature:
temperature = RX_I2C_2_environment_sensor.get_temperature()
print(f "Temperature: {temperature} °C")
Retrieve the relative humidity:
humidity = RX_I2C_2_environment_sensor.get_humidity()
print(f"Relative humidity: {humidity} %")
Retrieve the air pressure:
pressure = RX_I2C_2_environment_sensor.get_pressure()
print(f"Air pressure: {pressure} hPa")
Retrieve the air quality as a number:
iaq_number = RX_I2C_2_environment_sensor.get_indoor_air_quality_as_number()
print(f"Air quality (IAQ): {iaq_number}")
Retrieve the air quality as text:
iaq_text = RX_I2C_2_environment_sensor.get_indoor_air_quality_as_text()
print(f"Air quality (IAQ): {iaq_text}")
Calibration of the sensor:
RX_I2C_2_environment_sensor.calibrate()
Check the need for calibration:
needs_calibration = RX_I2C_2_environment_sensor.needs_calibration()
if needs_calibration:
print("The sensor requires calibration.")
Summary: The environmental sensor provides a comprehensive range of environmental measurements, including temperature, humidity, air pressure and air quality. This data is critical for a variety of applications, from environmental monitoring to smart HVAC systems. The ability to measure air quality is particularly important in environments where indoor air quality can affect health and well-being.
The combination sensor, which includes an accelerometer, a gyroscope and a magnetometer. This device provides measurements of motion, orientation and magnetic field and is ideal for applications in robotics, motion detection, device stabilization and navigation. Below you will find a detailed description of the functions, initialization and data acquisition of this sensor.
Initializing the combination sensor To use the combination sensor, all its components (accelerometer, magnetometer, gyroscope) must be initialized with the desired settings.
controller.RX_I2C_3_combined_sensor.init_accelerometer(2, 8, False)
controller.RX_I2C_3_combined_sensor.init_magnetometer(25)
controller.RX_I2C_3_combined_sensor.init_gyrometer(250, 12, False)
Data Acquisition of the Combination Sensor
Calling up the acceleration:
acc_x = controller.RX_I2C_3_combined_sensor.get_acceleration_x()
acc_y = controller.RX_I2C_3_combined_sensor.get_acceleration_y()
acc_z = controller.RX_I2C_3_combined_sensor.get_acceleration_z()
print(f"Acceleration - X: {acc_x} g, Y: {acc_y} g, Z: {acc_z} g")
Retrieve the magnetic field:
mag_x = controller.RX_I2C_3_combined_sensor.get_magnetic_field_x()
mag_y = controller.RX_I2C_3_combined_sensor.get_magnetic_field_y()
mag_z = controller.RX_I2C_3_combined_sensor.get_magnetic_field_z()
print(f"Magnetic Field - X: {mag_x} µT, Y: {mag_y} µT, Z: {mag_z} µT")
Retrieve the rotation speed:
rot_x = controller.RX_I2C_3_combined_sensor.get_rotation_x()
rot_y = controller.RX_I2C_3_combined_sensor.get_rotation_y()
rot_z = controller.RX_I2C_3_combined_sensor.get_rotation_z()
print(f"Rotation Speed - X: {rot_x} °/s, Y: {rot_y} °/s, Z: {rot_z} °/s")
Summary: The combination sensor provides a comprehensive solution for measuring motion, orientation and magnetic field. With capabilities to measure acceleration, magnetic field and rotational speed, this sensor is extremely useful for applications in robotics, navigation, device stabilization and other motion control systems. Each of the measurements captured provides a detailed understanding of the connected device's state and motion, facilitating a wide range of applications from fall detection to position and orientation sensing.