element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi IoT
  • Challenges & Projects
  • Design Challenges
  • Pi IoT
  • More
  • Cancel
Pi IoT
Blog [Pi IoT] Alarm Clock #21: Domotics
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fvan
  • Date Created: 27 Aug 2016 12:39 PM Date Created
  • Views 2021 views
  • Likes 2 likes
  • Comments 7 comments
  • fvan_piiot
  • piiot
  • domotics
Related
Recommended

[Pi IoT] Alarm Clock #21: Domotics

fvan
fvan
27 Aug 2016

  • Domestia
  • Read
  • Interpret

 

Not all blog posts can be about successful implementations or achievements. Sometimes, failure happens as well image This is the case for my domotics implementation. Does that mean I have given up on getting it to work? Certainly not, but I'm stuck and don't have to luxury that is time, so close to the deadline with plenty of other things left to do.

 

Here's what I did manage to figure out so far ...

 

Domestia

 

As you may or may not know, I moved house during the challenge, beginning of July. The new house has a domotics installation by Domestia, a belgian domotics brand from what I could find.

 

The installation consists of two relay modules, capable of turning lights and outlets on or off. There are also two dimmer modules for lights. When we started replacing the halogen bulbs by LED ones, we noticed the dimmers no longer worked, and had to replace the dimmers by LED compatible ones.

Next to the electrical wires, the modules have a three way connector labeled A, B and GND. Searching the datasheets, it is explained the domotics modules are connected to a RS485 bus for communication.

 

The wiring is illustrated in the module's manual:

image

 

The RS485 bus could be an entry point in reading the lights or outlets' status, and eventually control them.

 

Here's what it looks like in real life:

imageimage

The RS485 bus can be accessed via the dimmer's blue, green and orange wires, labeled A, B and GND.

 

Read

 

According to this, the pins' functions are the following:

  • A: Data+ (non-inverted)
  • B: Data- (inverted)
  • GND: ground

 

I started by first connecting my oscilloscope to the bus, verifying there is activity. Probe 1 was connected to line A, probe 2 to line B. This is what I saw:

imageimage

 

Three things can be observed/confirmed at a glance:

  • there is a constant flow of data
  • there is a short sequence followed by a long one: request vs response?
  • line B is indeed an inverted version of line A

 

Knowing there is data present, I could perhaps find a script or piece of software able to decode the data. For that purpose, I bought a generic RS485 to Serial USB module.

imageimage

 

Using a basic serial tool, I was able to dump the raw hexadecimal data. A new observation, is that every new line, starts with the hexadecimal value "0x0C".

 

With a script I found and modified to suit my needs, I captured the raw data and jumped to a new line every time the "0x0C" value appeared.

 

#!/usr/bin/env python

# Original script from http://stackoverflow.com/questions/31868997/using-pyserial-to-get-device-data-through-rs485
# Modified to print full hex sequences per line instead of individual values

import serial
import binascii
import time

ser = serial.Serial()
data = ""

def initSerial():
    global ser
    ser.baudrate = 9600
    ser.port = '/dev/tty.usbserial-A50285BI'
    ser.stopbits = serial.STOPBITS_ONE
    ser.bytesize = 8
    ser.parity = serial.PARITY_NONE
    ser.rtscts = 0

def main():
    initSerial()
    global ser
    global data
    ser.open()
    while True:
        mHex = ser.read()
        if len(mHex)!= 0:
            if not binascii.hexlify(bytearray(mHex)).find("0c"):
                print data
                data = binascii.hexlify(bytearray(mHex))
            else:
                data = data + " " + binascii.hexlify(bytearray(mHex))
        time.sleep(0.05)

if __name__ == "__main__":
    main()

 

Some of the captured sequences:

 

0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 aa 08 ff 08 fe
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 fe 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 fe
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 fe 85 ff
0c 08 08 08 08 0a 08 08 0a 08 08 18 08 a8 08 fe 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 fe 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 85 ff
0c 0a 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 fe
0c 08 08 08 08 08 08 08 08 08 08 18 08 aa 08 fe 85 ff 22 20
0c 08 08 08 08 0a 08 08 08 18 08 a8 08 ff 84 ff
0c 08 0a 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 85 ff 22 20
0c 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 fe
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 fe 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 fe
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 85 ff
0c 08 08 08 08 08 08 08 08 08 08 18 0a a8 0a fe 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 fe 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 0a ff 08 fe
0c 08 08 08 08 08 08 08 08 08 08 1a 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 85 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 fe 08 fe
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 fe
0c 08 08 08 08 08 08 08 08 08 0a 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 fe 08 ff 22 20
0c 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 ff
0c 08 08 08 08 08 0a 08 08 08 08 18 08 a8 08 fe 08 ff
0c 08 08 08 08 08 08 08 08 08 08 18 08 a8 08 ff 08 fe 22 20

 

There is a very repetitive pattern, with occasionally different values. But what does it do or mean?

 

Interpret

 

This is where I got blocked. This is a bit too low-level for me, so any help would be greatly appreciated! Before being able to go any further, I need to be able to make sense of the data. Until then, this feature will be parked. The goal is still to be able to control and monitor the domotics, but sadly It most likely won't be achieved in this challenge.

 

Now, if you do have knowledge or know about tools which could help me further, feel free to leave a comment below image

 

 


image

 


Navigate to the next or previous post using the arrows.

image
  • Sign in to reply

Top Comments

  • Robert Peter Oakes
    Robert Peter Oakes over 9 years ago +3
    This protocol may well be ModBusRTU, an old but still very popular industrial control protocol. ModBusRTU being the serial version of this ModBus protocol and is often used along with RS485 to improve…
  • volly
    volly over 9 years ago +2
    fvan , I have full confidence that you will get it done....by the deadline or not...but you will complete this project 100%. Just keep at it Budd!!! YV
  • Jan Cumps
    Jan Cumps over 9 years ago +2
    Long live Belgian designs The 0x0c is the form feed character. One would expect that they'd use a line feed to separate lines.
  • dvader
    dvader over 8 years ago in reply to pettitda

    I agree. It looks like your bit period is ~26us which would point to a baud rate of 38400 not 9600. Don't even bother trying to interpret the serial capture until you have done it at 38400.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • pettitda
    pettitda over 8 years ago

    Looks like from the oscilloscope shot above that the baud rate is maybe 38400.  Your capture window shows a baud rate of 9600.  Can you recapture with 38400? 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago

    Frederick

    You may find the first sequence is the address, then the rest is either data read or write depending on the module.

     

    I'm sure someone will have cracked this, so keep searching.

     

     

    mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Robert Peter Oakes
    Robert Peter Oakes over 9 years ago

    This protocol may well be ModBusRTU, an old but still very popular industrial control protocol. ModBusRTU being the serial version of this ModBus protocol and is often used along with RS485 to improve range (Distance) and reliability.

     

    it is also possible you have the wrong baud rate and are therefor not seeing as much change in data as you should (Or more), try playing around with that to see if it makes a difference. you could also veryfy with an oscilloscope for the timing

     

    https://en.wikipedia.org/wiki/Modbus

     

    another point is that if it is MODBUS RTU then the serial port would be set slightly different as described in this document:-

    Modbus Protocol

     

    Hope this may help

     

    Peter

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 9 years ago

    Long live Belgian designs image

     

    The 0x0c is the form feed character. One would expect that they'd use a line feed to separate lines.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube