element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
In the Air Design Challenge
  • Challenges & Projects
  • Design Challenges
  • In the Air Design Challenge
  • More
  • Cancel
In the Air Design Challenge
Blog AirMobile - 28 - Finalizing OpenHAB setup on BBB
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: amgalbu
  • Date Created: 19 Feb 2015 1:57 PM Date Created
  • Views 856 views
  • Likes 3 likes
  • Comments 5 comments
  • iot_distributed
  • openhab
  • in_the_air
  • bbb
  • bb_black
Related
Recommended

AirMobile - 28 - Finalizing OpenHAB setup on BBB

amgalbu
amgalbu
19 Feb 2015

It's time to finalize the OpenHAB setup on the BeagleBoneBlack, which will collect and analyze data stored on the AirVantage cloud.

The steps required to complete the installation are

Install web server

A web server is required to serve the files for the web page that shows collected data. I chose lighttpd because it's lightweight and easy to configure.

To install lighttpd, simply type

 

sudo apt-get install lighttpd

 

First, let's check that your configuration is ok:


$ lighttpd -t -f lighttpd.conf

 

Now let's start the server for testing:


$ lighttpd -D -f lighttpd.conf

 

I edited the config file in /etc/lighttpd/lighttpd.conf


server.document-root = "/var/www/airmobile/pages/" 
server.port = 8082

mimetype.assign = (
  ".html" => "text/html", 
  ".js" => "application/javascript", 
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png" 
)

index-file.names = ( "index.html" )

 

Then I started the webserver by typing


/etc/init.d/lighttpd start

 

Copy web page files

AirMobile web files (HTML and Javascript) have been copied to


"/var/www/airmobile/pages"

 

 

Copy bindings

The binding bundles developed (namely gpio and iarvantage) needs to be copied to the openhab/addons folder. To create the bundle, right click on the project and select Export. In the Export wizard, select Deployable  plugins and fragments.

image

 

In the next step, enter the folder where you want the plugin to be generated and check the options as shown

image

image

 

During the deployment, I experienced a Java ClassNotFoundException. I was not able to completely understand the reason for that exception, and the only way to solve this issue was to create a bundle for each jar the AirVantage binding depends on (okhttp, Gson, scribe and org.json). I created bundle projects by selecting File -> New -> Project -> Bundle and following the wizard steps

image

 

Finally, I added the bundles to the Import-Package section of manifest file of the AirVantage binding.


Manifest-Version: 1.0
Bundle-Vendor: openHAB.org
Bundle-Version: 1.6.0.qualifier
Bundle-Activator: org.openhab.binding.airvantage.internal.AirVantageActivator
Bundle-ManifestVersion: 2
Bundle-Description: This is the AirVantage binding of the open Home Automation Bus (openHAB)
Import-Package: 
 com.google.gson,
 com.google.gson.reflect,
 com.squareup.okhttp,
 org.scribe.builder,
 org.json,
 org.apache.commons.lang,
 org.codehaus.jackson,
 org.codehaus.jackson.map,
 org.openhab.core.binding,
 org.openhab.core.events,
 org.openhab.core.items,
 org.openhab.core.library.items,
 org.openhab.core.library.types,
 org.openhab.core.types,
 org.openhab.model.item.binding,
 org.osgi.framework,
 org.osgi.service.cm,
 org.osgi.service.component,
 org.osgi.service.event,
 org.slf4j
Export-Package: org.openhab.binding.airvantage
Bundle-DocURL: http://www.openhab.org
Service-Component: OSGI-INF/binding.xml, OSGI-INF/genericbindingprovider.xml
Bundle-ClassPath: .,
 lib\scribe-1.3.5.jar,
 lib\gson-2.2.4-sources.jar,
 lib\json-20140107.jar,
 lib\okhttp-1.2.1-sources.jar

Define the items and the sitemap

First, a set of items that show the last sensor readings are defined


