Tests:
Communicates with devices connected to the local system using the I2C bus.
This adapter should work on Linux boards like the Raspberry Pi, C.H.I.P., BeagleBone or Intel Edison.
Before installing, please read the installation guide of the i2c-bus module.
Especially make sure, that you have properly configured and enabled I2C on your system (if needed):
After you have enabled and configured I2C, you can install this adapter via ioBroker Admin:
Depending on the age of your ioBroker installation, the iobroker
user (or under whatever user ioBroker is running) might not have the proper rights to access I2C.
If you have connected a device and it is not showing up in the configuration screen, please make sure the user is added to the i2c
group:
sudo usermod -aG i2c iobroker
Note: if don't have a standard installation, replace iobroker
in the above command with the user running your ioBroker installation (check with ps
).
This is the number of the I2C bus/adapter to open, 0 for /dev/i2c-0, 1 for /dev/i2c-1, ...
On Raspberry Pi 3 and 4B, this is "1".
The following devices are currently supported. The numbers in parenthesis are the known addresses of the device in hexadecimal format (without the read bit).
Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor using the ATSAMD10 chip.
Texas Instruments 4x 3.3-kSPS, 12-Bit ADCs with Internal Reference.
Texas Instruments 4x 860-SPS, 16-Bit ADCs with Internal Reference.
Bosch Digital Humidity, Pressure and Temperature Sensor.
MaxSonar GY-US42 Sonar Rangefinder 20 - 720cm.
Honeywell 3-Axis Digital Compass IC.
Texas Instruments Zero-Drift, Bidirectional Current/Power Monitor.
Microchip 8-Bit I/O Expander with Serial Interface.
Microchip 16-Bit I/O Expander with Serial Interface.
Microchip 18-Bit, 2-Channel Analog-to-Digital Converter with On-Board Reference.
Microchip 18-Bit, 2-Channel Analog-to-Digital Converter with On-Board Reference.
Microchip 18-Bit, 4-Channel Analog-to-Digital Converter with On-Board Reference.
Microchip 16-Bit, 2-Channel Analog-to-Digital Converter with On-Board Reference.
Microchip 16-Bit, 2-Channel Analog-to-Digital Converter with On-Board Reference.
Microchip 16-Bit, 4-Channel Analog-to-Digital Converter with On-Board Reference.
Microchip 12-Bit Digital-to-Analog Converter with EEPROM Memory.
Texas Instruments Remote 8-Bit I/O Expander for I2C Bus.
Texas Instruments Remote 8-Bit I/O Expander for I2C Bus.
Adafruit PCA9685 breakout board for 16-channel 12 bit PWM. Adapter focused on using the 16 channels from 0..4095 as LED dimmer. Can drive many LEDs when PWM (and GND) is attached to a N-channel Mosfet module e.g. based on D4184. Connect LED GND to the MOSFET and +12/24/n V to PSU.
QST 3-Axis Magnetic Sensor.
Sensirion SHT3x Humidity and Temperature Sensor.
Devantech Ultrasonic Ranger Finder 16 - 600cm.
Semtech World’s Lowest Voltage Level Shifting GPIO with LED Driver for 4 channels.
Semtech World’s Lowest Voltage Level Shifting GPIO with LED Driver and Keypad Engine for 8 channels.
Semtech World’s Lowest Voltage Level Shifting GPIO with LED Driver and Keypad Engine for 16 channels.
Generic I2C device. Registers can be configured depending on the hardware.
Supported commands for sendTo
in scripts are search
, read
and write
.
search
takes as message the bus number and returns a JSON string of an array of found addresses on the bus.
read
takes as message an object containing the address and optional the register and number of bytes to read. It returns a buffer with the read data.
write
takes as message an object containing the address, the data as buffer and optional the register to write. It returns the written buffer on success.
sendTo('i2c.0', 'search', 1, (ret) => {
log('Ret: ' + ret, 'info');
});
sendTo(
'i2c.0',
'read',
{
address: 0x40,
register: 0x02,
bytes: 2,
},
(ret) => {
log('Ret: ' + ret.inspect(), 'info');
},
);
sendTo(
'i2c.0',
'write',
{
address: 0x40,
register: 0x00,
data: Buffer.from([0x44, 0x27]),
},
(ret) => {
log('Ret: ' + ret.inspect(), 'info');
},
);
Compatibility has been tested with Raspberry Pi 3 and 4B.
Please use the GitHub repository to report any bugs or request new features.
If you require a missing devcies, please provide the type of IC (brand, model, ...) and its address(es) as reported in the adapter configuration.
This repository is set up so development can be done using VS Code and Devcontainer. Simply open the root folder of this repository with VS Code and and acknowledge to switch to Devcontainer.
If you are developing on a desktop PC and want to test I2C on a SBC (e.g. a Raspberry Pi), you can do the following:
"serverPort"
setting in "native"
: "native": {
"busNumber": 1,
"serverPort": 5555
}
"clientAddress"
setting in "native"
: "native": {
"busNumber": 1,
"clientAddress": "http://<your-ip-address>:5555/rpc"
}
Keep in mind that the RPC server is completely unsecured, so this should only be used for development inside a secure network!
read
and write
commands in scripts using sendTo
.This project is based on the i2c-bus NPM module. Thanks to fivdi for his great module!
Copyright 2021 UncleSamSwiss
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
The BME280 code is based on https://github.com/skylarstein/bme280-sensor:
MIT License
Copyright (c) 2016 Skylar Stein
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The ADS1x15 code is based on https://github.com/alphacharlie/node-ads1x15/blob/master/index.js
node-ads1x15 itself is based on https://github.com/adafruit/Adafruit_Python_ADS1x15
The MIT License (MIT)
Copyright (c) 2016 Adafruit Industries
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The PCA9685 code is based on https://github.com/adafruit/Adafruit_Python_PCA9685/blob/master/Adafruit_PCA968/PCA9685.py
The MIT License (MIT)
Copyright (c) 2016 Adafruit Industries Author: Tony DiCola
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Also based on: https://github.com/tessel/servo-pca9685/blob/master/index.js
Copyright 2014 Technical Machine, Inc. See the COPYRIGHT file at the top-level directory of this distribution.
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. This file may not be copied, modified, or distributed except according to those terms.