Skip to content

Instantly share code, notes, and snippets.

@SijmenHuizenga
Last active December 30, 2017 14:33
Show Gist options
  • Save SijmenHuizenga/0b6d34cd0337f912cd12baf5aea961aa to your computer and use it in GitHub Desktop.
Save SijmenHuizenga/0b6d34cd0337f912cd12baf5aea961aa to your computer and use it in GitHub Desktop.
Mysensors Firework Igniter
/**
* This mysensor node will turn a relais on for 5 seconds upon receiving a V_STATUS message. This will trigger some firework!
* To ignite the firework send the following message to the gateway:
* 17;18;1;1;2;1
*/
#define MY_DEBUG
#define MY_RADIO_NRF24
#define MY_REPEATER_FEATURE
#define MY_NODE_ID 17
#define CHILD_SENSOR_ID 18
#define RELAY_PIN 4
#define RELAY_ON 1
#define RELAY_OFF 0
#include <MySensors.h>
//timestamp in millis when the relais is turned on. 0 if relais is off.
unsigned long onmoment = 0;
void before(){
pinMode(pin, OUTPUT);
digitalWrite(pin, RELAY_OFF);
}
void setup(){}
void presentation(){
sendSketchInfo("Igniter", "1.0");
present(CHILD_SENSOR_ID, S_BINARY);
}
void loop(){
if(onmoment != 0 && millis() - onmoment > 5000){
digitalWrite(RELAY_PIN, RELAY_OFF);
onmoment = 0;
}
}
void receive(const MyMessage &message){
if (message.type==V_STATUS)
digitalWrite(RELAY_PIN, RELAY_ON);
}
#define MY_DEBUG
#define MY_RADIO_NRF24
#define MY_GATEWAY_W5100
#define MY_SOFTSPI
#define MY_SOFT_SPI_SCK_PIN 14
#define MY_SOFT_SPI_MISO_PIN 16
#define MY_SOFT_SPI_MOSI_PIN 15
#define MY_RF24_CE_PIN 5
#define MY_RF24_CS_PIN 6
#define MY_PORT 5003
#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
#define MY_GATEWAY_MQTT_CLIENT
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway-out"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway-in"
#define MY_MQTT_CLIENT_ID "mysensors-1"
#define MY_MQTT_USER ""
#define MY_MQTT_PASSWORD ""
#define MY_CONTROLLER_URL_ADDRESS "m20.cloudmqtt.com"
#define MY_PORT 11020
#define MY_DEFAULT_LED_BLINK_PERIOD 300
#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin
#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
#define MY_DEFAULT_TX_LED_PIN 9 // Transmit led pin
#include <Ethernet.h>
#include <MySensors.h>
void setup(){}
void presentation(){}
void loop(){}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment