Skip to content

Latest commit

 

History

History
68 lines (49 loc) · 4.09 KB

File metadata and controls

68 lines (49 loc) · 4.09 KB

Moisture Sensing Edgent 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.edgent-x.x.x.jar from the latest release.
  2. Make sure device.cfg and the smartsprinkler.edgent-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.edgent-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.edgent-x.x.x.jar from the latest release.
  4. In the device.cfg file, set the simulation property to false.
  5. Make sure device.cfg and the smartsprinkler.edgent-x.x.x.jar are in the same directory.
  6. Run the simulator using this command in the terminal: sudo java -jar smartsprinkler.edgent-x.x.x.jar

What kind of moisture sensor did you use? We got our moisture sensor from here: Moisture Sensor from ModMyPi

Here's a tutorial on how to connect the sensor: Raspberry Pi Moisture Sensor Tutorial

Developing the Edgent Application

  1. Import the eclipse project in com.ibm.streamsx.smartsprinkler.edgent
  2. Download Apache Edgent and Pi4J libraries, and make the jar files available on your machine. Configure the classpath variables EDGENT and PI4J to the location of the libraries. For example, set EDGENT and PI4J to /opt/edgent/java8 and /opt/pi4j respectively.
  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