Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.96k stars 1.67k forks source link

Extend range of zigbee network using CC2531/CC2530 routers #52

Closed james-fry closed 6 years ago

james-fry commented 6 years ago

The CC2531 does not seem to have as good range as my Xiaomi hub. Using same type of Xiaomi sensor (new generation reed switch sensor - MCCGQ11LM) I found that the CC2531 is failing to receive updates, where the Xiaomi does. Hub and CC sniffer are in same room ~1.5M apart. The reed sensors are in a room in floor below next to each other. (Neither network has active/powered devices to act as repeater)

Is there any way to improve range?

1) I have the dongle on a USB extension to move it away from the metal of my VM server, but I think I can use a longer extension to get further away from the metal...

2) I can add powered device (e.g.) bulb as a repeater. Problem with this is that bulbs do get hard switched off sometimes. I dont have any zigbee sockets.

3) There are CC2531 devices with a RF front end and external antenna with supposedly higher range. e.g. this one But these cost more + less easy to program (need to solder header) + not sure if firmware is compatible with the RFX2401C PA chip

Anything else?

kirovilya commented 6 years ago

Hello. I have been tested 4 types of cc253x devices as coordinator: sticks_4 From left to right: cc2531, cc2530 with external antenna, cc2530+cc2591, cc2530+RFX2401

Three last (right) devices not different for xiaomi sensors. Because it is not listen xiaomi sensor in long range (sensor can not send long range signal).

In direct line of sight I get work sensor on ranges: 30m with cc2531 and about 50-60m with cc2530 + external antenna and also with cc2530 + range amplifieres.

https://www.youtube.com/watch?v=v6iMcxRl_Xc

ptvoinfo commented 6 years ago

You may add a custom router with the external antenna (based on 2nd board from the left) http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/ I'm using 2 routers and 1 coordinator in my rather large home (about 500 m2).

kirovilya commented 6 years ago

@ptvoinfo It is good news! Thank you. Can you make and share cc2531 firmware for router?

ptvoinfo commented 6 years ago

@kirovilya I can try. But why CC2531 is better than CC2530? CC2530 is cheaper and has the external antenna.

kirovilya commented 6 years ago

@ptvoinfo yes, but cc2531 is simplier for other users :) "plug and use"

ptvoinfo commented 6 years ago

@kirovilya this is not simple as you think :)

  1. you need to flash a new firmware.
  2. you need to place it somewhere with a 5V power source and usually this is a hidden place. So IMHO, CC2530 is better. Therefore I use CC2531 as a sniffer only.
james-fry commented 6 years ago

Plug a cc2531 with router firmware into 5v USB PSU like one of these? https://www.amazon.co.uk/dp/B01N25761P/ref=cm_sw_r_cp_api_i_KxdaBbMNEQA2E

dgomes commented 6 years ago

I would also like to get my hands on a cc2531 router firmware :)

Too easy to stick it directly to a usb mains charger behind some furniture

james-fry commented 6 years ago

Hi @ptvoinfo I read your blog post linked above - thx for sharing. I notice that for the router firmware you mention that you "Pre-configured manufacturer code for Xiaomi devices." Does this mean that the router f/w needs to be customised for the devices that will be in the network? Can it be made generic?

ptvoinfo commented 6 years ago

Hi @james-fry A generic router must be configured first using Z-Tool (set network ID, default channel, security key). From my point of view this is not an easy process.

james-fry commented 6 years ago

Understood. With my limited understanding of zigbee, I had assumed that we'd need to pair the router with the coordinator in the same was as an end device - e.g. perhaps using one of the two ptm switches on the cc2531 sniffer to initiate pairing?. This would then set the ID/channel/key in same way as a device like the xiaomi smart sockets (which are both end device and router). BTW I totally get that writing f/w for this is a big job, but maybe there is capability in this forum to get it working?

james-fry commented 6 years ago

Hi @kirovilya - I noticed that your testing includes two boards with RF frontends (cc2530+cc2591, cc2530+RFX2401). Are you aware of whether the "48 device" coordinator firmware for this project is compatible with those frontends? As I understand it the CC253x SoC has to program/control the frontend chip via GPIOs, so the f/w needs to include support. Both 2591 and RFX2401 have different requirements. @oskarn97 - If Im correct you were the source for the f/w. Would you be able to confirm this?

Maybe we can start a list of compatible boards over and above the recommended CC2531 sniffer USB dongle?

