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

@ptvoinfo what the board are you use? I use this https://www.aliexpress.com/item/CC2530-Zigbee-UART-Wireless-Core-Board-Development-Board-CC2530F256-Serial-Port-Wireless-Module-24MHz/32767470382.html without any problem.

ptvoinfo commented 6 years ago

@kirovilya Yes, the same board from the same seller. I can only say "it happens" :)

kirovilya commented 6 years ago

@ptvoinfo thank you for experiens. but i don't know what to do...

james-fry commented 6 years ago

@kirovilya Regarding you comment:

And other one thing i said: "sensor can not send long range signal"... So, Coordinator will have "long range", but sensors - no.

My understanding is that the RF frontend has a low noise amp, and hence the sensitivity of the receiver is increased. So the end device is no "louder" but the coordinator's ability to "hear" is increased. That plus additional gain from a real antenna should, I hope, give additional range for sensors.

kirovilya commented 6 years ago

@james-fry Yes, all true. it is good that you understand this.

james-fry commented 6 years ago

@kirovilya @ryanbeaton FWIW I found the manuals for the USB stick and the SoC here: http://www.gban.cn/yk_Picture/hdp/20140523091382828282.pdf http://www.gban.cn/yk_Picture/hdp/2014052216470315315.pdf

ptvoinfo commented 6 years ago

I've prepared a router firmware for CC2531: http://ptvo.info/cc2531-based-router-firmware-136/ Your comments are welcome!

kirovilya commented 6 years ago

@ptvoinfo good work! will try later.

james-fry commented 6 years ago

Nice job @ptvoinfo. I have updated the wiki with links for your 2530 and 2531 router firmwares. When my new device arrives I will reflash my 2531 as a router and test.

realroywalker commented 6 years ago

Can anyone clarify what equipment is needed to use https://www.aliexpress.com/item/RF-TO-USB-CC2530-CC2591-RF-switch-USB-transparent-serial-data-transmission-equipment/1996354384.html

I see the modifications to connect a few pins above, but does it require ccdebugger AND the downloader cable as described for the other stick in the getting started guide? If so, can anyone confirm if its a specific downloader cable?

Lastly I'm correct in thinking this is currently the easiest setup to go with for best signal?

ptvoinfo commented 6 years ago

@realroywalker The CC debugger and download cable is required in any case. In some cable you need a proprietary cable, in some case you need to solder wires to the board/dongle.

realroywalker commented 6 years ago

@ptvoinfo thank you. I've been searching aliexpress but cannot find any downloaded cable for the cc2530, only cc2531 seems available.

james-fry commented 6 years ago

Looks like only 5 of the 10 pins on the programmer are needed for programming. Maybe the rest are for debugging?

ptvoinfo commented 6 years ago

@realroywalker CC2530 boards: http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/ I've used a cable for CC2531 with the board from the first image. The second board has been temporarily connected using a dupont cable (female - female). Pinout: http://ptvo.info/wp-content/uploads/2018/05/smartrf04eb-pinout.jpg

Koenkk commented 6 years ago

Would it be possible to pair end devices to routers? In this way we can increase the network size. #26

kirovilya commented 6 years ago

Hello again. I flashed CC2531-router-diag-usb.hex to cc2531 stick to make it router... Plug it to external usb-charger. Then I try to pairing... with very interesting messages:

