…………………………….. DELETED ……..
sadsdfaefssadfsedfsegfvsegfvsegfvsgfv
…………………………….. DELETED ……..
sadsdfaefssadfsedfsegfvsegfvsegfvsgfv
Did you try using pip to install the required libraries in a venv, or did you go direct into the root install of Python?
I use the BME280, BME680, MAX30205, MCP9808, and HDC1010 in various applications and the basic approach would be the same for any of them. I do tend to write my own drivers, as the Adafruit Python drivers have been somewhat abandoned in favor of their own "flavor" of Python.
I go direct into the root install of Python
@ pilovis Could you please add targeted hardware to subject line e.g. Raspberry if there is some place left?
Why do you want to restrict this to Raspi? Every device where I2C is accessible should do.
You are right, I couldn't imagine someone is poking around at a standard router without proper pin header for I²C ;- )
Does "all" routers have an I²C bus? Estimated around %?
I'm not sure, but the inexpensive GL.iNet devices have a header for I2C called out. At under US$20 in a case, they're an interesting platform.
Hi Jeff,
yes I took a short look at https://www.gl-inet.com/ and indeed nearly all are marked with "GPIO header" although I don't ckecked if this also means I2C bus.
As a "normal" usr my first thoughts where centered around standard consumer routers. I superficial ckecked for R7800 and found nothing so probably it's a niche for enthusiasts, nevertheless not uninteresting e.g. for some people to add a LCD matrix display for router status.
What surely would have a heavy commercial impact would be some kind of controllable RGB lightning for routers ;- )
I agree that many consumer devices can be "challenging" to find the right pads, if they exist at all. I'll be checking my Archer C7's unpopulated header one of these days.
On the GL.iNet, for example, https://openwrt.org/toh/gl.inet/gl.inet_gl-ar300m-lite shows two GPIOs "tagged" as I2C and two "tagged" for serial.
For this project I used the TP-Link TL WDR4300 (TL-WDR3600 is almost the same) and OpenWrt 18.06.1
Any Router that supports OpenWrt 18.06.1 and has at least two free GPIO pins availabe and 32 Mbytes or more of ram, is OK for this project.
if you don't want to open your router and solder any pin inside, simply buy an USB to I2C dongle and use kmod-i2c-tiny-usb 

@pilovis
many thanks for this and other tutorials
Do you know how to read the data using sysfs, i.e. without python?
I’m familiar with these devices and you need to access them with “raw” I2C commands. There also are some complex calculations required to convert the data read from the registers to meaningful values. If you wanted “turn-key” access from OpenWrt, a dedicated microcontroller with a USB interface would be my recommendation.
There is another option - with kmod-iio-bmp280-i2c driver the ready-to-use data are available through sysfs. While I was able to read the sensor data, I'm also getting some weird error messages in the log. That's why I was curios if anyone else tried that way.
echo "bmp180 0x77" > /sys/bus/i2c/devices/i2c-0/new_device
# cat /sys/bus/iio/devices/iio\:device0/in_temp_input
19500
log:
[ 2118.066798] bmp280 0-0077: non-rising trigger given for EOC interrupt, trying to enforce it
[ 2118.075672] i2c i2c-0: new_device: Instantiated device bmp180 at 0x77
[ 2185.639232] bmp280 0-0077: timeout waiting for completion
There is also a kmod-bmp085-i2c driver, but I have no idea on how to use it.
OK, sorted out with another sensor - BME280.
Initial configuration:
insmod i2c-gpio-custom bus0=0,2,3
modprobe bmp280
modprobe bmp280-i2c
echo "bme280 0x76" > /sys/bus/i2c/devices/i2c-0/new_device
reading temperature:
# cat /sys/bus/iio/devices/iio\:device0/in_temp_input
20560
Here is a log:
Custom GPIO-based I2C driver version 0.1.1
i2c-gpio i2c-gpio.0: using pins 2 (SDA) and 3 (SCL)
i2c i2c-0: new_device: Instantiated device bme280 at 0x76