kirovilya commented 6 years ago

@james-fry for cc2530 (without range amplifieres) you need firmware https://github.com/kirovilya/files/blob/master/CC2530ZNP-Pro-Secure_LinkKeyJoin.hex (but this firmware without maximum 48 devices) and for cc2530 with RF you need https://github.com/kirovilya/files/blob/master/CC2530ZNP-Test_for_CC2591.hex (thank @oskarn97 for this firmware)

oskarn97 commented 6 years ago

I've just increased the device limit and enabled secure link join. Apart from that I did not modify the default TI Z Stack Home.

james-fry commented 6 years ago

Thanks for the swift replies, @kirovilya @oskarn97

So as a summary we have support for: (UPDATED)

Not supported

Is this correct?

kirovilya commented 6 years ago

@james-fry not correct. https://github.com/kirovilya/files/blob/master/CC2530ZNP-Test_for_CC2591.hex compatible with CC2591 and RFX2401. I not found CC2531 with any RF. sorry, found in first post

james-fry commented 6 years ago

@kirovilya Thanks. Updated the summary with this confirmation. This guy is selling CC2531 + RFX2401 https://www.ebay.co.uk/itm/CC2531-RFX2401C-PA-LNA-RF-Front-End-2-4GHz-IEEE-802-15-4-ZigBee-USB-dongle/141931496878 There are a couple of versions - one also with ext antenna.

dgomes commented 6 years ago

We need to make this information sticky in the Wiki :)

kirovilya commented 6 years ago

@dgomes I also maintain wiki in Russian. it will be possible to give a link to it as a localized resource :)

james-fry commented 6 years ago

I'm happy to update wiki and make a PR later today.

ptvoinfo commented 6 years ago

@kirovilya

CC2530 with this firmware: https://github.com/kirovilya/files/blob/master/CC2530ZNP-Pro-Secure_LinkKeyJoin.hex

What communication settings does this firmware use? What pins must be connected? I've tried 115200,8N1 pins (P02, P03, GND, 3.3V) and it does not work for me. My own firmware works.

kirovilya commented 6 years ago

@ptvoinfo P20 to GND

ptvoinfo commented 6 years ago

@kirovilya P20 to GND: tried too.

kirovilya commented 6 years ago

@ptvoinfo Hmm. My connections to UART cable: RX - P03 TX - P02 3.3v - VCC GND - GND

and on board wire P20 to GND. Port speed 115200, but rtscts is false

What error did you receive?

ptvoinfo commented 6 years ago

@kirovilya I'm using UART TTL to USB converter. Wiring is the same (tried swap RX and TX, with/without P20). zigbee2mqtt cannot initialize CC2530. Data timeout.

james-fry commented 6 years ago

@Koenkk - I didn't realise that wiki is not part of repo (GH noob here), so I cant edit your wiki in my fork and submit PR :( Are you able to give me permission to update the wiki? Alternative I can message you with the wiki markup?

kirovilya commented 6 years ago

@ptvoinfo Very strange... Try to reboot :) I flashed and used cc2530 many times...

kirovilya commented 6 years ago

@ptvoinfo may be you have CC2530 + CC2591 board ?

kirovilya commented 6 years ago

@ptvoinfo in case cc2530+RF i need connect P06 and P04 to GND too (do not ask me "why" :) ). may be it help in your case.

Koenkk commented 6 years ago

@james-fry you should be able to edit the wiki now.

james-fry commented 6 years ago

Great. Will update shortly.

james-fry commented 6 years ago

Updated wiki. New page for supported CC sniffer devices: https://github.com/Koenkk/zigbee2mqtt/wiki/Supported-sniffer-devices

james-fry commented 6 years ago

This guy on smartthings forum made a nice CC2350 based solution with custom pcb: https://community.smartthings.com/t/another-zigbee-repeater-solution-with-temperature-humidity-pressure-and-light-sensors/123815

He sees the usefulness of usb for power source :)

ghost commented 6 years ago

The guy over smartthings does not seem to sharing his firmware. I found this: setting a slightly more expensive Xbee S2C as router https://alselectro.wordpress.com/2017/01/23/zigbee-xbee-s2c-how-to-configure-as-coordinator-router-end-device/

kirovilya commented 6 years ago

@kiucheng As I know, Xbee S2C can't work with xiaomi devices. May be I wrong...