Number Home_Temperature "Temperature [%.1f]" <temperature> {airvantage="system=AirMobile1,measure=temperature"}
Number Home_Humidity "Humidity [%.0f]" <humidity> {airvantage="system=AirMobile1,measure=humidity"}
Number Home_CO "CO [%.3f]" <co> {airvantage="system=AirMobile1,measure=co"}
Number Home_NO2 "NO2 [%.3f]" <no2> {airvantage="system=AirMobile1,measure=no2"}
Number Home_Dust "Dust [%.0f]" <dust> {airvantage="system=AirMobile1,measure=dust"}
Number Home_AQI "AQI [%.2f]" <gauge>

 

Second, a set of items that show pollutant levels at a certain location (in this case the location of a public garden where I typically go for a run) are define

 

Number PB_Temperature "Temperature [%.1f]" <temperature> {airvantage="system=AirMobile1,measure=temperature"}
Number PB_Humidity "Humidity [%.0f]" <humidity> {airvantage="system=AirMobile1,measure=humidity"}
Number PB_CO "CO [%.3f]" <co> {airvantage="system=AirMobile1,measure=co"}
Number PB_NO2 "NO2 [%.3f]" <no2> {airvantage="system=AirMobile1,measure=no2"}
Number PB_Dust "Dust [%.0f]" <dust> {airvantage="system=AirMobile1,measure=dust"}
Number PB_AQI "AQI [%.2f]" <gauge>      

 

Finally, the item for controlling the servo for the Air Quality Index (see below) indicator is defined

 

Number Home_Servo "Servo [%.0f]" {gpio="pin:13 name:pwm_test_P8_13.11"}

 

 

Define the rule to compute AQI

In order to provide an easy to understand measure of the air quality, I defined a custom Air Quality Index. Unfortunately widely-used Air Quality indexes are based also on measure of the ozone concentration at ground level. Since the Air Mobile does not have a ozone sensor, I defined my own Air Quality index.

The index formula is

 

  homeAQI = 1 -
((((homeCO - 30.0)/(1000.0-30.0))* 0.4) +
(((homeNO2 - 200.0)/(2000.0-200.0))*0.4) +
(((homeDust-0.0)/(500.0-0.0))*0.2))

 

The index is basically a weighted average of the percentage of the three pollutants detected by the AirMobile sensor

The value of the index range from 0 (worst air quality) to 1 (best air quality)

The index is calculate by an OpenHAB rule


rule "Home_AQI_Calculation"
when
      Item Home_CO changed or
      Item Home_NO2 changed or
      Item Home_Dust changed
then
  homeCO = Home_CO.state as DecimalType
  homeNO2 = Home_NO2.state as DecimalType
  homeDust = Home_Dust.state as DecimalType

  homeAQI = 1 - ((((homeCO - 30.0)/(1000.0-30.0))* 0.4) + (((homeNO2 - 200.0)/(2000.0-200.0))*0.4) + (((homeDust-0.0)/(500.0-0.0))*0.2))
      postUpdate(Home_AQI, homeAQI)
  
  homeServo = 1500 + (homeAQI * 1000)
  postUpdate(Home_Servo, homeServo)
end

 

This rule also updates the servo position by converting the index value (from 0 t 1) to a PWM duty cycle value (from 600 to 2400 microseconds). The PWM duty cycle is then posted to the Home_Servo item

  • Sign in to reply

Top Comments

  • mcb1
    mcb1 over 10 years ago +2
    Final week is always crunch time. I've never known any project (big or small) that hasn't featured an ability to improve on it. BUT if we constantly corrected and improved, we'd never actually get it going…
  • amgalbu
    amgalbu over 10 years ago in reply to mcb1 +1
    List of improvements will be a very long list I will try to publish updates
  • fvan
    fvan over 10 years ago in reply to amgalbu +1
    In my opinion, going from nothing to working prototype in 18 weeks is already quite an achievement, especially taking into account all the new things you've learned which will help you with future prototypes…
Parents
  • DAB
    DAB over 10 years ago

    Nice detailed post.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • amgalbu
    amgalbu over 10 years ago in reply to DAB

    Thanks DAB

    we are just one week from the end of the challenge and there are so many things that could be improved...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • amgalbu
    amgalbu over 10 years ago in reply to DAB

    Thanks DAB

    we are just one week from the end of the challenge and there are so many things that could be improved...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube