Power switch Function
The ProdBoard has an onboard power switch using the the same design as Nanomesher Hackable Raspberry Pi Power Switch
For software installation, please follow one of below:
- “Software Installation” section in Hackable Raspberry Pi Switch Quick Start
- “Software Installation” section in https://nanomesher.com/diy/raspberry-pi-support/
Enable i2c bus
sudo raspi-config
Samples Code
Examples for using the ProdBoard are here.
In order to use the examples, you will need to install the following dependent libraries.
Install essential libraries
sudo apt-get update
sudo apt-get install build-essential i2c-tools python-pip python-dev python-smbus git
GPIO Python Library
sudo apt-get install python-dev python-rpi.gpio
Luma.OLED Python Library
ProdBoard uses i2c OLED display with SH1106 controller.
Library Info: https://pypi.python.org/pypi/luma.oled
Install Instructions: http://luma-oled.readthedocs.io/en/latest/install.html
More display examples from Luma.OLED: https://github.com/rm-hull/luma.examples
To run the examples from Luma.OLED, dont forget to use “-d sh1106” option.
cd /home/pi/luma.examples python examples/pi_logo.py -d sh1106
Download Nanomesher ProdBoard Samples
cd ~ git clone https://github.com/nanomesher/Nanomesher_ProdBoard.git
LIRC Setup
LIRC is a package that allows you to decode and send infra-red signals of many (but not all) commonly used remote controls.
LIRCDemo.py required LIRC to be installed.
To be able to run the example, do the following (assuming Raspbian):
- Install LIRC
sudo apt-get install lirc
- In /boot/config.txt, add/edit the following line
dtoverlay=lirc-rpi,gpio_in_pin=17,gpio_out_pin=22
- Setup for i2c communications with display and LIRC for infrared in /etc/modules
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with “#” are ignored. i2c-dev lirc_dev lirc_rpi gpio_in_pin=17 gpio_out_pin=22
- If using Raspbian Stretch or after, in /etc/lirc/hardware.conf , add/edit the following line
LIRCD_ARGS="--uinput --listen" LOAD_MODULES=true DRIVER="default" DEVICE="/dev/lirc0" MODULES="lirc_rpi"
- If using Raspbian Stretch or after, in /etc/lirc/lirc_options.conf, add/edit the following line
[lircd] nodaemon = False #driver = devinput #device = auto driver = default device = /dev/lirc0
- Copy lirc settings files to /etc/lirc/
cd ~/Nanomesher_ProdBoard/lirc sudo cp -rT ~/Nanomesher_ProdBoard/lirc /etc/lirc
- Reboot
- Test your lirc set up with irw and pressing your remote buttons
- Install LIRC python library: https://pypi.python.org/pypi/python-lirc/ or use this method if you dont want to use python-lirc.
#For python 3.x
sudo apt-get install python3-lirc
#For python 2.x
sudo apt-get install python-lirc
List of Sample Code
Important: To enable the LEDs and Buttons. You will need to switch on the dip switches on the prodboard
- ledDemo.py – Blink the LED Twice
- SimpleButton.py – Simple polling button example
- LIRCDemo.py – Using the remote control (top row , first 2 buttons from the left) to control the LED
- DisplayDemo.py – Display IP address on the on screen display
- EventBasedButtonsDemo.py – Using event driven approach to listen to button press
- ProdBoardDemo.py – Using polling approach to listen to button press, with top 2 buttons triggering LED to toggle
- WeatherDemo.py – Display humidity and temperature using SHT31 sensor. Need SHT31 library. See Weather Sensors section.
Weather Sensors
All weather sensors below uses i2c bus and needs to be enabled.
BMP180 Library – For Pressure Sensor
The recommended library is Adafruit_Python_BMP
cd ~ git clone https://github.com/adafruit/Adafruit_Python_BMP.git cd Adafruit_Python_BMP sudo python setup.py install
SHT31 Library – For Temperature and Humidity Sensor
The recommended library is Adafruit_Python_SHT31
cd ~ git clone https://github.com/ralf1070/Adafruit_Python_SHT31.git cd Adafruit_Python_SHT31 sudo python setup.py install
CCS811 Air Quality Sensor – For air quality Sensor
- Due to limitations of CCS811 sensor, the i2c port needs to be slowed down
sudo nano /boot/config.txt
- Add this line to the file
dtparam=i2c_baudrate=10000
- Reboot, and then install the library
sudo pip install Adafruit_CCS811
- Run i2cdetect to detect the i2c address
i2cdetect -y 1
*** If you have a CCS811 sensor (Blue colour pcb) which has address 0x5B, change the settings in the library
sudo nano /usr/local/lib/python2.7/dist-packages/Adafruit_CCS811/Adafruit_CCS811.py
Change CCS811_ADDRESS to 0x5B, save (Write out) and exit