ryanbeaton commented 6 years ago

HI @kirovilya , do you have a link for the cc2530+RFX2401 ("ZIGBEE RF to USB dongle)?

https://www.aliexpress.com/item/1pcs-lot-CC2530-CC2591-USB-ZigBee-dongle-board-free-shipping/1813876248.html Is the only one I could find but it is unavailable.

kirovilya commented 6 years ago

@ryanbeaton I got here (two times) https://www.aliexpress.com/item/RF-TO-USB-CC2530-CC2591-RF-switch-USB-transparent-serial-data-transmission-equipment/1996354384.html Description says "CC2591", but in fact it has GB2530-S chip photo_2018-05-22_19-26-24 wich have CC2530+RFX2401 http://www.gban.cn/en/product_show.asp?action=p295&id=47

james-fry commented 6 years ago

Haha I was just about to post that same link. I speculated that you were the person who left the reviews :)

The GB2530-S chip seems to have a RF(x)2401 front end: http://www.gban.cn/en/product_show.asp?action=p295&id=47 (just saw you added this above, but its under the image)

Actually looks like this might be the go-to device for upgraded range/sensitivity. Did you add the programming header? (I assume its the white 5 pin header)

ryanbeaton commented 6 years ago

:) @james-fry my next Q was about the programming header. If thats comes as is would be easy

kirovilya commented 6 years ago

@james-fry @ryanbeaton Yes, 5 pin header use for ccdebugger (look at description on Aliexpress). Cable in complect exists.

ryanbeaton commented 6 years ago

thanks, have ordered wasn't to sure about description but this helped http://www.gban.cn/en/product_show.asp?action=p297&id=43

james-fry commented 6 years ago

I also ordered. Hope the antenna and additional sensitivity from the Rf frontend will resolve my range issues

kirovilya commented 6 years ago

@ryanbeaton @james-fry remember me when received devices :) because: photo_2018-05-22_21-46-06

james-fry commented 6 years ago

Better get my fine tip soldering iron out... what’s this for? Is it the p06 and p04 to gnd you mentioned above?

kirovilya commented 6 years ago

Yes. It is for normal work. And P20 to GND.

ryanbeaton commented 6 years ago

@kirovilya Oh! I forgot about those comments of yours. Sorry but can you clarify, I just solder up like that and then flash. Do I also leave it like that to operate also. Thanak

kirovilya commented 6 years ago

@ryanbeaton Yoy may solder after flash and leave it. And other one thing i said: "sensor can not send long range signal"... So, Coordinator will have "long range", but sensors - no.

ptvoinfo commented 6 years ago

I would share a solution for my problem with CC2530 and the ZNP firmware (https://github.com/kirovilya/files/blob/master/CC2530ZNP-Pro-Secure_LinkKeyJoin.hex).

Problem: zigbee2mqtt does not want to connect to CC2530 with correct wiring.

RX - P03 TX - P02 3.3v - VCC GND - GND P20 to GND

Background: The ZNP firmware for CC2530 has the serial boot loader code. This boot loader starts and verifies a checksum of the application code. Then it waits for 1 minute for any commands from UART. 0xEF - skip the boot loader code and go to the normal mode and 0x10 - stay in the boot loader mode forever.

Solution: Send 0xEF to a UART port. I'm not sure, but it is possible we can send this command to zigbee2mqtt when a timeout appears with first initialization attempt.

kirovilya commented 6 years ago

@ptvoinfo It is very-very strange...

I look at code zigbee2mqtt, how it is start zigbee-shepherd:

const shepherdSettings = {
    net: {
        panId: settings.get().advanced.pan_id,
        channelList: [settings.get().advanced.hasOwnProperty('channel') ? settings.get().advanced.channel : 11],
    },
    dbPath: data.joinPath('database.db'),
};
...
shepherd = new ZShepherd(settings.get().serial.port, shepherdSettings);

There is no port parameters. When i start, i set port speed and rtscts:

shepherd = new ZShepherd(port, {
        net: {panId: 0x1a62},
        sp: { baudrate: 115200, rtscts: false },
        dbPath: dbDir+'/shepherd.db'
});

Try to append this parameter on start.

ptvoinfo commented 6 years ago

This does not matter. The same problem appears without zigbee2mqtt. I cannot connect to CC2530 using ZTool too for 1 minute without sending this magic byte (0xEF).