Page 1 of 1
Building a wired RS485 Mysensor network
Posted: Tuesday 15 November 2016 16:18
by Jan Jansen
At the moment I'm not using Mysensors. I am considering to use a wired Mysensors network, is that possible?
My knowledge is limited, but I love experimenting. I read that it is possible to connect an RS-485 network to RPI through
http://store.linksprite.com/rs485-gpio- ... erry-pi-2/ .
What else is needed for communication between Domoticz and Mysensors nodes?
I read earlier:
https://www.mysensors.org/build/rs485 and
http://learn.linksprite.com/raspberry-p ... d-for-rpi/.
Thanks in advance
Jan
Re: Building a wired RS485 Mysensor network
Posted: Sunday 15 January 2017 9:57
by Redguy
Sure,
Should work just fine with my sensors..
The mysensors pages will give you information on how to setup a serial rs485 gateway by using an arduino or directly connected to a raspberry pi.. Just uae max485 chip or module from aliexpress or ebay..
Install the mysensors library in the arduino IDE and go to examples -> MySensors
You will find example sketches for both the gateway and a sensor node using rs485..
In domoticz, you just create a mysensors gateway hardware device, domoticz does not care if you use rs485 or rf.
It will show up in your hardware list with a setup/configure button.
Every mysensors node and sensor will show up there, every usable sensor will also show up in the device list.
Hint : you need to select a specific node to see the sensors attached in the child list on the setup screen of your gateway davice
Re: Building a wired RS485 Mysensor network
Posted: Sunday 15 January 2017 12:46
by RidingTheFlow
Jan Jansen wrote:At the moment I'm not using Mysensors. I am considering to use a wired Mysensors network, is that possible?
It is possible very easy, just make every device a mysensors serial gateway which does not need any kind of routing and talks sensor reports directly.
However why would you use RS485? If your host/central device does have USB host support (like Raspberry PI/HTPC) I'd just use bog standard USB (1.1/2.0), its a lot less hassle.
Re: Building a wired RS485 Mysensor network
Posted: Sunday 15 January 2017 13:41
by Toulon7559
Cabled network is generally more reliable than wireless, and RS485 can be run over (in comparison) really long distance.
If already an RS485-network in place, why not use it?
You just have to program the communication between the Slaves and the Bus-Master.
If protocol of the Slave is known, a compatible script to be made for the Bus-Master for the interface to Domoticz, etc.:
experience-example for a kWh-meter setup applying the Linksprite-shield at a Raspberry, see
http://www.domoticz.com/forum/viewtopic ... 808#p37429
In my case a slightly different view then Jan Jansen:
- the Bus-Master is present as a Raspberry with Domoticz and Python
kWh-meter Slave(s) present, with compatible Python-script at the Bus-Master
Slaves for other sensors still absent & undefined, and therefore the protocol is 'open for suggestion'
for the sensor-protocol a compatible script at Raspberry 'to be developed' (or to be copied from another setup)

