These are the various source files used in my hackathon project Java. Here's a brief description of what they do:
Agent and device scripts to run on the Electric Imp
You don't have to edit anything in here to get Java up and running.
Source for the PhoneGap/Cordova app GUI for the Imp API
You will have to edit JavaControl/www/js/agenturl-template.js to connect the app to your Imp. You'll also have to build the app for your device.
Arduino sketch to relay (heh) voltages on pin 9 of the imp to the relay shield on the Arduino
You don't have to edit anything in here to get Java up and running, but feel free to replace the Arduino with a relay that works directly with the Imp.
Code for a Particle Photon-powered button that toggles the coffee maker state.
You will need to put your Imp agent ID in the agent
variable on line 11. You can find the ID above the agent code in the online Imp IDE.
The API is really simple. There are only three methods:
- ?getstate: Gets the current state of the relay. Returns "yes" or "no".
- ?brew=start: Closes the relay to start the coffeemaker. Returns "Brewing commencement command sent...".
- ?brew=stop: Opens the relay to stop the coffeemaker. Returns "Brewing halt command sent...".
- ?brew=toggle: Sets the relay to the opposite of its current state. Returns "Toggling brew state...".
What did I tell you? Simple!
Here's a little schematic thing I made in Fritzing:
Needless to say, this project is not written in the Java language. I just thought it's a witty name.