Zigbee Switch Configurable Firmware (+Router)

This firmware allows you to create a Zigbee switch device with a flexible configuration of inputs and outputs. I’ve created a base firmware for CC2530, CC2530 + CC2590 , CC2530 + CC2591 and CC2530 + CC2592 chips. The attached configurator for Windows can write your device configuration to the selected base firmware. Then you can save the customized version to a separate HEX file and upload it to your device.

Inputs and outputs can work independently. So you may create a switch without a control button, or a simple button only.

The device with this firmware also works as a router.

Note: the firmware is designed for constantly powered devices.

Options

Fig.1 The configuration window

Remember state – The firmware saves the output state to NVRAM and restores it after power off/on.

Link – The input immediately controls the state of the corresponding output. The device sends the on/off state of the output to a coordinator. Otherwise, the input is independent.

Long – The firmware detects and reports to the coordinator a long click (2000 ms).

Double – The firmware detects and reports a double click (max 500 ms between clicks).

Triple – The firmware detects and reports triple-click (max 500 ms between clicks).

Zigbee internals

  1. The firmware creates a separate endpoint (1..5) for every configured output and/or input (max 5 endpoints).
  2. The firmware reports the state of an independent button via the “ZCL_CLUSTER_ID_GEN_MULTISTATE_INPUT_BASIC” cluster and the “PRESENT_VALUE” attribute. 1 – single click.
    2 – double click.
    3 – triple-click.
    4 – long click.
  3. The firmware does not send a separate report for the linked button. Otherwise, it sends reports about the output state via the “ZCL_CLUSTER_ID_GEN_ON_OFF” cluster and the “ON_OFF” attribute.
  4. You may control the output state via the “ZCL_CLUSTER_ID_GEN_ON_OFF” cluster and the “ON_OFF” attribute.
  5. The “ZCL_CLUSTER_ID_GEN_ON_OFF” cluster also accepts the “read”, “configure” and “onOffWithTimedOff” commands: “read” – returns the current state on the specified endpoint.
    “configure” – set the periodic reporting interval for the output. The “minReportInt” attribute specifies the reporting interval in seconds. If “minReportInt” is 65535, the firmware disables periodic reports. “onOffWithTimedOff” – sets the output state to “HIGH” for “onTime” milliseconds, and automatically resets to “LOW”.

Updates

2020-04-01 Released v2.
2019-08-14: Fixed bug with 3rd and 4th inputs.
2019-06-27: First release.

Download

Download firmware


Comments
Harvey Specter
Posted at 12:32 October 16, 2020
Dmitry
Reply
Author

Am I can somehow use all 16 gpio as inputs? Or are you planned to create similar firmware?

    Harvey Specter
    Posted at 14:06 October 16, 2020
    Owner
    Reply
    Author

    Hi! Sorry. You cannot do it. Also, I didn’t plan to implement this configuration.

Harvey Specter
Posted at 15:51 September 13, 2020
Emmanuel_FR
Reply
Author

Hi,

I tried today to make my custom firmware : it just took me the time to wire, to find the netword key in hex, generate the firmware and… voilà !!! One minute later, I had a switch on Domoticz and was able to check that indeed I could output a logical signal. The only problem I had was to cycle the power and remove the CC-Debugger connections before pairing (not sure it was necessary…).

This is so great, many many thanks for this excellent work !! Do you have a Paypal accound to pay you a virtual beer?

Cheers !

Harvey Specter
Posted at 14:26 August 17, 2020
Saeid
Reply
Author

Hi,
Thanks for the great work. I just flashed a simple switch and usual ON/OFF and reading status works just fine.
By I cannot make the onOffWithTimedOff feature to work.
This and some other guesses did not work:
mosquitto_pub -t zigbee2mqtt/0x00124b000ef0b755/l1/onOffWithTimedOff -m 1000

I was not able to find any example of using the TimedOut feature anywhere on the web or in this blog.
Is onOffWithTimedOff supported by Zigbee2mqtt? If yes how it can be exploited?
If not shall I try to create a pull request?

    Harvey Specter
    Posted at 14:48 August 17, 2020
    Owner
    Reply
    Author

    Sorry, but the firmware does not this command.

      Harvey Specter
      Posted at 14:16 August 19, 2020
      saeid
      Reply
      Author

      Which firmware do you exactly mean?
      The generated firmware created by this tool.
      If yes what does this mean in the readme file:

      The “ZCL_CLUSTER_ID_GEN_ON_OFF” cluster also accepts the “read”, “configure” and “onOffWithTimedOff” commands: “read” – returns the current state on the specified endpoint.
      “configure” – set the periodic reporting interval for the output. The “minReportInt” attribute specifies the reporting interval in seconds. If “minReportInt” is 65535, the firmware disables periodic reports. “onOffWithTimedOff” – sets the output state to “HIGH” for “onTime” milliseconds, and automatically resets to “LOW”.

Harvey Specter
Posted at 15:45 June 25, 2020
Shah
Reply
Author

Hi,
The sensor works just fine, in an attempt to make it more reliable I have enabled watchdog setting in the firmware builder.
I find that the sensor stops communicating sometimes with coordinator (Zigbee2mqtt), however the link led still blinks as if it is connected- and once it is power cycled it reconnects. ( I am not sure if this issue is from coordicator side or the sensor itself other sensors work when some fail) Is the watchdog timer set to reboot the device? or re-attemp connection to co-oordinator after connection failure?. Can LED change its status again once it looses connection? On a separate note:
Is it possible to select/define the network-ID as well with the network-key for dedicated networks? or it is a feature request?
Can the default re-set process be set to say more than 3 times power cycling say 5 times etc to make it more solid.

Thanks again for this wonderful tool that you have created Kudos for that, it has really separated programming layer away from its utility.
I hope/wish future releases would address some of these desired features?

    Harvey Specter
    Posted at 03:56 June 26, 2020
    Owner
    Reply
    Author

    Hi.
    If LED blinks it means that the firmware is working. So, the watchdog timer works, or the firmware is stable :).
    You may define network parameters on the “Expert” tab.
    The number of cycles: some users cannot repeat 3 times, so 5 times is the impossible mission :-).

    Harvey Specter
    Posted at 07:52 August 20, 2020
    Saeid
    Reply
    Author

    Thanks. That was exactly what I was looking for

Harvey Specter
Posted at 05:45 June 22, 2020
S. Shah
Reply
Author

Hi, this was probably caused by flaky module, I changed the module and glad to know that all worked just fine as expected.
Here is the config that I used just FYI: when it was not working the GPIOS were tried with varius settings ( pull ups/down/tri) but the results were the same.
Board type: CC2530
Update firmware’s timestamp : 2020-06-16
Enable watch dog timer: Yes
Power saving mode (PSM): No
Status LED: Yes (Inversed)

Output pins:
P11: Output 1, GPIO, Pull-down, Remember state
P12: Output 2, GPIO, Pull-down
P13: Output 3, GPIO, Pull-down, Remember state
P14: Output 4, GPIO, Pull-down, Remember state
P15: Output 5, GPIO, Pull-down, Remember state
P16: Output 6, DS18B20, Pull-down (AA-BB-CC-DD-EE-FF-01-02)

Input pins:
P01: Input 1, GPIO, Pull-down, Link to out 1
P02: Input 2, GPIO, Pull-down, Switch, Link to out 2
P03: Input 3, GPIO, Pull-down, Switch, Link to out 3
P04: Input 4, GPIO, Pull-down, Switch, Link to out 4
P05: Input 5, GPIO, Pull-down, Switch, Link to out 5

Harvey Specter
Posted at 21:19 June 18, 2020
S. Shah
Reply
Author

Hi, I am using P03,P04,P05 inputs with pushbuttons to ground ( door sensor). all works but when the devices is powercycled with any of the pushbutton on, stops working wont join the network the status will start flashing. I have to remove the switch and re-join. The sensor works fine when the device is allready on. but any powercycle with the pushbuttons (doors) on loose connections.
The GOIP are configigured with pull-ups… how can we make sure it boots fine when the pushbuttons are on.
Thanks a lot for this tool, it really is great

    Harvey Specter
    Posted at 03:57 June 19, 2020
    Owner
    Reply
    Author

    Hi. Please, show your configuration. The firmware saves it to a text file.
    Try to shift inputs and outpus and do not use Input 1.

Harvey Specter
Posted at 12:37 May 26, 2020
David
Reply
Author

Hi

Hi, excellent project! 🙂

I am trying to get an DHT22 working, a little confused about the usage of “Input” and “Output” – are they effectively:

+ Input: “read” as in read a GPIO/sensor attached to the device
+ Output: As in “Publish” as in publish the readings to the Zigbee network?

My aim is to get the module to report every 60 seconds with the temperature and humidity. It has produces a reading once so far (so its wired up correctly) but never again after that…

I would also like it to read A GPIO and send a message when the state changes (along with reading the DHT 22) – is that possible?

Any help would be greatly appreciated 🙂

    Harvey Specter
    Posted at 12:48 May 26, 2020
    Owner
    Reply
    Author

    Hi. I would recommend configuring your sensor on the first output. Inputs are related to GPIO inputs (buttons). The firmware should read values from the sensor every 60 seconds and report to the coordinator.

      Harvey Specter
      Posted at 21:14 May 27, 2020
      David
      Reply
      Author

      That got it working! Thanks for your help 😀

Harvey Specter
Posted at 08:23 May 26, 2020
Hung Le
Reply
Author

Hello ptvo,
How to force device leave zigbee network and connect to another zigbee network?
In the moment, I am reflash CC2530

    Harvey Specter
    Posted at 10:06 May 26, 2020
    Owner
    Reply
    Author

    Please, look at the “README” file for an alternative method.

      Harvey Specter
      Posted at 02:51 May 27, 2020
      Hung Le
      Reply
      Author

      Nice document. I am clear everything

Harvey Specter
Posted at 05:45 May 13, 2020
Shah
Reply
Author

Thanks for your feedback, I actually ment monitoring a pushbutton/ reedswitch, door switch etc as an end device powered by battery would be awesome too. Thanks for this great tool again with this tool transition to cc2530 became very easy.

Harvey Specter
Posted at 17:10 May 12, 2020
Tom
Reply
Author

Thank you for your job.
I’m using it with zigbee2mqtt on cc2530 modules with enabled status led.
Sometimes after power reset this module wan’t connect to my zigbee network.
To fix it I need enable “Allow devices to join” option and wait some time or send command to triger output.
Is it normal behavior ?
Is it possible to enable debug on serial port ?

    Harvey Specter
    Posted at 03:59 May 13, 2020
    Owner
    Reply
    Author

    Hello,
    No, it is not normal behavior. The configurable firmware does not provide debug output.

      Harvey Specter
      Posted at 16:01 September 9, 2020
      piotns
      Reply
      Author

      Hi, thanks for that firmware, it is brilliant thing for Z community.
      And now about pain… I have a same behaviour on 2530+2592 (E18-MS1PA1-IPX) with 2.5 firmware. Have any thoughts? Maybee problem in power supply? In my case this is a 5V 2A power supply. In my config i use ony 3 pull-up outputs (1.2, 1.3, 1.4). Thanks.

        Harvey Specter
        Posted at 03:27 September 10, 2020
        Owner
        Reply
        Author

        You may try to re-flash the module or reset it using a power on/off sequence.

          Harvey Specter
          Posted at 05:04 September 10, 2020
          pilotns
          Author

          I did it few times.. after that, module work about 4-6 hours and all repeats. I did try to use 2 various modules and did receive same behaviour… but in my network successfully work 2 another modules on your firmware.. last chance is try to change power supply…

Harvey Specter
Posted at 02:30 May 12, 2020
Shah
Reply
Author

Battery powered switches version would be awesome as well. Thank you for this amazing tool.

    Harvey Specter
    Posted at 04:04 May 12, 2020
    Owner
    Reply
    Author

    Hello. The switch cannot be battery powered, because of the constant current drain through the pin.

Harvey Specter
Posted at 13:48 April 25, 2020
Martin
Reply
Author

I’ve tried to setup an input as external pulldown. With this, there seems to bee a crash. The status led begins to blink a few times, goes off, blinks and so on. The modul didn’t connect to the Z2M. When I change to external pullup, it’s working fine

Harvey Specter
Posted at 10:17 March 24, 2020
Aden
Reply
Author

I see that all the relay switch outputs show up in z2m, even if none are defined in the firmware setup.

eg.

– 0x0000000000000000_switch_bottom_left
– 0x0000000000000000_switch_bottom_right
– 0x0000000000000000_switch_center
– 0x0000000000000000_switch_top_left
– 0x0000000000000000_switch_top_right

I am only using this for input, not output, so these extra endpoints are quite annoying to have automatically populated into Home Assistant.

Any thoughts on a fix?

    Harvey Specter
    Posted at 10:42 March 24, 2020
    Owner
    Reply
    Author

    Hi. All possible endpoints should be programmed in Z2M to provide support for all possible variants.

Harvey Specter
Posted at 01:47 March 24, 2020
qlwz
Reply
Author

I want to add 5 outputs and fix led bug, can you send me the code?

Harvey Specter
Posted at 10:05 March 23, 2020
Dmitry
Reply
Author

Hi, is it possible to use more than 5 outputs?

    Harvey Specter
    Posted at 10:45 March 23, 2020
    Owner
    Reply
    Author

    Hi.
    My firmware supports up to 4 output pins.

Harvey Specter
Posted at 06:44 March 23, 2020
Olili
Reply
Author

in my environment all DIY-software (yours and mine) based on the Z-Stack12 and patches @ Koenk are not answering on a LQI scan request.
After adding this 2 defines it worked for me (at least for my SW).

Simply create a network map with z2m and see what your DIY-SW is showing.

O

    Harvey Specter
    Posted at 09:18 March 23, 2020
    Owner
    Reply
    Author

    #define MT_ZDO_MGMT adds LQI automatically.

« Older Comments

Leave a Reply to Owner
Cancel Reply