Skip to content

Latest commit

 

History

History

com.ibm.streamsx.smartsprinkler.quarks

Moisture Sensing Quarks Application

Overview

This application reads moisture data from the moisture sensor and makes decision to turn on the sprinkler (i.e. the buzzer), when conditions are met. It passes moisture data to the Watson Internet of Things Platform, and the Streaming Analytics application ingests the data and make makes the final decision on the sprinkler control.

Setting up device configuration file

Once the Node.js application is deployed on Bluemix, it generates a device configuration file. This application uses the device configuration file to connect to the Watson Internet Of Things Platform, as well as to the dashboard on the Node.js application.

To download the device file, click the hamburger icon on the top left corner, and select Settings, then Download the device.cfg file. A sample file is stored in the root directory of the project for reference.

Water Conservation Device Config

Running Simulation on your workstation

  1. Download the smartsprinkler.quarks-x.x.x.jar from the latest release.
  2. Make sure device.cfg and the smartsprinkler.quarks-x.x.x.jar are in the same directory.
  3. In the device.cfg file, set the simulation property to true.
  4. Run the simulator using this command in the terminal: java -jar smartsprinkler.quarks-x.x.x.jar

Running on your Raspberry Pi 2

  1. Connect the digital output of moisture sensor to GPIO17
  2. Connect the buzzer input to GPIO23
  3. Download the smartsprinkler.quarks-x.x.x.jar from the latest release.
  4. Make sure device.cfg and the smartsprinkler.quarks-x.x.x.jar are in the same directory.
  5. Run the simulator using this command in the terminal: sudo java -jar smartsprinkler.quarks-x.x.x.jar

Developing the Quarks Application

  1. Import the eclipse project in com.ibm.streamsx.smartsprinkler.quarks
  2. Download Apache Quarks and Pi4J libraries, and make the jar files available on your machine. This project assumes they are installed in /opt/quarks and /opt/pi4j respectively. If you installed the libraries in a different location, adjust the project build paths accordingly.
  3. Copy the device configuration file to the root of the project

Running Your Project using Eclipse

  1. Ensure the Node.js application (i.e. the dashboard) is running on Bluemix.
  2. Modify device.cfg, and set the property simulation to true.
  3. Ensure the property ui-host is set to the URL of the Node.js application.
  4. Right click SmartSprinklerApp.java, and Run as Java Application.
  5. The dashboard should plot the moisture data received by this application on the graph.

Running Your Project on Raspberry Pi

  1. Create a runnable Jar file by right clicking on the project, and Export as a Runnable JAR file.
  2. Select the launch configuration that was created when you run the simulation on the workstation.
  3. Select an appropriate destination file name for the runnable jar.
  4. Select Package required libraries into generated JAR.
  5. Click Finish to create the runnable JAR.
  6. Copy the runnable JAR and the device.cfg to the Raspberry Pi.
  7. Ensure the property simulation in device.cfg is set to false.
  8. On the pi, sudo java -jar <runnable.jar>. (You must be root to run this)
  9. The dashboard should plot the moisture data received by the pi on the graph.

Links