Building a wired RS485 Mysensor network

Subforum for the 'MySensors' project.
http://www.mysensors.org/
Post Reply
Jan Jansen
Posts: 151
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi
Domoticz version: Stable
Location: The Netherlands
Contact:

Building a wired RS485 Mysensor network

Post by Jan Jansen » Tuesday 15 November 2016 17:18

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

User avatar
Redguy
Posts: 34
Joined: Saturday 19 November 2016 22:26
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Maassluis
Contact:

Re: Building a wired RS485 Mysensor network

Post by Redguy » Sunday 15 January 2017 10:57

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

RidingTheFlow
Posts: 78
Joined: Friday 11 March 2016 19:23
Target OS: Raspberry Pi
Domoticz version:
Location: Essex, UK
Contact:

Re: Building a wired RS485 Mysensor network

Post by RidingTheFlow » Sunday 15 January 2017 13:46

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.

Toulon7559
Posts: 425
Joined: Sunday 23 February 2014 18:56
Target OS: Raspberry Pi
Domoticz version: latest
Location: Hengelo(Ov)/NL
Contact:

Re: Building a wired RS485 Mysensor network

Post by Toulon7559 » Sunday 15 January 2017 14:41

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 ...
Last edited by Toulon7559 on Monday 16 January 2017 14:44, edited 1 time in total.
Set1 = RPI-B+RFXCom433+S0PCM+Linksprite-shield for BMP180/DS18B20/RS485+DDS238ZN1
Set2 = RPI-3+RFLinkGTW+ESP8266s+PWS_WS7000
Common = 2*PVLogger+PWS_TFA_Nexus+KAKUs
=> Energy & Data Management based on Time and on PV&Consumption&Meteo

User avatar
Redguy
Posts: 34
Joined: Saturday 19 November 2016 22:26
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Maassluis
Contact:

Re: Building a wired RS485 Mysensor network

Post by Redguy » Monday 16 January 2017 12:38

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 !

Toulon7559
Posts: 425
Joined: Sunday 23 February 2014 18:56
Target OS: Raspberry Pi
Domoticz version: latest
Location: Hengelo(Ov)/NL
Contact:

Re: Building a wired RS485 Mysensor network

Post by Toulon7559 » Monday 16 January 2017 14:46

@Redguy

More detailled description of your setup available?
Pictures such as Network-diagram etc. provide quick understanding.
Set1 = RPI-B+RFXCom433+S0PCM+Linksprite-shield for BMP180/DS18B20/RS485+DDS238ZN1
Set2 = RPI-3+RFLinkGTW+ESP8266s+PWS_WS7000
Common = 2*PVLogger+PWS_TFA_Nexus+KAKUs
=> Energy & Data Management based on Time and on PV&Consumption&Meteo

pj-r
Posts: 245
Joined: Wednesday 17 December 2014 18:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: Building a wired RS485 Mysensor network

Post by pj-r » Monday 23 January 2017 0:24

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).
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors

bobdvb
Posts: 23
Joined: Friday 29 July 2016 9:53
Target OS: Raspberry Pi
Domoticz version:
Location: United Kingdom
Contact:

Re: Building a wired RS485 Mysensor network

Post by bobdvb » Monday 27 February 2017 12:24

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

pj-r
Posts: 245
Joined: Wednesday 17 December 2014 18:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: Building a wired RS485 Mysensor network

Post by pj-r » Wednesday 15 March 2017 21:37

For modbus communication I did use this library: https://github.com/smarmengol/Modbus-Ma ... or-Arduino
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors

Abbadon
Posts: 55
Joined: Thursday 01 October 2015 8:25
Target OS: Raspberry Pi
Domoticz version: beta
Location: Poland, Wrocław
Contact:

Re: Building a wired RS485 Mysensor network

Post by Abbadon » Wednesday 15 March 2017 22:54

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)); 

  }

Lomax
Posts: 43
Joined: Monday 18 May 2015 17:12
Target OS: Raspberry Pi
Domoticz version:
Location: United Kingdom
Contact:

Re: Building a wired RS485 Mysensor network

Post by Lomax » Monday 17 April 2017 4:41

I might be interested in putting a bounty up for native RS485/Modbus support in Domoticz, if anyone here thinks they can create it?

bigcat
Posts: 1
Joined: Monday 17 April 2017 6:13
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Building a wired RS485 Mysensor network

Post by bigcat » Monday 17 April 2017 6:21

I hope to be able to achieve this, I have a set of Daikin central air conditioning and plan to buy an RS485 interface

Lomax
Posts: 43
Joined: Monday 18 May 2015 17:12
Target OS: Raspberry Pi
Domoticz version:
Location: United Kingdom
Contact:

Re: Building a wired RS485 Mysensor network

Post by Lomax » Tuesday 01 August 2017 18:38

@bigcat: Did you get anywhere with the air conditioning & RS485?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests