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?

h4nc commented 5 years ago

I ordered the same one, so we are in the same boat now. Let's see how it will affect the range.

mrfoxbit commented 5 years ago

Can I use the cc2530 + CP2102 Module USB To TTL as coordinator?

Pin Setup:

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

image

image

ranseyer commented 5 years ago

I use it. Be carefull. Some of the blue CP2102 Modules have 4,7V (or so) at the 3,3V Pin...

My Design: https://github.com/ranseyer/home-automatics/tree/master/ZigBee photo2 top bot

mrfoxbit commented 5 years ago

That custom pcb is out of my skills. So, Can I connect direct CC2530 to CP2102 Module USB To TTL and use it as like as CC2531 sniffer USB dongle?

h4nc commented 5 years ago

The antenna has two pins. Could someone here explain what the two pins are used for and which one is the antenna?

The reason I'd like to know this is because I want to use one of these antennas in another setup too (sonoff basic) and these devices only have one antenna pin. Is it possible to use only one pin of the antenna? If yes which one?

Would be nice to understand those antennas.

ranseyer commented 5 years ago

The middle pin is the more important. If the PCB has a big ground-plane it could be enough to have the midlle pin, or only a wire with lambda/4. Problem wit 2,4 GHz Antenna is that Labda/4 is too small to cut it really exacly. In your case you would use an antenna that have only the middle pin connected.

Here some picture from me: https://forum.fhem.de/index.php/topic,93021.msg856053.html#msg856053

I use in that case some old antennas from old WIFI routers...

CU

h4nc commented 5 years ago

Ok, thanks. Just to be clear. Is the second pin an electrical shielding? Why does the PCB have to have a big ground-plane?

I already connected a wire to my device, I think about 17cm long (I read that somewhere). Some of those devices work ok but a better signal would be good. I was hoping to get a better signal changing from the wire to an wifi-antenna. First it worked (signal from 50% to 60%), but the device looses the connection every few minutes and reconnects. So I switched back to the cable I think I'll leave it like that (should never change a running system) but I'd like to know why it did not work.

I ordered those parts for the Coordinator but I'm interessted: How long should the wire for the CC2531 be? Is the antenna (with the electrical shield??) better than the wire and why?

Thanks a lot!

ranseyer commented 5 years ago

I think about 17cm long

Sounds bad for me.

The only thing 2.4 GHz really tells you is that the wavelength is c/f = (3e8 m/s)/(2.4e9 1/s) = 0.125 meters = 4.92 inches

This topic is a bit more complex. The wire has to be Lambda/4 or Lamda 1/2 or Lambda 5/8. => Important, you have to to google "wavelength lambda/4" to understand it.

Why big grund plane?

You need a dipol, or something like the groundplane: https://searchmobilecomputing.techtarget.com/definition/ground-plane-antenna

When you take a look at the groundplane, you have only the main element, for a partial replacement of the radials you use the big ground-plane on the pcb. The PCB or a metalcase is not as good as the radials, but better than nothing.

If you want to connect all kinds of good antennas you need a correct antenna socket like RP-SMA.

Please respect you local law and regulations for antennas and "ERP".

h4nc commented 5 years ago

Thanks for your answer! I have some left open questions.

1) How will a wrong length of the antenna affect the signal? Is it like a binary status (work or doesn't work) or will it make the connection worse?

2) I connected the antenna with a wire. I think this wire adds up to the length of the antenna and will most probably lead to question one because of a wrong lenght. https://de.aliexpress.com/item/Dlenp-4-teile-satz-2-4-ghz-Antenne-f-r-wireless-router-RP-SMA-M-nnlichen/32862602967.html?spm=a2g0s.9042311.0.0.342d4c4dv6XlKi I cut the wire and connected the middle pin wire to the antenna trace of the pcb.

3) I will leave it like it is now. Currently a wire (that is probably not lamda/4) is connected and it works. The wire goes threw a hole of the pcb and than is lead out of the case. How will the orientation of the antenna wire affect the signal? The cable is not straight and hangs out of the case. Also it makes a 90° turn in the case. How should it be orientated.

ranseyer commented 5 years ago

