@TriXwooD : i can confirm - i succesfully run two radios - rfm69 and nrf24 on RPi - on the spi0 runs rfm69 and on spi1 runs nrf24. Started two separated mysensors gateway on ports 5003 and 5004 and everythng runs fine!
Posts made by seal
-
RE: Double SPI Radio Raspberry Pi
-
Relay Actuator - send periodic status as heart beat.
Hi,
i successfully added heartbeat sending to RelayActuator.ino and relay sensor is sending data every one minute - but domoticz don't update last seen - this is only visible on gateway log. So i decided to send relay status as heartbeat - i have relay with two relay switches.Source code:
#define MY_RADIO_RFM69 #define MY_RFM69_NEW_DRIVER #define MY_NODE_ID 3 // Enable repeater functionality for this node //#define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define RELAY_2 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 2 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay #define MY_DEBUG_VERBOSE long double last_heartbeat_time = millis(); long double HEARTBEAT_TIME = 30000; int oldValue=0; bool state; MyMessage msg(2,V_LIGHT); MyMessage msg2; void before() { for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); } } void setup() { } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Relay", "1.0"); for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_LIGHT); } } void loop() { long double temp = (millis() - last_heartbeat_time); if (temp > HEARTBEAT_TIME) { // If it exceeds the heartbeat time then send a heartbeat sendHeartbeat(); send(msg.set(msg2.getBool()?1:0)); last_heartbeat_time = millis(); Serial.println("Sent heartbeat" ); } } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { // Change relay state digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); msg2 = message; } }
but state is send only for one switch (second) and when i try to change switch 1 - this change is send aslo as relay 2. I added msg2 for export message from recieve to loop.
How to send status for both relays as heartbeat?