User Tools

Site Tools


doc:appunti:hardware:raspberrypi_air

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:appunti:hardware:raspberrypi_air [2017/10/06 00:02] – [Other setup] niccolodoc:appunti:hardware:raspberrypi_air [2018/10/03 06:05] – [Basic Raspbian Setup] niccolo
Line 32: Line 32:
 {{.:raspberrypi:airpi_fritzing-view.png?direct&480|AirPi breadboard view with Fritzing}} {{.:raspberrypi:airpi_fritzing-view.png?direct&480|AirPi breadboard view with Fritzing}}
 {{.:raspberrypi:airpi_components.jpg?direct&480 |AirPi components}} {{.:raspberrypi:airpi_components.jpg?direct&480 |AirPi components}}
 +
 +====== Software setup ======
 +
 +===== Basic Raspbian Setup =====
 +
 +The base system is a **Raspbian GNU/Linux 9**, based on **Debian Stretch**. Some system configurations are accomplished using the **raspi-config** tool, we run at least:
 +
 +  * **Interfacing Options**
 +    * **Enable SSH** to get remote login via SSH.
 +    * **Enable I2C**, on this bus we have the BME280 sensor and the DS3231 clock.
 +    * **Serial**
 +      * **Disable Serial Login Shell**, our software will use the serial line instead.
 +      * **Enable Serial Port**, we have the PMS5003 sensor attached to it.
 +  * **Localisation Options**
 +    * **Change Locale**, choose the locales you nedd (e.g. en_US.UTF-8).
 +    * **Change Timezone**, set the proper timezone. Data timestamps will be stored in UTC time.
 +    * **Change Wi-fi Country**, to use the proper frequencies, etc.
 +  * **Advanced Options**
 +    * **Memory Split: 16**, we use only the text interface of the GPU.
 +    * **Expand Filesystem** (no longer required: Raspbian Stretch does it automatically at first boot).
 +
 +Be sure to have all the latest updates:
 +
 +<code>
 +apt-get update && apt-get upgrade
 +</code>
 +
 +The scripts to run the AirPi station require several **Debian packages**; install them all:
 +
 +<code>
 +apt-get install build-essential busybox-syslogd git i2c-tools \
 +    nginx php7.0-fpm php7.0-sqlite3 \
 +    python-dev python-requests python-smbus python-serial python-tz \
 +    rrdtool snmp snmp-mibs-downloader snmpd sqlite3
 +</code>
 +
 +Because we installed **busybox-syslogd** to get system log facilities, we can remove rsyslog:
 +
 +<code>
 +dpkg --purge rsyslog
 +</code>
 +
 +There are some packeges not strictly required by the AirPi station, but that I find very useful:
 +
 +<code>
 +apt-get install dselect dump mc minicom nmap screen setserial sniffit tcpdump vim
 +</code>
 +
 +Edit **/etc/nginx/sites-available/default** to enable PHP into the Nginx web server, then reload Nginx.
 +===== DS3231 RTC Clock =====
 +
 +If you instelled the Real-Time Clock module edit **/etc/modules** and **/etc/rc.local** as explained in **[[#Enabling RTC at bootstrap]]**, then you should remove the **fake-hwclock** package:
 +
 +<code>
 +vi /etc/modules
 +vi /etc/rc.local
 +dpkg --purge fake-hwclock
 +</code>
 +
 +===== Python Libraries =====
 +
 +The **Adafruit library for the GPIO** lines is required by the Adafruit BME280 library to access I2C bus. It is advisable to install also some packages **from the Raspbian distro**, otherwise the python setup will try to download and install a local version:
 +
 +<code>
 +apt-get install python-dev python-setuptools python-spidev
 +</code>
 +
 +The Adafruit Python library is installed from the Git repository:
 +
 +<code>
 +cd /usr/local/src/
 +git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
 +cd Adafruit_Python_GPIO
 +python setup.py install
 +</code>
 +
 +The setup procedure will download and install also the **Adafruit_PureIO** library. Everything will be installed into the **/usr/local/lib/python2.7/dist-packages/** directory.
 +===== Serial Line =====
 +
 +Setting the serial line via **raspi-config** as exposed above should suffice, for more info see **[[#More on Serial Line (Manual Setup)]]**. The kernel will expose the serial line at bootstrap using the device **/dev/ttyAMA0** (Raspberry Pi 2) or **/dev/serial0** (Raspberry Pi 3). Read the kernel messages using the **dmesg** command.
 +
 +===== AirPi software =====
 +
 +This software collection will bring you:
 +
 +  * The scripts to read sensors data (BME280 and PMS5003).
 +  * The cronjobs to gather data periodically.
 +  * The web interface to display sensors data.
 +  * The configuration web interface.
 +
 +Everything is stored into the **[[https://github.com/RigacciOrg/AirPi|GitHub AirPi repository]]**, there is a Makefile included, which should do the installation.
 +
 +<code>
 +cd /usr/local/src
 +git clone https://github.com/RigacciOrg/AirPi
 +cd AirPi
 +make install-lib
 +make install-config
 +make install-html
 +make install-webconfig
 +</code>
 +
 +Edit the **/etc/airpi/airpi.cfg** configuration file and make sure you have the rights //bme280// **I2C_ADDRESS** and  //pms5003// **DEVICE**. Now you should be able to read the sensors, using these commands:
 +
 +<code>
 +vi /etc/airpi/airpi.cfg
 +/usr/local/lib/airpi/bme280-snmp
 +/usr/local/lib/airpi/pms5003
 +</code>
 +
 +FIXME Configuration using the web interface uses a custom framework, which is not yet released. Everything you change from the **%%http://<station>/config/%%** web pages is not actually applied to the various configuration files. So you have to edit the configuration files stated above, manually.
 +
 +====== Hardware Setup and Test ======
  
 ===== DS3231 RTC Clock ===== ===== DS3231 RTC Clock =====
Line 148: Line 261:
  
 <code> <code>
-apt-get install build-essential python-dev python-smbus git+apt-get install git build-essential python-dev python-smbus python-setuptools python-spidev
 cd /usr/local/src/ cd /usr/local/src/
 git clone https://github.com/adafruit/Adafruit_Python_GPIO.git git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
Line 357: Line 470:
 ==== Export to DXF ==== ==== Export to DXF ====
  
-In OpenSCAD we use the menu //Design// -> //Compile and Render (CGAL)//. If the object is only bi-dimensional it will be rendered with a red outline and cyan filling. Only in this case we will be able to //File// -> //Export// -> //Export as DXF...//.+In OpenSCAD we use the menu //Design// -> //Render//. If the object is only bi-dimensional it will be rendered with a red outline and cyan filling. Only in this case we will be able to //File// -> //Export// -> //Export as DXF...//.
  
 ==== Using Inkscape to add writings, logos and to layout the pieces ==== ==== Using Inkscape to add writings, logos and to layout the pieces ====
Line 376: Line 489:
  
 To lay out the shapes into a single project, you should follow the guidelines of the laser cutting services that you will to use. Generally they **provide some templates** (Inkscape is well supported), which shows you how big is the cutting area, and the stroke and the fill that you have to use. To lay out the shapes into a single project, you should follow the guidelines of the laser cutting services that you will to use. Generally they **provide some templates** (Inkscape is well supported), which shows you how big is the cutting area, and the stroke and the fill that you have to use.
-====== Software setup ====== 
  
-==== Basic Raspbian Setup ====+===== More Software Setup =====
  
-The base system is a **Raspbian GNU/Linux 9**, based on **Debian Stretch**. Some system configurations are accomplished using the **raspi-config** tool, we run at least:+=== SNMP ===
  
-  * **Interfacing Options** +FIXME make configuration to expose sensors values via SNMPD.
-    * **Enable SSH** to get remote login via SSH. +
-    * **Enable I2C**, on this bus we have the BME280 sensor and the DS3231 clock. +
-    * **Serial** +
-      * **Disable Serial Login Shell**, our software will use the serial line instead. +
-      * **Enable Serial Port**, we have the PMS5003 sensor attached to it. +
-  * **Localisation Options** +
-    * **Change Timezone**, set the proper timezone. Data timestamps will be stored in UTC time. +
-    * **Change Wi-fi Country**, to use the proper frequencies, etc. +
-  * **Advanced Options** +
-    * **Memory Split: 16**, we use only the text interface of the GPU. +
-    * **Expand Filesystem** (no longer required: Raspbian Stretch does it automatically at first boot).+
  
-Be sure to have all the latest updates: +<code bash
- +#!/bin/sh 
-<code> +SENSORS="temperature pressure humidity cputemp" 
-apt-get update && apt-get upgrade+SENSORS="$SENSORS pm1.0 pm2.5 pm10 gt00.3um gt00.5um gt01.0um gt02.5um gt05.0um gt10.0um" 
 +for SENSOR in $SENSORS; do 
 +    snmpwalk -v 2c -c public 127.0.0.1 "NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"$SENSOR\"" 
 +done
 </code> </code>
  
-The scripts to run the AirPi station require several **Debian packages**; install them all:+=== Logread Buffer Len ===
  
-<code> +We installed **busybox-syslogd** instead of **rsyslog**, so that the system log is stored into a RAM ring-buffer and thus saving SD card write cyclesIf you want to have a larger memory buffer (e.g2 Mb) put this into **''/etc/default/busybox-syslogd''**:
-apt-get install build-essential busybox-syslogd git i2c-tools \ +
-    nginx php7.0-fpm php7.0-sqlite3 \ +
-    python-dev python-requests python-smbus python-serial python-tz \ +
-    rrdtool snmp snmp-mibs-downloader snmpd sqlite3 vim +
-</code>+
  
-Because we installed **busybox-syslogd** to get system log facilities, we can remove rsyslog:+<file> 
 +SYSLOG_OPTS="-C2048" 
 +</file>
  
-<code> +=== PMS5003 Reset Line ===
-dpkg --purge rsyslog +
-</code>+
  
-There are some packeges not strictly required by the AirPi stationbut that I find very useful:+We used the PMS5003 sensor quite extensively for about 9 months24h/24h with one reading every 15 minutes and sensor sleep in betweenwe never registered a failure. Neverthless the sensors has a RESET pin which can be used just in case. The pin is keept high by an internal pull-up resistor, so we can leave it vacant. In our experience it seems also that we can leave it attached to a Rapspberry's GPIO (we used #17) and leave it not initialized.
  
-<code> +If you need, we have included the script **''/usr/local/lib/airpi/pms5003-gpio-set''**. Run it once at startup to export the GPIO device (i.eit will be accessible under **''/sys/class/gpio/gpio17/''**) and to set it HIGHIn this case the **pms5003** controlling program will try RESET signal if the sensor will became not responsiveJust add the following lines into **''/etc/rc.local''** (before the last line ''exit 0''):
-apt-get install dselect mc minicom nmap screen setserial sniffit tcpdump vim +
-</code> +
- +
-Edit **/etc/nginx/sites-available/default** to enable PHP into the Nginx web server, then reload Nginx. +
-==== DS3231 RTC Clock ==== +
- +
-If you instelled the Real-Time Clock module edit **/etc/modules** and **/etc/rc.local** as explained in **[[#Enabling RTC at bootstrap]]**, then you should remove the **fake-hwclock** package: +
- +
-<code> +
-vi /etc/modules +
-vi /etc/rc.local +
-dpkg --purge fake-hwclock +
-</code> +
- +
-==== Python Libraries ==== +
- +
-The **Adafruit library for the GPIO** lines is required by the Adafruit BME280 library to access I2C bus: +
- +
-<code> +
-cd /usr/local/src/ +
-git clone https://github.com/adafruit/Adafruit_Python_GPIO.git +
-cd Adafruit_Python_GPIO +
-python setup.py install +
-</code> +
- +
-==== Serial Line ==== +
- +
-Setting the serial line via **raspi-config** as exposed above should suffice, for more info see **[[#More on Serial Line (Manual Setup)]]**. The kernel will expose the serial line at bootstrap using the device **/dev/ttyAMA0** (Raspberry Pi 2) or **/dev/serial0** (Raspberry Pi 3). Read the kernel messages using the **dmesg** command. +
-==== AirPi software ==== +
- +
-This software collection will bring you: +
- +
-  * The scripts to read sensors data (BME280 and PMS5003). +
-  * The cronjobs to gather data periodically. +
-  * The web interface to display sensors data. +
-  * The configuration web interface. +
- +
-Everything is stored into the **[[https://github.com/RigacciOrg/AirPi|GitHub AirPi repository]]**, there is Makefile included, which should do the installation. +
- +
-<code> +
-cd /usr/local/src +
-git clone https://github.com/RigacciOrg/AirPi +
-cd AirPi +
-make install-lib +
-make install-config +
-make install-html +
-make install-webconfig +
-</code> +
- +
-Edit the **/etc/airpi/airpi.cfg** configuration file and make sure you have the rights //bme280// **I2C_ADDRESS** and  //pms5003// **DEVICE**. Now you should be able to read the sensors, using these commands: +
- +
-<code> +
-vi /etc/airpi/airpi.cfg +
-/usr/local/lib/airpi/bme280-snmp +
-/usr/local/lib/airpi/pms5003 +
-</code> +
- +
-FIXME Configuration using the web interface uses a custom framework, which is not yet released. Everything you change from the **%%http://<station>/config/%%** web pages is not actually applied to the various configuration files. So you have to edit the configuration files stated above, manually. +
-===== Other setup ===== +
- +
-FIXME SNMPD, logread buffer len, ... +
-==== SNMPD ====+
  
 +<file>
 +# ==== PMS5003 RESET pin ====
 +# Set the GPIO pin to normal HIGH. The controlling program will bring
 +# it down for a short time, if device reset is required.
 +/usr/local/lib/airpi/pms5003-gpio-set high
 +</file>
  
 ===== More on Serial Line (Manual Setup) ===== ===== More on Serial Line (Manual Setup) =====
doc/appunti/hardware/raspberrypi_air.txt · Last modified: 2020/08/14 10:17 by niccolo