This project provides a unified interface for communicating with I2C, SPI and 1-Wire devices. It supports a wide range of sensors, LED panels, servo drivers, and other devices. The controller can automatically detect known devices on the bus and provide access to these devices through a standard JSON-based API.
- JSON-Schema: All devices define a JSON Schema that can be fetched to enable easy integration of devices for read or write
- Unified JSON-based API: All devices can be accessed and manipulated using a standard API, which exchanges data in JSON format.
- Device Loading: Known devices are automatically loaded and made ready for interaction.
- Generic I2C Device Entries: Each detected device is represented by an
I2CDeviceEntry
instance, which holds all necessary information for interacting with the device. - Generic SPI Device Entries: Can load and access SPI Devices and access by a
SPIDeviceEntry
instance. - 1-Wire Device Entries: Scans and autoloads any 1-wire device found within the filesystems namespace
- I2C Bus Scanning: The controller can automatically scan the I2C bus to detect connected devices.
This document describes the configuration parameters for an SPI device using the deviceConfig
map.
Map<String, Object> deviceConfig = new LinkedHashMap<>();
// Required for SPI Bus Configuration
deviceConfig.put("spiBus", "0"); // Can be 0 to 6
deviceConfig.put("spiChipSelect", "0"); // Either 0, 1 or 2
deviceConfig.put("spiMode", "0"); // Can be 0 to 3
// Device Specific configuration
deviceConfig.put("resolution", "12");
deviceConfig.put("channels", "8");
Map<String, Object> map = new LinkedHashMap<>();
map.put("Mcp3y0x", deviceConfig);
deviceBusManager.getSpiBusManager().configureDevices(map);
The deviceConfig
map contains the following parameters for the SPI device:
- Type:
String
- Description: Specifies the SPI bus number. This parameter determines the specific SPI bus to which the device is connected.
- Example:
"0"
- Type:
String
- Description: Specifies the chip select (CS) address of the device. This parameter determines the specific CS address to which the device is assigned.
- Example:
"5"
- Type:
String
- Description: Specifies the resolution of the SPI device. This parameter determines the number of bits used for digital representation in the device.
- Example:
"12"
- Type:
String
- Description: Specifies the number of channels available on the SPI device. This parameter determines the number of independent input or output channels supported by the device.
- Example:
"8"
To configure an SPI device, you can use the configureDevices
method provided by the SPI device manager. Pass the configuration map as an argument to the method.
Example usage:
deviceBusManager.getSpiBusManager().configureDevices(map);
Before using the controller, make sure all your I2C devices are connected correctly.
-
Start the Controller: Use the provided script to start the controller.
./startController.sh
-
Scan the I2C Bus: The controller will automatically scan the I2C bus and load all known devices.
-
Access Devices via the API: You can access and manipulate devices using the provided API. Data is exchanged in JSON format.
-
Add More Devices: You can add support for more devices by implementing the
I2CDeviceEntry
interface and adding the new device to the controller's known devices.For example, to read data from a device:
curl http://localhost:8080/device/i2c/read?address=0x28
This would return a JSON object with the device's data:
{ "data": { "temperature": 25.6, "humidity": 45.2 } }
Sensors | Manufacturer | Description | Functionality | Datasheet |
---|---|---|---|---|
DS3231 | Maxim Integrated | Real-time clock | - Provides accurate timekeeping and calendar functions | Datasheet |
AM2315 | Aosong | Temperature and humidity sensor | - Measures ambient temperature and humidity | Datasheet |
AM2320 | Aosong | Temperature and humidity sensor | - Measures ambient temperature and humidity | Datasheet |
AS3935 | AMS | Lightning sensor | - Detects and provides information on nearby lightning activity | Datasheet |
BH1750 | ROHM | LUX sensor | - Measures ambient light in lux | Datasheet |
BMP280 | Bosch Sensortec | Pressure and temperature sensor | - Measures atmospheric pressure and ambient temperature | Datasheet |
BNO055 | Bosch Sensortec | 9-axis absolute orientation sensor | - Provides precise orientation, acceleration, and magnetic data | Datasheet |
INA219 | Texas Instruments | High-side current sensor | - Measures high-side current and voltage | Datasheet |
PMSA003I | Plantower | Particulate matter sensor | - Detects and measures particulate matter in the air | Datasheet |
TLS2561 | Texas Instruments | Digital light sensor | - Measures ambient light intensity | Datasheet |
DFRobot Gas Sensors | DFRobot | Gas detection sensors | - Detects various gases such as Carbon Monoxide, Hydrogen Sulfide, Alcohol, Oxygen, Hydrogen, Ozone, Sulfur Dioxide, Nitrogen Dioxide, Hydrogen Chloride, Chlorine, Hydrogen Fluoride, and Phosphine | Datasheet |
LPS25 | STMicroelectronics | MEMS pressure and temperature sensor | Measures barometric pressure | Datasheet |
LPS35HW | STMicroelectronics | MEMS pressure and temperature sensor | Measures barometric pressure | Datasheet |
Device | Manufacturer | Description | Functionality | Datasheet |
---|---|---|---|---|
PCA9685 | NXP | 16-channel PWM controller | Controls up to 16 channels of PWM output | Datasheet |
Adafruit 7-Segment | Adafruit | I2C Quad Segment Alphanumeric LED Display | Displays alphanumeric characters and symbols | Product Page |
Adafruit Alphanumeric | Adafruit | I2C Quad Alphanumeric LED Backpack | Displays alphanumeric characters and symbols | Product Page |
Device | Manufacturer | Description | Functionality | Datasheet |
---|---|---|---|---|
AT24C32/64 | Atmel | 4KB or 8KB serial EEPROM | Can read or write 4K or 8K data | Datasheet |
|
Device | Manufacturer | Description | Functionality | Datasheet |
---|---|---|---|---|
MCP3004 | Microchip | 10-bit Analog-to-Digital Converter - 4 channels | Converts analog signals to digital with 10-bit resolution | Datasheet |
MCP3204 | Microchip | 12-bit Analog-to-Digital Converter - 4 channels | Converts analog signals to digital with 12-bit resolution | Datasheet |
MCP3008 | Microchip | 10-bit Analog-to-Digital Converter - 8 channels | Converts analog signals to digital with 10-bit resolution | Datasheet |
MCP3208 | Microchip | 12-bit Analog-to-Digital Converter - 8 channels | Converts analog signals to digital with 12-bit resolution | Datasheet |
Contributions are always welcome! Please read the contributing guidelines first.