Is it like a binary status

No. The more wrong, the more loss of radiated power...

Koenkk commented 5 years ago

I've written a tutorial on how to create a CC2530 router. (https://github.com/Koenkk/zigbee2mqtt/blob/dev/docs/how_tos/how_to_create_a_cc2530_router.md)

h4nc commented 5 years ago

No. The more wrong, the more loss of radiated power...

Do you know if a wrong length affects the radiated power linear or exponential (or other function)?

matejzero commented 5 years ago

I've written a tutorial on how to create a CC2530 router. (https://github.com/Koenkk/zigbee2mqtt/blob/dev/docs/how_tos/how_to_create_a_cc2530_router.md)

Great! I was just looking for a router howto, because I have to build a few of them to cover my home.

ErneX commented 5 years ago

I've written a tutorial on how to create a CC2530 router. (https://github.com/Koenkk/zigbee2mqtt/blob/dev/docs/how_tos/how_to_create_a_cc2530_router.md)

Great stuff, thanks!

You can find the enclosure @ aliexpress by searching for: 100x68x40mm

matejzero commented 5 years ago

This might come handy: Ikea has put out a ZigBee range extender that also looks nice.

At the moment, it can be bought in Sweden shops: https://www.ikea.com/se/sv/catalog/products/10400408/

h4nc commented 5 years ago

I already got my sma connectors from china. This is how my CC2531 looks now.

img_8083-2 img_8084-2 img_8086-2 img_8087-2

EDIT: I noticed an error at the start up of the hassio addon (edge). I recently switched from the "normal" version to edge, so I don't no if this error is related to the new addon or my antenna mod. Maybe @Koenkk can help? Is this a known error for edge?

EDIT2: After a restart of the addon (to copy the error) it did not appear again. I repeatet that several times but seems like it is gone. Unfortunatley I did not save it at the first time.

EDIT3: I'd like to add that the linkquality of both of my routers is significantly better now. From around 10 to around 35.

EDIT4: If you are interessted in buying one of these (case is different now see) you can contact me in the home assistant community (username h4nc) or via email here: h4nc.zigbee(a)gmail.com

talondnb commented 5 years ago

What’s the error?

h4nc commented 5 years ago

What’s the error?

I had a look into the log files.

2019-1-18 10:32:25 - error:  Error: Port is already open
    at SerialPort.open (/app/node_modules/serialport/lib/serialport.js:222:29)
    at CcZnp.init (/app/node_modules/cc-znp/lib/ccznp.js:141:8)
    at Promise.post (/app/node_modules/q/q.js:1181:36)
    at Promise.promise.promiseDispatch (/app/node_modules/q/q.js:808:41)
    at /app/node_modules/q/q.js:1411:14
    at runSingle (/app/node_modules/q/q.js:137:13)
    at flush (/app/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)

It fixed itself after two or three reboots.

EDIT: I think was I did first was Restart, after that the error reappeared. Than I stopped the addon and startet it again.

fred-c1 commented 5 years ago

@h4nc , the mod could not be done better The RP-SMA connector opens a lot of possibilities:

creativtransfer commented 5 years ago

Here's a nice tutorial on how to add an SMA antenna socket, somewhat similar to what h4nc did: https://hackaday.io/project/163505-cc2531-usb-adapter-antenna-mod

h4nc commented 5 years ago

Thanks for that share. That looks better than mine.

hvddrift commented 5 years ago

Here's a nice tutorial on how to add an SMA antenna socket, somewhat similar to what h4nc did: https://hackaday.io/project/163505-cc2531-usb-adapter-antenna-mod

Thanks for the instructions...

Could you elaborate a bit more on what this means?

Also note that I've removed a little bit of soldermask on the end of the pcb antenna and the groundplane close to it.

Don't forget to solder the ground trace/bridge on the left side.

creativtransfer commented 5 years ago

Basically it means that you can solder the open end of the pcb antenna (which is now connected to the outside of the SMA socket) on the left side to the closest groundplane in order to keep unwanted RF effects at a minimum.

fred-c1 commented 5 years ago

