Hi
I have coneccted the arduino mega to RPI 3 via usb
I can not handle the script on more than one motion sensor
#define MY_DEBUG
// Enable serial gateway
#define MY_GATEWAY_SERIAL
// Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
#if F_CPU == 8000000L
#define MY_BAUD_RATE 38400
#endif
// Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
#define MY_INCLUSION_BUTTON_FEATURE
// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
#define MY_INCLUSION_MODE_BUTTON_PIN 3
#include <SPI.h>
#include <MySensors.h>
#include <Bounce2.h>
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
#define DIGITAL_INPUT_SENSOR 6 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
#define CHILD_ID 1 // Id of the sensor child
#define DIGITAL_INPUT_SENSOR_2 7 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
#define CHILD_ID_2 2 // Id of the sensor child
// Initialize motion message
MyMessage msg(CHILD_ID, V_TRIPPED);
MyMessage msg2(CHILD_ID_2, V_TRIPPED);
void setup()
{
pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
pinMode(DIGITAL_INPUT_SENSOR_2, INPUT);
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Motion Sensor", "1.0");
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID, S_MOTION);
present(CHILD_ID_2, S_MOTION);
}
void loop()
{
{
// Read digital motion value
bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
Serial.println(tripped);
send(msg.set(tripped?"1":"0")); // Send tripped value to gw
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
}
{// Read digital motion value
bool tripped = digitalRead(DIGITAL_INPUT_SENSOR_2) == HIGH;
Serial.println(tripped);
send(msg2.set(tripped?"1":"0")); // Send tripped value to gw
sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE,digitalPinToInterrupt(DIGITAL_INPUT_SENSOR_2), CHANGE, SLEEP_TIME);
}
}
This script generates a lot of different sensors in the domoticz and should only two.
I don't now why?
When it erases:
sleep(digitalPinToInterrupt(CzujnikRuchu1), CHANGE, digitalPinToInterrupt(CzujnikRuchu2), CHANGE, SLEEP_TIME); ``````
It's the same
Could you help me with this?