Interesting challenge to combine Meters and Sensors in one RS485-setup ...
Re: Building a wired RS485 Mysensor network
Posted: Monday 16 January 2017 11:38
by Redguy
Actualy, i am building sort of the same setup..
I prefer using wired nodes connected through RS485 for most of my sensors as well. largely because the wiring is/was already there from a previous sensor network setup..
My Energy meter uses Modbus over RS485..
What i did is to conect the modbus/rs485 to my Serial->RS485 MySensors gateway node through a separate interface (i used a Arduino Mega). And this setup is working great !
Re: Building a wired RS485 Mysensor network
Posted: Monday 16 January 2017 13:46
by Toulon7559
@Redguy
More detailled description of your setup available?
Pictures such as Network-diagram etc. provide quick understanding.
Re: Building a wired RS485 Mysensor network
Posted: Sunday 22 January 2017 23:24
by pj-r
I'm commanding my air-to-water heat pump(rs485/modbus-rtu) thru mysensors network.
So the network looks like this:
Domoticz(Radxa Rock) <-USB/Serial-> MySensors GW(Arduino Nano) <-wireless/nrf24l01-> Heat pump node(Arduino Mega) <-RS485/modbus-rtu-> Heat pump(Amitime avh-12v1d).
I'm going to replace that wireless part with wired at some point. It'll be either RS485(
see this) or CAN bus(for better "multi-master" and collision detection/prevent support).
Re: Building a wired RS485 Mysensor network
Posted: Monday 27 February 2017 11:24
by bobdvb
Redguy wrote:Actualy, i am building sort of the same setup..
I prefer using wired nodes connected through RS485 for most of my sensors as well. largely because the wiring is/was already there from a previous sensor network setup..
My Energy meter uses Modbus over RS485..
What i did is to conect the modbus/rs485 to my Serial->RS485 MySensors gateway node through a separate interface (i used a Arduino Mega). And this setup is working great !
What Modbus code did you use? I am using Modbus relays and I have managed to write a script to read the status but as yet it isn't very reliable.
Bob
Re: Building a wired RS485 Mysensor network
Posted: Wednesday 15 March 2017 20:37
by pj-r
Re: Building a wired RS485 Mysensor network
Posted: Wednesday 15 March 2017 21:54
by Abbadon
example of code i use on rs485 (here ptt is deleted for test)
Code: Select all
#include <EEPROM.h>
long pulseCount = 0;
unsigned long pulseTime,lastTime;
double power, elapsedkWh;
int ppwh = 1; //1000 pulses/kwh = 1 pulse per wh
//##################
#define ADRESS 89
//##################
int boot_time = ADRESS * 120;
#define ptt 2
#define sv_version 0.01
char character;
String content = "";
unsigned long tempMillis = 0;
unsigned long presenceMillis = 0;
unsigned long HBMillis = 0;
unsigned long EmonMillis = 0;
const long temp_interval = 300000; //send temp every 5 min to gateway
const long presence_interval = 1800000; // sends persence every 30 min
const long HB_interval = 20000; // sends heartbeat every X min
const long Emon_interval = 60000; // sends vals every X min
void setup()
{
attachInterrupt(1, onPulse, FALLING);
Serial.begin(115200);
}
void loop()
{
unsigned long currentMillis = millis();
unsigned long currentMillisHB = millis();
unsigned long currentMillisEmon = millis();
//send persence every X ms to gateway (to avoid unknow child)
if (currentMillis - presenceMillis >= presence_interval) {
presenceMillis = currentMillis;
send_presence();
}
}
void send_vals(){
Serial.println(String(ADRESS) + ";1;1;0;18;"+ String(elapsedkWh,3)+ "\n");
Serial.println(String(ADRESS) + ";2;1;0;17;" + String(power,3)+"\n");
}
void onPulse()
{
//used to measure time between pulses.
lastTime = pulseTime;
pulseTime = micros();
//pulseCounter
pulseCount++;
//Calculate power
power = (3600000000.0 / (pulseTime - lastTime))/ppwh;
//Find kwh elapsed
elapsedkWh = (1.0*pulseCount/(ppwh*1000)); //multiply by 1000 to convert pulses per wh to kwh
//Print the values.
//Serial.print(power,3);
//Serial.println(elapsedkWh,3);
}
void send_presence(){
//node-id ; child-sensor-id ; command ; ack ; type ; payload \n
Serial.print(String(ADRESS) + ";255;3;0;11;Abbadon Pulse " + sv_version + "\n");
//Serial.print(String(ADRESS) + ";255;3;0;11;Abbadon Pulse " + sv_version + "\n");
Serial.println(String(ADRESS) + ";1;1;0;18;" + String(elapsedkWh,3));
Serial.println(String(ADRESS) + ";2;1;0;17;" + String(power,3));
}
Re: Building a wired RS485 Mysensor network
Posted: Monday 17 April 2017 4:41
by Lomax
I might be interested in putting a bounty up for native RS485/Modbus support in Domoticz, if anyone here thinks they can create it?
Re: Building a wired RS485 Mysensor network
Posted: Monday 17 April 2017 6:21
by bigcat
I hope to be able to achieve this, I have a set of Daikin central air conditioning and plan to buy an RS485 interface
Re: Building a wired RS485 Mysensor network
Posted: Tuesday 01 August 2017 18:38
by Lomax
@bigcat: Did you get anywhere with the air conditioning & RS485?