{"type":"devInterview","status":{"endpoint":{"current":8,"cluster":{"total":2,"current":1},"total":1}},"data":"0x00124b0014bdeb6a"}
{"type":"devInterview","status":{"endpoint":{"current":8,"cluster":{"total":2,"current":2},"total":1}},"data":"0x00124b0014bdeb6a"}
{"type":"devIncoming","endpoints":[{"device":{"_id":2,"type":"Router","ieeeAddr":"0x00124b0014bdeb6a","nwkAddr":29547,"manufId":4447,"manufName":"LUMI","powerSource":"Mains (single phase)","modelId":"lumi.router","epList":[8],"status":"online","joinTime":1527614556,"endpoints":{"8":"[Circular]"}},"profId":260,"epId":8,"devId":256,"inClusterList":[0,6],"outClusterList":[0,6],"clusters":{"zapp":null,"genBasic":{"dir":{"cid":"genBasic","sid":"dir","value":3},"attrs":{"cid":"genBasic","sid":"attrs","hwVersion":1,"manufacturerName":"LUMI","modelId":"lumi.router","dateCode":"2018-04-18","powerSource":1,"locationDesc":"","physicalEnv":0,"deviceEnabled":1}},"genOnOff":{"dir":{"cid":"genOnOff","sid":"dir","value":3},"attrs":{"cid":"genOnOff","sid":"attrs","onOff":0}}},"onAfDataConfirm":null,"onAfReflectError":null,"onAfIncomingMsg":null,"onAfIncomingMsgExt":null,"onZclFoundation":null,"onZclFunctional":null}],"data":"0x00124b0014bdeb6a"}

So, device has "1" endpoint (total), but current is "8" and "2" clusters (from "devInterview" message). It is strange, but ok, not bad. And on "devIncoming" it described as "lumi.router". Why "lumi"? :)

Then, every minute it send "attReport" message with data:

{"cid":"genBinaryValue","data":{"description":"0/0x00124B0018558DDF","inactiveText":"COORD","presentValue":86,"relinquishDefault":0,"minimumOffTime":0}}

and in second minute with data:

{"cid":"genOnOff","data":{"onOff":0}}

and then repeated...

Sometimes (I do not undestand how) I see "devChange" with data:

{"cid":"genOnOff","data":{"onOff":1}}

And I know how check work with this router? When I move temperature sensor to other room, it can not send data to coordinator, but router placed between them. Maybe I see it in messages as some attribute?

kirovilya commented 6 years ago

Hmmm, I begin to understand router messages:

{"cid":"genBinaryValue","data":{"description":"0/0x00124B0018558DDF","inactiveText":"COORD","presentValue":86,"relinquishDefault":0,"minimumOffTime":0}}
{"cid":"genBinaryValue","data":{"description":"59437/0x00158D0001F41725","inactiveText":"CHILD_RFD","presentValue":170,"relinquishDefault":2,"minimumOffTime":1}}
{"cid":"genBinaryValue","data":{"description":"38336/0x0000000000000000","inactiveText":"NEIGHBOR","presentValue":0}}

1) Message from coordinator, 0x00124B0018558DDF - it is coordinator 2) Message from sensor 0x00158D0001F41725 - it is temperature sensor 3) Message from xiaomi button, but in paring process...

glsf91 commented 6 years ago

@ptvoinfo (i tried to comment on http://ptvo.info/cc2531-based-router-firmware-136/ but I didn't saw my comment so I try here)

I have a xiaomi sensor which is sometimes out of range of the xiaomi gateway. Is it possible to add your cc2531 router between an existing Xiaomi sensor and the Xiaomi gateway? (as an alternative to the Xiaomi sockets Zigbee edition) If yes:

newzealandpaul commented 6 years ago

Would be great if someone could put together a tutorial on making this work from scratch for us complete n00bs who own a soldering iron but not much else :)

ptvoinfo commented 6 years ago

@kirovilya

The "diag" version of the firmware sends additional reports to the coordinator: http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/

In your case the router reports more info about parent, child and near zigbee devices.

{"cid":"genOnOff","data":{"onOff":1}}

This is a simple "keep-alive" report and allows you to control presence of the router.

ptvoinfo commented 6 years ago

@newzealandpaul

  1. Take a CC2531 dongle
  2. Flash my firmware to this dongle: https://github.com/Koenkk/zigbee2mqtt/wiki/Getting-started
  3. Put this dongle to any power source with an USB socket (for example, from any mobile phone)
  4. Pair it with a gateway.
  5. Put the dongle + power source to a wall power socket somewhere between your gateway and remote zigbee sensor.
