Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from rlisle/pinrelay
Pin based relay
- Loading branch information
Showing
14 changed files
with
329 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
Copyright 2017 Ron Lisle | ||
|
||
<insert the text of your chosen license license here> | ||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote | ||
products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. | ||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright 2017 Ron Lisle | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote | ||
products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. | ||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# PatriotRelay | ||
|
||
A Patriot plugin to support simple relays. | ||
|
||
## Usage | ||
|
||
Include this library in a Photon sketch to control simple on/off | ||
devices such as relays. | ||
|
||
Note that many relay type devices require more current than can be | ||
safely provided by a GPIO pin. In these cases you will need to provide | ||
some sort of driver circuit (eg. transistor, MOSFET, etc) to provide | ||
ample current to the device. | ||
|
||
This example creates a single device connected to a relay attached | ||
to GPIO D0. The device is named "relay". | ||
|
||
Since Patriot supports automatic detection by the iOS app and Alexa, | ||
either of these can be used to control the relay once this sketch is | ||
loaded to a Photon. There may be a 15 minute delay before Alexa starts | ||
to work, since a "Discover Devices" cycle is needed. You can manually | ||
invoke a discovery using the Alexa app to eliminate the delay. | ||
|
||
After Alexa discovery is performed, you can control this by saying | ||
"Alexa, turn on relay" or "Alexa, turn off relay". | ||
|
||
|
||
## Documentation | ||
|
||
Refer to the Patriot Github repository and documentation for more | ||
information. | ||
|
||
|
||
## Contributing | ||
|
||
Here's how you can make changes to this library and eventually contribute those changes back. | ||
|
||
To get started, [clone the library from GitHub to your local machine](https://help.github.com/articles/cloning-a-repository/). | ||
|
||
Change the name of the library in `library.properties` to something different. You can add your name at then end. | ||
|
||
Modify the sources in <src> and <examples> with the new behavior. | ||
|
||
To compile an example, use `particle compile examples/usage` command in [Particle CLI](https://docs.particle.io/guide/tools-and-features/cli#update-your-device-remotely) or use our [Desktop IDE](https://docs.particle.io/guide/tools-and-features/dev/#compiling-code). | ||
|
||
After your changes are done you can upload them with `particle library upload` or `Upload` command in the IDE. This will create a private (only visible by you) library that you can use in other projects. Do `particle library add IoT_myname` to add the library to a project on your machine or add the IoT_myname library to a project on the Web IDE or Desktop IDE. | ||
|
||
At this point, you can create a [GitHub pull request](https://help.github.com/articles/about-pull-requests/) with your changes to the original library. | ||
|
||
If you wish to make your library public, use `particle library publish` or `Publish` command. | ||
|
||
## LICENSE | ||
Copyright 2017 Ron Lisle | ||
|
||
Refer to the included LICENSE file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/******************************************************* | ||
Relay Example | ||
This example supports a relay connected to pin D7. | ||
D7 is also connected to the built-in blue LED, so | ||
it can be used to view operation. | ||
http://www.github.com/rlisle/Patriot | ||
Written by Ron Lisle | ||
BSD license, check LICENSE for more information. | ||
All text above must be included in any redistribution. | ||
Changelog: | ||
2017-10-31: Initial creation | ||
********************************************************/ | ||
|
||
#include <IoT.h> | ||
#include <PatriotRelay.h> | ||
|
||
IoT *iot; | ||
|
||
void setup() { | ||
iot = IoT::getInstance(); | ||
iot->begin(); | ||
|
||
// Define our "relay" device on pin D7 | ||
// Since no duration is specified, it is set to a | ||
// default value of 0 meaning no automatic turn off. | ||
Relay *relay = new Relay(D7, "relay"); | ||
iot->addDevice(relay); | ||
} | ||
|
||
void loop() { | ||
iot->loop(); | ||
} |
Oops, something went wrong.