Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Lato-Heavy.ttf
harness.jpeg
live_temp_hum_bme280.py
readme.md
realtime.temps.png
remote.temps.jpg
remote_temps_humid.py
schematics.png

readme.md

I2C Bus: BME280 sensor & 0.96" OLED Display

For the folks who want to support super tiny displays, this directory has info how to show up to two temperatures and humidity from your YANPIWS install like this:

As well, you can show real time temperature if you have both a display and a sensor hooked up. This will up date every 100ms. No YANPIWS web server install needed:

Thanks to raspberrypi-spy for much of this script. Thanks to code electron for images and tecno info!

Requirements

Hardware

These python scripts assume you're using I2C compatible hardware. For my development, I used (prices as of Oct 2019):

Software

  • Python3
  • I2C bus enabled (eg raspbi-config or armbian-config)
  • Adafruit-GPIO Drivers for OLED installed

Quick start

  1. You should already have you screen set up and working. You should know the I2C bus, either 1 or 0, after running i2cdetect -l. As well, you should know the two device IDs after running i2cdetect 0 or i2cdetect 1. These are likley 76 for temp sensor & 3c for display.

  2. The remote_temps_humid.py script takes the following arguments:

    usage: remote_temps_humid.py [--bus] [--remote_ip]
                                 [--temp_id1] [--temp_id2]
    
    

    It defaults to --bus/-b of 0 and the --remote_ip/-ip should be where your main YANPIWS install is. The --temp_id1/-id1 and --temp_id1/-id2 are from IDs of the temps in your config.csv. A complete call might look like this:

    python3 remote_temps_humid.py -b 0 -ip 10.0.40.219 -id1 96 -id2 97
  3. live_temp_hum_bme280.py takes the following arguments:

    usage: live_temp_hum_bme280.py [--bus BUS] [--device DEVICE]
    

    It defaults to --bus/-b of 1 and --device/-d of 0x76. Likely if you're on a Pi, you won't need to change anything, so you can just call it with out any arguments.

  4. For ensure this runs at boot runs every minute, add one of these to your crontab, but be sure to update the variables and paths accordingly!

    */1 * * * * cd /var/www/html/I2C.bme280.oled; /usr/bin/python3 remote_temps_humid.py -b 0 -ip 10.0.40.219 -id1 96 -id2 97 
    */1 * * * * cd /var/www/html/I2C.bme280.oled; /usr/bin/python3 live_temp_hum_bme280.py 
    

If you need more help - read up on the "Long Start" below.

Long Start

These are my notes for doing an install on an Orange Pi Zero.

  1. You'll need to wire your devices in parallel. I did it with a harness I made like this with spliced, soldered and heat-shrink tubed Breadboard Jumper Wires:
  2. Connect the harness to the correct I2C pins like this (Thanks to code electron for image):
  3. download "bionic" from armbian
  4. write image to microsd card, put in device
  5. plugin in ethernet and boot up device
  6. check your DHCP server for "orangepizero" IP
  7. login first time with root/1234: ssh root@192.168.68.104
  8. change root password to something good
  9. create your user, use good password
  10. add your ssh key via ssh-copy-id -i PATH_TO_KEY USER@IP
  11. edit /etc/ssh/sshd_conf to PasswordAuthentication no. extra bonus PermitRootLogin no
  12. systemctl restart sshd
  13. apt update;apt dist-upgrade -y
  14. run armbian-config and do:
    • personal -> timezone -> change time zone to be correct
    • system -> hardware -> check 3 i2c boxes, save
  15. reboot
  16. ssh back in and run: apt install build-essential python3-pip python3-setuptools python3-smbus autoconf libtool pkg-config python3-pil python3-dev i2c-tools
  17. run pip3 install wheel
  18. run sudo pip3 install --upgrade setuptools
  19. install adafruit drivers
    1. git clone https://github.com/adafruit/Adafruit_Blinka.git
    2. cd Adafruit_Blinka
    3. python3 setup.py install
    4. pip3 install Adafruit-GPIO
    5. pip3 install Adafruit_SSD1306
    6. pip3 install Adafruit_BBIO
  20. go home cd
  21. make apache dir (even though we don't have apache): mkdir -p /var/www
  22. check out YANPIWS there git clone https://github.com/Ths2-9Y-LqJt6/YANPIWS.git /var/www/html
  23. make sure we can see the three I2C buses:
    i2cdetect -l
    i2c-1   i2c             mv64xxx_i2c adapter                     I2C adapter
    i2c-2   i2c             mv64xxx_i2c adapter                     I2C adapter
    i2c-0   i2c             mv64xxx_i2c adapter                     I2C adapter
  24. After wiring up your devices, make sure they show up:
    i2cdetect -y 0
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    70: -- -- -- -- -- -- 76 -- 
  25. add crontab entries per above with the correct flags/paths
  26. enjoy!
You can’t perform that action at this time.