I'm sorry for asking, but I'm totally new to mysensors and home assistent, but I've already read a lot and watched youtube videos but in fact I'm right now not aware what I should do next.
First of all, my setup is home assistent running on a raspberry pi 4 Model B. I've installed MySensors Libarary 2.3.2 and used the SerialGateway Sketch with some modifications to add a motion sensor directly on the Gateway to test the functionality.
This is what my code looks like on an arduino nano:
// Enable debug prints to serial monitor
// Enable and select radio type attached
// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Enable serial gateway
// Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
#if F_CPU == 8000000L
//#define MY_BAUD_RATE 38400
#define MY_BAUD_RATE 115200
// Enable inclusion mode
// Enable Inclusion mode button on gateway
// Inverses behavior of inclusion button (if using external pullup)
// 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
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Inverses the behavior of leds
// Flash leds on rx/tx/err
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
#define CHILD_ID 1 // Id of the sensor child
// Initialize motion message
MyMessage msg(CHILD_ID, V_TRIPPED);
// Setup locally attached sensors
pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
// Present locally attached sensors
// 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)
// Send locally attached sensor data here
// Read digital motion value
bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
send(msg.set(tripped?"1":"0")); // Send tripped value to gw
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
In the configure.yml File I've added the following lines as described here:
# Example configuration.yaml entry
- device: '/dev/ttyUSB0'
# baud_rate: 38400
name: 'Motion Sensor'
At the moment I get the following message:
Unable to connect to /dev/ttyUSB0
But as I connect the gateway it I can see, that /dev/ttyUSB0 should be correct.