newzealandpaul commented 6 years ago

@ptvoinfo I meant a long range version, I already have a CC2531. I read your tutorial, but it looks like it needs a antenna soldered onto the board:

http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/

Or should I just use one with USB like this (much more expensive):

https://www.aliexpress.com/item/CC2530-Zigbee-Core-Board-Development-Board-Kit-IOT-Smart-Home-Wireless-Module-Packet-24MHz-256KB/32767454609.html?spm=2114.10010108.1000023.21.68ad410fMUAP3g

ptvoinfo commented 6 years ago

@newzealandpaul

CC2531 has an antenna already. If CC2531 based router does not cover all your areas then add more routers. In most cases it will work better than a single CC2530 with an external antenna.

newzealandpaul commented 6 years ago

@ptvoinfo ah I understand, thank you :) I will do that.

kirovilya commented 6 years ago

@ptvoinfo Thank for response. But how check that sensor successful work with this router? I could not confirm that the temperature sensor is working from another room through the router ... I did not receive any messages from it.

Koenkk commented 6 years ago

@ptvoinfo Are you sure this is the right link?

Flash my firmware to this dongle: https://github.com/Koenkk/zigbee2mqtt/wiki/Getting-started

ptvoinfo commented 6 years ago

@Koenkk In case of CC2531 the link is correct except a firmware file. @kirovilya Good question: I've used a standard ZStack sample application just changes some small things (PanId, channel, security key, regular reports). In your case you see the temperature sensor is connected to the router.

kirovilya commented 6 years ago

@ptvoinfo

temperature sensor is connected to the router

So I'm thinking how it will be displayed: any attributes in the message? or will messages from the sensor just come?

ptvoinfo commented 6 years ago

I've tested my routers:

  1. I've removed all Xiaomi plugs. Therefore only my own routers worked at this time.
  2. Pressed a small button on the temperature sensor shortly and blue light blinks.
  3. Coordinator received a message from the sensor.

Note: The coordinator is 30m away and 8 brick walls. Without routers it does not receive messages from this sensor.

Note 2: The CC2530 router with the external antenna work better than CC2531

kirovilya commented 6 years ago

@ptvoinfo Okay, once again I'll try with cc2531. If it does not work, I'll try the cc2530 with the antenna.

Koenkk commented 6 years ago

@ptvoinfo would you mind sharing your firmware source code? I've setup a repo here: https://github.com/Koenkk/zigbee2mqtt-firmware

dgomes commented 6 years ago

This project needs to move into an organisation ;)

james-fry commented 6 years ago

@ptvoinfo Are you sure this is the right link

The links for all router (and coordinator) firmwares are here: https://github.com/Koenkk/zigbee2mqtt/wiki/Supported-sniffer-devices

ptvoinfo commented 6 years ago

@james-fry the people ask for instructions how to flash each of these boards. Step-by-step, for noobs :)

james-fry commented 6 years ago

Will be happy to help - either with 1st hand advice where I have a board, or by updating wiki with advice/procedure from others

ciotlosm commented 6 years ago

@ptvoinfo @kirovilya @james-fry @Koenkk maybe move firmware hex files for router in a common place here: https://github.com/Koenkk/zigbee2mqtt-firmware?

I recommend to keep a structure like:

- firmware
      - coordinator
          - CC2531
          - CC2530
          - CC2530-RFX2401
          - CC2530-CC2591
      - router
          - CC2531
          - CC2530

A README.md file in each folder for credits and linking to the location of the flashing documentation would be great. Maybe even links to tools used to build the firmware?

Maybe even add source files for firmware builds in a mirror structure?

- firmware-src
      - coordinator
          - CC2531
          - CC2530
          - CC2530-RFX2401
          - CC2530-CC2591
      - router
          - CC2531
          - CC2530

