<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title><![CDATA[Dobrica Pavlinušić's random unstructured stuff: Orange Pi Plus 2]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?orange_pi_plus_2</link>
<description></description>
<pubDate>Sat, 02 Jan 2021 12:41:37 -0000</pubDate>
<webMaster>root@saturn.ffzg.hr</webMaster>
<generator>Socialtext Workspace v2.19.0.2</generator>

<item>
<title><![CDATA[Orange Pi Plus 2]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?orange_pi_plus_2</link>
<description><![CDATA[<div>Creator: Dobrica Pavlinušić</div><hr/><div>Tags: arm</div><hr/><div class="wiki">
<span class="nlw_phrase"><a href="https://saturn.ffzg.hr/rot13/index.cgi/iio.conf?action=attachments_download;page_name=orange_pi_plus_2;id=20210102124137-0-5384">iio.conf</a><!-- wiki: {file: iio.conf} --></span><br /><br /><span class="nlw_phrase"><img alt="orangepiplus2_info.jpg" src="https://saturn.ffzg.hr/rot13/index.cgi/orangepiplus2_info.jpg?action=attachments_download;page_name=orange_pi_plus_2;id=20191209172612-5-13730" /><!-- wiki: {image: orangepiplus2_info.jpg} --></span><br /><br /><p>
<a target="_blank" title="(external link)" href="http://www.orangepi.org/orangepiplus2/">http://www.orangepi.org/orangepiplus2/</a></p>
<p>
<a target="_blank" title="(external link)" href="https://www.armbian.com/orange-pi-plus-2/">https://www.armbian.com/orange-pi-plus-2/</a></p>
<p>
SoC	H3 @ 1.2GHz[1]<br />
DRAM	2GiB DDR3 @ ?MHz (H5TC4G83AFR-PBA)<br />
NAND	16GB EMMC Flash (in 2016 KLMAG2GEND-B031 but now slower KLMAG2WEPD-B031)<br />
Power	DC 5V @ 2A (4.0mm/1.7mm barrel plug - centre positive)<br />
Features<br />
Video	HDMI (HDCP, CEC), CVBS<br />
Audio	3.5 mm Jack, HDMI, Microphone<br />
Network	10/100/1000Mbps Ethernet (Realtek RTL8211E), WiFi 802.11 b/g/n (Realtek RTL8189ETV)<br />
Storage	�SD (max 64GB), SATA 2.0 (via GL830 USB-to-SATA bridge, +5V power on JST XH 2.5mm connector)<br />
USB	4 USB 2.0 Host (via FE1.1s hub), 1 USB 2.0 OTG</p>
<h1 id="bme280_i2c_temperature_humidity_pressure">bme280 i2c temperature/humidity/pressure</h1>
<pre>
/home/dpavlin/linux-gpio-pinout/overlay-load.sh /boot/dtb-`uname -r`/overlay/*h3*i2c0*

root@opip:/home/dpavlin/linux-gpio-pinout# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --
</pre>
<br /><p>
Check i2c address in datasheet</p>
<p>
Connecting SDO to GND results in slave<br />
address 1110110 (0x76); connection it to V DDIO results in slave address 1110111 (0x77)</p>
<pre>
root@opip:/home/dpavlin/linux-gpio-pinout# zgrep BMP280 /proc/config.gz
CONFIG_BMP280=m
CONFIG_BMP280_I2C=m
CONFIG_BMP280_SPI=m

root@opip:/home/dpavlin/linux-gpio-pinout# echo bmp280 0x76 &gt; /sys/bus/i2c/devices/i2c-2/new_device
root@opip:/home/dpavlin/linux-gpio-pinout# [Sat Jan  2 11:43:58 2021] i2c i2c-2: new_device: Instantiated device bmp280 at 0x76
[Sat Jan  2 11:43:58 2021] bmp280 2-0076: supply vddd not found, using dummy regulator
[Sat Jan  2 11:43:58 2021] bmp280 2-0076: supply vdda not found, using dummy regulator
[Sat Jan  2 11:43:58 2021] bmp280 2-0076: bad chip id: expected 58 got 60
[Sat Jan  2 11:43:58 2021] bmp280: probe of 2-0076 failed with error -22

</pre>
<br /><p>
So it's not BMP280, but BME280.</p>
<p>
Using <a target="_blank" title="(external link)" href="https://www.raspberrypi-spy.co.uk/2016/07/using-bme280-i2c-temperature-pressure-sensor-in-python/">https://www.raspberrypi-spy.co.uk/2016/07/using-bme280-i2c-temperature-pressure-sensor-in-python/</a><br />
I downloaded and modified for python3 <span class="nlw_phrase"><a href="https://saturn.ffzg.hr/rot13/index.cgi/bme280.py?action=attachments_download;page_name=orange_pi_plus_2;id=20210102122720-0-6473">bme280.py</a><!-- wiki: {file: bme280.py} --></span></p>
<pre>
root@opip:/home/dpavlin# ./bme280.py
Chip ID : 96
Version : 0
Temperature : 24.65 C
Pressure : 998.4304559219445 hPa
Humidity : 41.458674890198445 %e
</pre>
<br /><p>
So let's try with correct sensor name</p>
<pre>
root@opip:/sys/bus/i2c/devices/i2c-2# echo bme280 0x76 &gt; /sys/bus/i2c/devices/i2c-2/new_device
[Sat Jan  2 12:32:01 2021] bmp280 2-0076: supply vddd not found, using dummy regulator
[Sat Jan  2 12:32:01 2021] bmp280 2-0076: supply vdda not found, using dummy regulator
[Sat Jan  2 12:32:01 2021] i2c i2c-2: new_device: Instantiated device bme280 at 0x76

root@opip:~# apt install libiio-utils

root@opip:~# iio_info
Library version: 0.16 (git tag: v0.16)
Compiled with backends: local xml ip usb serial
IIO context created with local backend.
Backend version: 0.16 (git tag: v0.16)
Backend description string: Linux opip 5.10.0-rc7-sunxi #20.11.3 SMP Fri Dec 11 21:18:30 CET 2020 armv7l
IIO context has 1 attributes:
	local,kernel: 5.10.0-rc7-sunxi
IIO context has 1 devices:
	iio:device0: bme280
		3 channels found:
			humidityrelative:  (input)
			2 channel-specific attributes found:
				attr  0: input value: 40775
				attr  1: oversampling_ratio value: 16
			pressure:  (input)
			2 channel-specific attributes found:
				attr  0: input value: 99.809761718
				attr  1: oversampling_ratio value: 16
			temp:  (input)
			2 channel-specific attributes found:
				attr  0: input value: 25350
				attr  1: oversampling_ratio value: 2
</pre>
<br /><h2 id="collect_using_telegraf">collect using telegraf</h2>
<pre>
root@opip:/etc/telegraf/telegraf.d# ../telegraf --config iio.conf --test
2021-01-02T12:39:39Z I! Starting Telegraf
&gt; iio,host=opip,name=bme280 humidityrelative=39.934,pressure=99.801214843,temperature=25.66 1609591179000000000
</pre>
</div>
<hr/><div>Attachments: bme280.py, iio.conf, orangepiplus2_info.jpg</div>]]></description>
<author>Dobrica Pavlinu&#x161;i&#x107;</author>
<category>arm</category>
<guid isPermaLink="true">https://saturn.ffzg.hr/rot13/index.cgi?orange_pi_plus_2</guid>
<pubDate>Sat, 02 Jan 2021 12:41:37 -0000</pubDate>
</item>
</channel>
</rss>