I have now a heartbeat response form the gateway.
For my test stetup I did not define any transport layer and this is probably the reason why the gateway did not respond to the heatbeatrequest from domoticz.
I have now a heartbeat response form the gateway.
For my test stetup I did not define any transport layer and this is probably the reason why the gateway did not respond to the heatbeatrequest from domoticz.
@grumpazoid You will indeed see that a changed value in Domoticz on one of your MySensor nodes will be published on the domoticz/out topic. This is because the node was presented to Domoticz at start up.
You are not able to access a non presented node directly by Domoticz through the gateway.
You can walk around that by creating a virtual sensor in Domoticz and a 'bridge' in Node red that translates MQTT to the MySensor.
Check https://www.mysensors.org/controller/nodered.
All works fine.
I can update Text sensor or send a switch command.
But when it comes to the heartbeat request there is no response form the gateway.
I
Hi,
I would like to capture the heartbeat request send by a controller (in my case Domoticz).
However this does not work within the receive funtction.
What did I overlook?
void receive(const MyMessage &message)
{
if (message.type == I_HEARTBEAT_REQUEST) {
Serial.println("heartbeat request");
}
}```
I got a similar issue. Installed 2.2.0 beta and the gateway worked fine for some hours and then it stopped.
When I check the gateway function with :
sudo ./bin/mysgw -d
I only get these messages :
pi@raspberrypi:~/MySensors $ sudo ./bin/mysgw -d
mysgw: Starting gateway...
mysgw: Protocol version - 2.2.0-rc.1
mysgw: MCO:BGN:INIT GW,CP=RNNGL-Q-,VER=2.2.0-rc.1
mysgw: TSF:LRT:OK
mysgw: TSM:INIT
mysgw: TSF:WUR:MS=0
When i limit the lenght with
send(nikoBusMessage.setSensor(SIMULATIE_LCD_ADRES).set(payload,8));
I get this as output (ascci values of char) :
0;54;1;0;47;3132333435363738
Maybe a bug in library?
But indeed the solution with the nul character works fine.
Than
Hi,
I have :
// define my payload
char payload[8] = "12345678";
// define my myssage
MyMessage nikoBusMessage(0, V_TEXT);
// and sending the message in the program
send(nikoBusMessage.setSensor(SIMULATIE_LCD_ADRES).set(payload));
But when the message is send, a complete payload of 26 char is send.
How do I control the lenght of the payload that I want to send?
I tried :
send(nikoBusMessage.setSensor(SIMULATIE_LCD_ADRES).set(payload,8));
but then the asci value for each character of "12345678" is send in the payload.
This is how you build your network.
I assume that you use these :
Node 1 is the MAX485 RS-485 Module connected to your gateway.
Node N is the MAX485 RS-485 Module connected to your last sensor of your network.
Between node 1 and N you can add addtional nodes but you need to keep the bus structure.
Important are the terminating resistors (1) and (2). They are R7 on the RS-485 module.
If you add modules between node 1 and node N and you have a failure in transmitting, check then with removal of R7 on that added node.
@Reza No. You need to have your gateway inbetween. Your controller can't "talk" directly with you MySensors network. Wee the picture from kimot.
@hek I was wondering if it could be useful to have an extra sensor that a bridge between the wireless and wire network.
This bridge is made between the SPI dealing with the wireless network and the hardware serial that is dealing with the wire network.
It would allow you to connect a remote wired network.
IF the CE pin for the radio (9) could be user defined, a 2nd thought (based on the bridge idea).
Canβt something similar be done for the serial gateway and make that one suitable for wired and wireless network in the same gateway?
@Reza I have written earlier that I didnβt have any problem with RS485 on a cable of 10m but did not trail longer yet.
If you make trails with the wired network, make sure that you define your node id number
#define MY_NODE_ID <X>```
@Reza You have exactly the same problem as I had when I first found MySensors in march last year.
I got a couple of radio and started to play with them. All worked fine as long as they were not more than 5m away from each other. I dropped the idea at that time.
2 months ago I saw the possibility on the website to build a wired network. I started again. With the order for the RS485 bricks I ordered also some radios but now with antenna and amplifier. The only improvement I got was now up to 7m.
I managed now to connect with my greenhouse that is 12m away but had to place a repeater in between but the connection is no reliable.
The discussion that is now ongoing is not related anymore to a RS485 network. I suggest you start an new topic specific for your radio issue. Or we both did do something wrong or the hardware that we buy does not meet the specification for transmitting distance.
Let me now if you started a new topic.
@Reza yes adding this code increases the power of the radio.
you add this code at the begin of your sketch (both gateway and nodes)
#define MY_RADIO_NRF24
#define MY_RF24_PA_LEVEL RF24_PA_HIGH
@Reza scroll down on the page down to the serial gateway chapter on that page.
@Reza Struggling also with the radio network if the distance is more then 5m (and I'm using the ones with the antenna) I have troubles
Add #define MY_RF24_PA_LEVEL RF24_PA_HIGH to send on maximum power.
Added the capacitor give a bit extra power on the 3,3V?
I do not have a RS485 network installed yet but trails on a 10m ethernet cable did not give any issues. Still in program phase.
@Reza Check https://www.mysensors.org/build/raspberry. There is a comment for a serialgateway.
@Reza sory but I'm not able to help you with this.
@Reza yes, select MySensors Gateway USB for type if you add hardware.
@MICK HI, please check this topic : https://forum.mysensors.org/topic/5495/rs485-on-nano
@skatun include debug, removal of inclusion and define MY_NODE_ID enabled communication on the RS485 bus.
@dbemowsk It are the standard examples.
For the gateway (Uno) :
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* DESCRIPTION
* The RS485 Gateway prints data received from sensors on the serial link.
* The gateway accepts input on seral which will be sent out on
* the RS485 link.
*
* Wire connections (OPTIONAL):
* - Inclusion button should be connected between digital pin 3 and GND
* - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
*
* LEDs (OPTIONAL):
* - To use the feature, uncomment MY_LEDS_BLINKING_FEATURE in MyConfig.h
* - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
* - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
* - ERR (red) - fast blink on error during transmission error or recieve crc error
*
* The gateway uses AltSoftSerial to handle two serial links
* on one Arduino. Use the following pins for RS485 link
*
* Board Transmit Receive PWM Unusable
* ----- -------- ------- ------------
* Teensy 3.0 & 3.1 21 20 22
* Teensy 2.0 9 10 (none)
* Teensy++ 2.0 25 4 26, 27
* Arduino Uno 9 8 10
* Arduino Leonardo 5 13 (none)
* Arduino Mega 46 48 44, 45
* Wiring-S 5 6 4
* Sanguino 13 14 12
*
*/
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable RS485 transport layer
#define MY_RS485
// Define this to enables DE-pin management on defined pin
#define MY_RS485_DE_PIN 2
// Set RS485 baud rate to use
#define MY_RS485_BAUD_RATE 9600
// Enable serial gateway
#define MY_GATEWAY_SERIAL
// Flash leds on rx/tx/err
#define MY_LEDS_BLINKING_FEATURE
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// 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
#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
#define MY_DEFAULT_RX_LED_PIN 5 // Receive led pin
#define MY_DEFAULT_TX_LED_PIN 6 // the PCB, on board LED
#include <SPI.h>
#include <MySensors.h>
void setup() {
// Setup locally attached sensors
}
void presentation() {
// Present locally attached sensors
}
void loop() {
// Send locally attached sensor data here
}
For the sensor (Nano):
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik Ekblad
*
* DESCRIPTION
* This is an example of sensors using RS485 as transport layer
*
* Motion Sensor example using HC-SR501
* http://www.mysensors.org/build/motion
*
* The transport uses AltSoftSerial to handle two serial links
* on one Arduino. Use the following pins for RS485 link
*
* Board Transmit Receive PWM Unusable
* ----- -------- ------- ------------
* Teensy 3.0 & 3.1 21 20 22
* Teensy 2.0 9 10 (none)
* Teensy++ 2.0 25 4 26, 27
* Arduino Uno 9 8 10
* Arduino Leonardo 5 13 (none)
* Arduino Mega 46 48 44, 45
* Wiring-S 5 6 4
* Sanguino 13 14 12 *
*
*/
// Enable RS485 transport layer
#define MY_RS485
// Define this to enables DE-pin management on defined pin
#define MY_RS485_DE_PIN 2
// Set RS485 baud rate to use
#define MY_RS485_BAUD_RATE 9600
#include <SPI.h>
#include <MySensors.h>
unsigned long 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);
void setup()
{
pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as 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);
}
void loop()
{
// Read digital motion value
boolean 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.
sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
}
@skatun Will join this discussion as well. I have exately the same issue. My set up is a nano as sensor and an uno as gateway.
I verified correct wiring of RS485 network is correctly doen I used this sketch (swith ReceiveOrSend to RS485Transmit or RS485Receive on both nodes;
:
#include <AltSoftSerial.h>
AltSoftSerial altSerial;
#define SSerialTxControl 2 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW
bool ReceiveOrSend = RS485Transmit;
void setup() {
Serial.begin(9600);
Serial.println("AltSoftSerial Test Begin");
pinMode(SSerialTxControl, OUTPUT);
digitalWrite(SSerialTxControl, RS485Transmit); // Enable RS485 Transmit
altSerial.begin(9600);
if (ReceiveOrSend ){
Serial.println("send mode");
digitalWrite(SSerialTxControl, RS485Transmit); // Enable RS485 Transmit
} else
{
digitalWrite(SSerialTxControl, RS485Receive); // Enable RS485 Transmit
Serial.println("receive mode");
}
}
void loop() {
char receivedOnRS485;
if (ReceiveOrSend ){
altSerial.println(" Hello world");
delay(2000);
} else
{
if (altSerial.available()) {
receivedOnRS485 = altSerial.read();
Serial.print("ontvagen=");
Serial.println(receivedOnRS485);
}
}
}```
@dbemowsk Thank you for the reply. I searched in the meantime and found on the form that 'rs485 on nano' topic describes exactely the same issue I have. I see that you are involved there.
I will join that chat as more people are involved.
Tried this but I get an errormessage when I complile sketch for the gateway.
The node presents itself but the messsage is not recognised/ answered by the gateway.
@dbemowsk Did all of these trail once again yesterday but without success.
Hi,
I build up the wired RS485 network with the gateway and motion sensor examples give on the website.
Unfortunately it does not work. There is no commucation between the Gateway and the sensor.
I only can capture nonsence.
Connectins are :
pin 8 (RX) to RO on RS485 brick.
pin 9 (TX) to DI on RS485 brick.
MY_RS485_DE_PIN to DE RE on RS485 brick.
However if I check the connections with with this small program that used the same pins, the communication works correctly. What detail did I forget?
#include <AltSoftSerial.h>
AltSoftSerial altSerial;
#define SSerialTxControl 2 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW
bool ReceiveOrSend = RS485Transmit;
void setup() {
Serial.begin(9600);
Serial.println("AltSoftSerial Test Begin");
pinMode(SSerialTxControl, OUTPUT);
digitalWrite(SSerialTxControl, RS485Transmit); // Enable RS485 Transmit
altSerial.begin(9600);
if (ReceiveOrSend ){
Serial.println("send mode");
digitalWrite(SSerialTxControl, RS485Transmit); // Enable RS485 Transmit
} else
{
digitalWrite(SSerialTxControl, RS485Receive); // Enable RS485 Transmit
Serial.println("receive mode");
}
}
void loop() {
char receivedOnRS485;
if (ReceiveOrSend ){
altSerial.println(" Hello world");
delay(2000);
} else
{
if (altSerial.available()) {
receivedOnRS485 = altSerial.read();
Serial.print("ontvagen=");
Serial.println(receivedOnRS485);
}
}
}```
Hi, I build up the set up with serial gateway and the motion sensor but nothing happens (only nonsence is is seen in the serial monitor)
However if I run this small program using the AltSoftSerial library I can communicatie without any issue in both directions.
Have others the same issue, or what do I overlook?
#include <AltSoftSerial.h>
AltSoftSerial altSerial;
#define SSerialTxControl 2 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW
bool ReceiveOrSend = RS485Transmit;
void setup() {
Serial.begin(9600);
Serial.println("AltSoftSerial Test Begin");
pinMode(SSerialTxControl, OUTPUT);
digitalWrite(SSerialTxControl, RS485Transmit); // Enable RS485 Transmit
altSerial.begin(9600);
if (ReceiveOrSend ){
Serial.println("send mode");
digitalWrite(SSerialTxControl, RS485Transmit); // Enable RS485 Transmit
} else
{
digitalWrite(SSerialTxControl, RS485Receive); // Enable RS485 Transmit
Serial.println("receive mode");
}
}
void loop() {
char receivedOnRS485;
if (ReceiveOrSend ){
altSerial.println(" Hello world");
delay(2000);
} else
{
if (altSerial.available()) {
receivedOnRS485 = altSerial.read();
Serial.print("ontvagen=");
Serial.println(receivedOnRS485);
}
}
}