Soldermask = the green (typically) varnish which protects the copper outside solder areas. This varnish is resistant to most solvants and heat => remove it by scrapping with a sharp blade

james-fry commented 5 years ago

@creativtransfer and @h4nc in real world how much increase in range did you get from this mod? I went down the route of buying the CC2530+front end USB dongle from Aliexpress as discussed months earlier in this thread, but I was never able to flash it (I think its faulty since same flasher was OK for flash my cc2531). Im not really happy to drop another $30 on another CC2530 dongle and this is a much less expensive option that might work as well for my use case...

h4nc commented 5 years ago

I don't have hard facts on how much increase I get. All I can say is that the linkquality rised from around 10-20 too 30-40.

All my devices worked before that mod.

As fred-c1 mentioned before the sma connector gives you the possibility to add bigger antennas. Maybe this would solve your issues. Also those antennas are cheap on aliexpress.

talondnb commented 5 years ago

@creativtransfer and @h4nc in real world how much increase in range did you get from this mod? I went down the route of buying the CC2530+front end USB dongle from Aliexpress as discussed months earlier in this thread, but I was never able to flash it (I think its faulty since same flasher was OK for flash my cc2531). Im not really happy to drop another $30 on another CC2530 dongle and this is a much less expensive option that might work as well for my use case...

Do you mean the GBAN dongle?

james-fry commented 5 years ago

Thanks. I already have a spare antenna from the nonfunctioning CC2530+front end USB dongle :) I think I'll give this a go when I have some spare time.

james-fry commented 5 years ago

@talondnb - yes the GBAN one. It would not show up in the programmer as a firmware install target. It did connect on USB OK though.

talondnb commented 5 years ago

@talondnb - yes the GBAN one. It would not show up in the programmer as a firmware install target. It did connect on USB OK though.

Ahh ok, and you performed the jumpering for this dongle?

I actually did the flashing through cc-tool on Mac terminal. Real quick and easy and shows the progress, etc. Let me know if you'd like to go through it..

james-fry commented 5 years ago

Yes - I tried flashing with both no jumpering and with soldered jumpering - see below. I have a mac too so if you have a link to the cctool process on osx (or happy to pm me) I'd love to give that a try too - thanks!. I spent too long on win10 messing with drivers etc to try to get the gban to show up as USB device.

gban

talondnb commented 5 years ago

@james-fry https://github.com/Koenkk/zigbee2mqtt/issues/302#issuecomment-433362573

talondnb commented 5 years ago

@james-fry https://koenkk.github.io/zigbee2mqtt/getting_started/flashing_the_cc2531.html

Sorry I've no idea how to pm on here, feel free to shoot me a message at amunday@gmail.com.

james-fry commented 5 years ago

Thanks for the link. Actually not sure you can PM :)

creativtransfer commented 5 years ago

See also https://hackaday.io/project/163487-zigbee-cc2531-smart-home-usb-adapter If you don't have a CC Debugger

james-fry commented 5 years ago

Thanks @creativtransfer. Actually I do have cc debugger and I used it successfully to flash a cc2531, but it would not flash this GBAN device. Nonetheless I will try the other tool approach before I consign this GBAN the to bits box :)

fred-c1 commented 5 years ago

A little bit off topic but I am reacting to the above picture of the GBAN unit. For GBAN unit or any other CC2530 + RF front end: you may want to have a look here: https://github.com/Koenkk/zigbee2mqtt/issues/794

james-fry commented 5 years ago

