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.
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.
- Download the smartsprinkler.quarks-x.x.x.jar from the latest release.
- Make sure device.cfg and the smartsprinkler.quarks-x.x.x.jar are in the same directory.
- In the device.cfg file, set the
simulation
property totrue
. - Run the simulator using this command in the terminal:
java -jar smartsprinkler.quarks-x.x.x.jar
- Connect the digital output of moisture sensor to GPIO17
- Connect the buzzer input to GPIO23
- Download the smartsprinkler.quarks-x.x.x.jar from the latest release.
- Make sure device.cfg and the smartsprinkler.quarks-x.x.x.jar are in the same directory.
- Run the simulator using this command in the terminal:
sudo java -jar smartsprinkler.quarks-x.x.x.jar
- Import the eclipse project in
com.ibm.streamsx.smartsprinkler.quarks
- 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. - Copy the device configuration file to the root of the project
- Ensure the Node.js application (i.e. the dashboard) is running on Bluemix.
- Modify
device.cfg
, and set the propertysimulation
totrue
. - Ensure the property
ui-host
is set to the URL of the Node.js application. - Right click
SmartSprinklerApp.java
, and Run as Java Application. - The dashboard should plot the moisture data received by this application on the graph.
- Create a runnable Jar file by right clicking on the project, and Export as a Runnable JAR file.
- Select the launch configuration that was created when you run the simulation on the workstation.
- Select an appropriate destination file name for the runnable jar.
- Select
Package required libraries into generated JAR
. - Click
Finish
to create the runnable JAR. - Copy the runnable JAR and the
device.cfg
to the Raspberry Pi. - Ensure the property
simulation
indevice.cfg
is set tofalse
. - On the pi,
sudo java -jar <runnable.jar>
. (You must be root to run this) - The dashboard should plot the moisture data received by the pi on the graph.
- Apache Quarks: http://quarks.incubator.apache.org
- Pi4J: http://pi4j.com
- Pi4J Pin Numbering: http://pi4j.com/pins/model-b-rev2.html