@Koenkk Considering testing usually ends up being the new stable, I think a better structure would be to drop "stable" and use branches on top of this same structure, allowing for easier "merge" back to "master"/"stable". What do you think?

booking100 commented 6 years ago

Is this board possibly interesting?

https://www.ebay.com/itm/Zigbee-Module-CC2530-/321149891328

If I understand everything correctly it has the advantage of an external antenna (CC2530) and additionally a debug interface (CC2531) for programming. Has anyone had any experience with this?

Koenkk commented 6 years ago

@ciotlosm that would be a perfect structure, can others share the firmware source code so that it can be added to the repo?

1981nick1982 commented 6 years ago

Is there a tutorial available for the CC2530? Would like to order this but first want to know how it can be connected to the cc debugger and my pi.

ciotlosm commented 6 years ago

@1981nick1982 check http://ptvo.info/cc2530-based-zigbee-coordinator-and-router-112/

1981nick1982 commented 6 years ago

Had read that but it was not entirely clear how the board should be linked to the cc debugger and usb for connection to PC and Rpi. If I understand correctly, should I use the pinout of this diagram to connect the CC2530 to the CC debugger / CC2531 cable? http://ptvo.info/wp-content/uploads/2018/05/smartrf04eb-pinout.jpg

And use USB to TTL - Aliexpress for the link to the pi?

I connect this stick as follows:

TX = P0_3 RX = P0_2 RST = P0_5 GND =? 3V3 =? 5V =?

ciotlosm commented 6 years ago

@1981nick1982 I think this thread is already too big to follow. Would you be so kind to open a separate thread for the specific CC2530?

On how to:

That can be later transformed into a wiki how-to.

james-fry commented 6 years ago

@ryanbeaton Just got my USB device from China (well actually it arrived over a week back but I have been away). I didnt realise from @kirovilya info, but mine came with a debugger cable and the header. You will need to solder the header to the pcb, but not to make any custom cable to flash the device.

ryanbeaton commented 6 years ago

@james-fry I cracked open my cc2530+RFX2401 but it does not have the header soldered and didn't come with one loose or a debugger cable :(

Up running with a CC2531 for now thanks to @palitu for the loan of his SmartRF04EB πŸ‘

Will come back to the CC2530 as soon as possible.

james-fry commented 6 years ago

it does not have the header soldered and didn't come with one loose or a debugger cable :(

This is what came with mine: img_0708

Maybe aske the seller on aliexpress if you didnt get one too?

realroywalker commented 6 years ago

@kirovilya - My stick has arrived from china - cc2530+RFX2401 (the one with GB2530 you linked in an earlier post).

I made the mods to connect pin 04,06,20 to GND as per the picture posted earlier.

My stick didn't come with debug cable/header like @james-fry posted, so I've used dupont cables and can make a solid connection between ccdebugger and the stick.

However - the CCDebugger light is permanently red.. I've tried plugging both the stick and ccdebugger in USB as the same time, just ccdebugger, updated firmware on the ccdebugger but it refuses to detect the stick. Should I not have made the soldering mods to connect 04/06/20 into GND until the stick is flashed ?

mali1 commented 6 years ago

Have you tried pressing the reset button on the debugger while both devices are plugged in and connected?

ciotlosm commented 6 years ago

@realroywalker @mali1 Can you guys please open a new issue with the specific device you're trying to flash? This ways it's easier to extract documentation for that and we avoid bloating this already very long topic.

james-fry commented 6 years ago

This issue is now closed per @ciotlosm recommendation. Going forward please open new issues for hardware specific issues,

luci-11 commented 6 years ago

Can anyone try with latest dev branch, latest fw for coordinator and CC2531 router fw , if it's still possible to pair a xiaomi device through CC2531 router? It's the procedure the same as pairing to coordinator i.e. just pressing buttons on sensors? Sorry if I keep asking but I do not manage to do it in any way. The sensor blinks as when requiring pairing but then nothing happens, it simply has "no answers back"