@talondnb @creativtransfer - thanks for the inputs. Bizarrely I managed to get it to flash under windows using the TI smartRF flasher. Maybe its because I was messing around with drivers for the debugger last time I tried. or maybe its because I removed the jumper between pins 9 and 10 on the mini pcb that links the debugger to the dongle (see in this image: https://user-images.githubusercontent.com/5823294/41374969-9173f154-6f4c-11e8-91f2-b08ff55ba67f.jpg). anyway now its working :D

woody4165 commented 5 years ago

Hi all

I've a CC2531 flashed as described https://koenkk.github.io/zigbee2mqtt/getting_started/flashing_the_cc2531.html and it's working. Now I've got a CC2530, like this oone schermata 2019-02-03 alle 12 20 04 and flashed with the firmware found here https://github.com/Koenkk/Z-Stack-firmware/tree/master/router/CC2530/bin, the file router-cc2530-std.hex. In Hassio, I've loaded the addon Zigbee Map, but I don't see any "router" that is not a device that I already have and that have specific name, like "OSRAM LIGHTIFY LED" that work as router.

The CC2530 is connected to a CP2102 (I've tried also with a CH340G) connected to 3.3V and GND.

I don't see any led turning on, don't know if there is one.

Any suggestion on how I can check if all is working? The CC2530 should automatically become part of my zigbee network ?

Thanks

h4nc commented 5 years ago

As with other devices you will have to add those routers to your network. So enable “add devices” and plug in those routers near the coordinator.

After connecting you should see them in your configuration.yaml (of zigbee2mqtt)

woody4165 commented 5 years ago

Thanks @h4nc Even if the CC2530 does not have any button to click, I just plugin the USB to power it on near the CC2531 and this should do the trick?

h4nc commented 5 years ago

Yes, but this will only work with a router that wasn’t connected before, else you need to reflash it (because no button to reset)

woody4165 commented 5 years ago

Sorry, I don't understand... Should I flash again the CC2530 same as I did it before?

h4nc commented 5 years ago

No, if it wasn’t connected before, you just have to add it as decribed above.

woody4165 commented 5 years ago

Sorry, my english is not good enough, or I don't get it... :-( What should I do? Thanks

h4nc commented 5 years ago

Or maybe it’s my english that isn’t good enough. ;)

1) flash your router 2) turn on “add devices” in zigbee2mqtt (permit_join":true) 3) power up your router near your coordinator 4) watch the log of zigbee2mqtt for the router to appear, should also add some lines in your configuration.yaml

Hope this helps. Mind that the first point isn’t necessary if you already flashed your device (and it wasn’t connected before).

woody4165 commented 5 years ago

Thanks @h4nc

I've done exactly your steps and positioned the router near the coordinator and now I can see it in the Zigbee Map!!!

basmeerman commented 5 years ago

Ok, so I was having some trouble getting good reception of Zigbee signals inside our house (new, concrete). The mesh was based on 4 CC2531's. So I thought about upgrading the mesh with two sensitive CC2530's. I thought, ok it was a pain getting everything paired, but while the last couple of months net firmware came out and Zigbee2MQtt was significantly improved. Let's try!

I bought two CC2530+RFX2401, soldered both (pins as instructed), flashed them, one as a coordinator, one as a router. Changed the existing config to disable "rtscts", enabled "auto-join", and bind to the right USB device. Put the coordinator into the USB port and ran Zigbee2MQTT. All well. I was able to pair 1 Xiaomi Aqara button quite easy as well as 1 Ikea Outlet (router).

After that things got tricky.

I'm trying to pair my routers first to the coordinator and then make a loop around the house to include all sensors again (Xiaomi).

I'm having trouble pairing the last 2 Ikea (of 4) Outlet plugs, Logs are constantly complaining about Node Descriptors timeouts and since I had them laying around I flashed 3 CC2531's with the router firmware. But can't get them to join as well.

a) Does everyone have such isssues on pairing new devices (how common are my issues)? b) Is it most likely interference (the devices are on a raspberry pi next to zwave/wifi/access points, although I;m trying to pair from a couple of centimeters distance)? c) Does Zigbee Shepperd only allow for new devices to be discovered the first somewhat minute after startup? I found no pairing was possible after about 1-2 minutes.

Anyone any tips/tricks as to how I'm able to rebuild my Zigbee mesh (about 50 sensors), since I thoroughly broke it with the upgrade :-) Wife acceptance factor is deteriorating rapidly.

Any help is appreciated.

Kind regards.

Bas

h4nc commented 5 years ago

I cannon help you with your issue. But I‘d like to know about that „auto-join“ feature. Did not find it in the docs?

Do you simple mean permit join: true always on? If yes I don’t think that’s a good idea (security).

basmeerman commented 5 years ago

I mean the later one, and agree with you for security purposes, first point on the agenda though is a working mesh. Thanks.