Pull-up or Pull-down
In electronic logic circuits, a pull-up resistor or pull-down resistor is a resistor used to ensure a known state for a signal (wiki).
- Pull-up – this option enables the internal pull-up resistor. For GPIO inputs, it means that the pressed state is the LOW signal (connected to the ground).
- Pull-down – For GPIO inputs, it means that the pressed state is the HIGH signal (connected to +3.3V via a 4700 Ohm resistor). You cannot mix internal pull-up or pull-down resistors on the same port.
- External pull-up – similar to the internal pull-up resistor, but you should add it externally on your PCB. It is the main disadvantage. The main advantage, you may mix different pull-up or pull-down types on the same port. A typical resistor value is 4700 Ohm.
- External pull-down – see notes above.
What should you select? It depends on your application and a used external sensor. For GPIO inputs, I prefer “pull-up.” For external sensors, you should look at the sensor’s data sheet for recommended schematics.
Note (CC2530, CC2531): The internal pull-up or pull-down option enabled for one pin automatically selects the same mode for all other pins on the same port P0x, P1x, or P2x. It is the main disadvantage because if you, for example, enable the internal resistor on P0.1, you enable it on P0.2 – P0.7. Therefore, it adds limits for mixing different sensors on the same port.
Note (CC2530, CC2531): P10 and P11 pins do not have internal pull-up resistors. Pull-up or pull-down mode does not affect it. I recommend using an external pull-up or external pull-down mode.
GPIO inputs
Inversed – By default, the firmware interprets the LOW state on the input pin as a button’s pressed state. If this option is enabled, the HIGH state means the pressed button. This option work in junction with the pull mode. For example, if you select the pull-down mode and set the “inversed” option, the logic is twice inverted, the firmware will interpret the LOW state on the input as a button’s pressed state.
Link – The input immediately controls the linked output state (e.g., Input 1 – Output 1). 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). The firmware also sends the release event when a button is unpressed.
Double – The firmware detects and reports a double click (max 500 ms between clicks).
Triple – The firmware detects and reports a triple-click (max 500 ms between clicks).
Switch – an input works as a switch. Only ON (pushed) / OFF (released) states. This option works if the input is linked to the corresponding output. When the switch changes a state, the firmware immediately reports a state of the output. The output can be virtual and assigned to any unused pin.
Switch is On & Link is Off – in this mode, the firmware reports click and release events for an input, also for fast clicks.
Toggle – this option appears for the switch input. The switch works like a toggle button. But because the ON/OFF state can be changed via external commands, a physical button position may differ from an output state.
Bind command – the device sends a click event as this Zigbee command to a bound device, if any. It does not change behavior of internal events and a linked output.
Note: Input 1, if defined as a click button, also acts as a system button and allows you to reset the device if you press and hold that button for 10 seconds. After resetting, the device starts a paring process.
Zigbee cluster: ZCL_CLUSTER_ID_GEN_MULTISTATE_INPUT_BASIC Zigbee attribute: ATTRID_IOV_BASIC_PRESENT_VALUE Data type: UINT8 (0 - button released, 1 - single click, 2 - double click, 3 - triple click, 4 - long press (more than 1500 ms))
External wake-up
This is the special GPIO input type. It does not send any button events to a coordinator, but it initiates an extra periodic report, when the device sends a state of all GPIO outputs and measured values from all sensors. Furthermore, if “External wake-up” is configured on Input #1, it works as a pairing button.
GPIO outputs
Inversed – By default, the firmware sets the output pin to HIGH when a logical state is ON. You may invert that logic using this option.
Remember state – The firmware saves the output state to NVRAM and restores it after power off/on. Furthermore, this option works for some sensors (counter, PWM)
Role – this options allows you to specify a role of the corresponding output. The configurator uses this option only when creates a custom converter for Z2M. As a result, the output may have a different icon and associated actions in a frontend or Home Assistant.
Zigbee cluster: ZCL_CLUSTER_ID_GEN_ON_OFF Zigbee attribute: ATTRID_ON_OFF
Virtual pins
The firmware adds a set of virtual pins:
- CC253x: from P30 to P37
- CC2652, CC1352: from P40 to P47
These pins do not exist in the chip, but you may use them in your configuration. For example, when you need to link an input and a virtual output, add a group switch or signal level control.
Zigbee2MQTT commands
on/off – sets the output to the HIGH or LOW state.
Topic: zigbee2mqtt/[friedly_name]/[channel]/set Channel: l1, l2, l3 … l16 Payload: ON or OFF
read – gets the current state of a GPIO output.
Topic: zigbee2mqtt/[friedly_name]/[channel]/get/state Channel: l1, l2, l3 ... l16 Returns the channel state: {"state_[channel]": "ON"}
trigger – sets the output to the HIGH state for N milliseconds, then resets to LOW. Please note, in the PSM mode the rigger may work unexpectedly with long intervals because the chip will go to the sleep mode and stop checking the timer. If you use the “Poll for queued commands” expert option, the trigger interval may be a multiple of this interval.
Topic: zigbee2mqtt/[friedly_name]/[channel]/set Channel: l1, l2, l3 … l16 Payload: {"trigger": 5000}
interval – sets the periodic reporting interval output to N seconds. This command can be sent to any configured channel, but it will change the interval for all channels at once. The value of 0 or 65535 disables periodic reports.
Topic: zigbee2mqtt/[friedly_name]/[channel]/set Channel: l1, l2, l3 … l16 Payload: {"interval": 50}
Gill
Thank you for this project.
Could you clarify the meaning of input and output channels?
Can 8 inputs and 8 outputs be used independently?
What is the exact benefit in linking input and output?
Could for example input 8 be used for ADC measurement and output 8 to turn something on/off?
Thanks.
Owner
Yes, you can have 8 independent inputs and outputs in the Premium version (16 channels). ADC input cannot control an output directly. The firmware will send an ADC value to your home automation system, and it can send a command back to change an output state. Internal linking allows you to on/off outputs without connection to a home automation system (offline mode).
Julian
Hi! Thank you for sharing this tool.
I have been trying for a long time to create a simple firmware configuration to turn on/off a led from Home Assistant using ZHA on a CC2530.
I am able to create the configuration, flash properly and add the device to Home Assistant. I am using configurator version 1.9.0.11 (from 2023-12-12).
I specified a status led in P00 and my output led in P02. The status led works fine, but the output led, nothing happens when I switch on/off from Home Assistant. In both cases I simply connected a red led with a small resistor to ground. If I measure voltage on P02 it’s always something like -1.37v and it doesn’t change in on or off position.
The config is super simple, besides the status led, I only have an output defined as GPIO with external pull down and generic role. I also tried external pull-up, no change.
I’m using the ZHA quirk generated by the configurator, which I confirm it’s successfully loaded.
NOTE: the generated quirk has a small bug, the model info says “ptvo.info ” (note the spaces). I had to remove the spaces to get the quirk to load.
Any ideas what I could be doing wrong? Why is it possible that the output in P02 never changes?
Thanks,
Julian
Owner
Please post your issue on GitHub, add your schematic and a screenshot of your configuration.
AP
Additional information. My inputs are configured as SWITCH same as in your example https://ptvo.info/zigbee-configurable-firmware-features/diy-examples/diy-zigbee-motion-detection-sensor-pir/ except they are not inversed and not binded to the output
Owner
You should invert the input and link it to a virtual output pin.
AP
It started to work after I configured outputs as shows on the example here
https://github.com/ptvoinfo/zigbee-configurable-firmware/issues/206
AP
Hello, thank you for your efforts! I have a question – how to configure digital input so system reports logic level of an input as follows: when input signal is low level, the logic input status is false, when input is high, the input status is true. No matter what I tried in PTVO configuration, the input logic gets changed on a transition of input from low to hi level, so when I set input to the high level, the input logic goes true momentarily, then goes to false regardless of input signal level
Jorn
Hi,
For my project, I’d like to report periodically all the states of various sensors with PSM mode. Most of it is already working perfectly, so thanks for this wonderful configurator.
However one of the sensors (“Battery is charging using solar”) is a boolean sensor, configured as GPIO switch linked to a virtual output. I want to report this output periodically only and not when the state is updated (to safe some battery). Is this possible with the software and could you help me how to configure this?
Thanks
Owner
The firmware always sends a state of all GPIO outputs (real and virtual) and all sensor values in periodic reports.
Jorn
Hi, I already get all periodic reports, that is working properly. I want to disable the immediate reports when a GPIO input changes, is this possible?
Owner
No, you cannot configure the firmware in that manner.
Martin
Hello
I tried to implement the example here https://ptvo.info/zigbee-configurable-firmware-features/diy-examples/diy-zigbee-motion-detection-sensor-pir/.
My configuration (CC2530, Firmware: 1.9.0.2) is:
Output 3:
P30, GPIO, Role: Generic
Input 3:
P00, GPIO, Pull-up, Link to out 3, Binding command: On/Off
However, when applying 3.3 V to pin 00, the virtual switch is not marked ON. Even if I use a “real” output (e.g. P01) there is no change of the switching state of P01.
What can be the reason for this?
Owner
If you use “Pull-up”, you should connect the pin to GND to get the ON state.
ov1d1u
I have a Non-Contact Liquid Level Sensor (XKC-Y25-V) which simply outputs a high level 3.3V-9V if it detects water or low level 0V if it doesn’t. How can I use this with your firmware? I tried with GPIO input but it looks to be designed to work with buttons, not sensors (it only updates action when state changes) and also as an ADC, but the voltage is being reported only once every X seconds (where X is the reporting interval).
Owner
Look at the example configuration for the PIR sensor.
https://ptvo.info/zigbee-configurable-firmware-features/diy-examples/diy-zigbee-motion-detection-sensor-pir/
Note: the CC2530 module can accept up to. 3.3V on an input. You need any kind of voltage limiter for your signal.
Flavien
If I configure a GPIO input like this:
– Link: off
– Switch: off
– Long: on
– Double/Tripple: on
Is there a delay before a single click event is reported, in order to detect double/tripple clicks?
Now if I turn off double/tripple (but leave long=on), will that remove the delay and send single clicks instantly?
Owner
The firmware generates a release event only for long clicks. A single click executes immediately, only if others click types are disabled.
Flavien
Thanks for the clarification. So can you confirm my understanding is correct:
1. I don’t need to set “switch=on” for a push-button like this that reports clicks but no state
2. With PSM and “switch=off”, an external pulldown resistor is not required
3. With “switch=off” and all click types disabled, the firmware reports when the button is first pressed down, but not when it is released
4. With “long=on”, it does not report when the button is first pressed down, instead it reports when the button is released
Is that correct?
Owner
1,2,3 – Yes, correct.
4 – The firmware reports a click after 300 ms and release when a button will be released.
saper_2
The mode Link allow for remote control output too?
I am looking for behavior: if input goes ON then out switch ON, if input goes OFF then output goes OFF. If input is ON (out ON too), sending remote command to switch output OFF, output is switched OFF. Now to turn it back ON using input I have to: toggle input OFF->ON. And when input is OFF (output OFF too), I send command to turn output ON, output switch ON; then to switch it OFF using input I have to toggle input ON, then OFF and output turn now OFF too.
Something like for output to “follow input state”.
Owner
You can try the “Switch mode” for the input.
Alex S.
Hi, for my battery powered device based on a CC2530 I need 8 inputs, PSM and an external wake-up. Unfortunately it seems not possible to have an external wake-up without sacrificing one input pin. Right?
Owner
Yes, correct. I think, you can easily split this device to two separate devices.
Owner
Hi Dimos,
Probably, you should configure a virtual output and link your input to it
https://ptvo.info/zigbee-configurable-firmware-features/diy-examples/diy-zigbee-motion-detection-sensor-pir/
Kamil
Do you have any working version of PWM with step motor? I need to create just 360* rotation with slow speed. I can’t find any working example
Owner
Hello. The firmware has PWM outputs with a low frequency where you can control a duty circle. But I didn’t test with with motors.
Shay
can a single input GPIO be used to control 2 outputs?
for example – use P00 as an inputs 1 and 2 then link output 1 as GPIO and link output 2 as PWM
Also, can you do a capacitive (touch) button?
Owner
No, you cannot link an input to two different outputs. But you can link to two GPIO outputs using the “Group switch” feature.
https://ptvo.info/zigbee-configurable-firmware-features/group-switch/
RaNo
This page says:
“read – sets the output to the HIGH or LOW state”
I guess this is wrong. Should say something about reading rather than setting. Please verify.
Owner
Yes, thank you! I’ve updated that paragraph.
Alex
There is anyway to change input/output name? I mean show MyCustomName instead L1 before to be paired.
Owner
No, you cannot change it because it is hard-coded in Z2M. You can create a custom converter and define a custom description by editing a converter JS file manually.
saeid
I think there is a small typo on the last line.
“…but it will change the interval for all changes at once. ” should probably be
” but it will change the interval for all channels at once. ”
changes->channels
Shonn
What is the difference of pull up or down in the OUTPUT mode?
Owner
It depends on your schematic. Usually, if the logical “ON” state sets the “HIGH” level on the output, you use “pull-up.”
Stefan
Hello,
I fail to report input status (with home assistant) , work only if it is linked to output (so twice input & output goes to on/off)
Is there something i mess ?
Best regards
Owner
Hello. Yes, you need to link an input to a virtual output (P3x) if you need periodic reports.
António
Hi, an output power state to On is possible?
Owner
Hi, Sorry, but I didn’t understand your question.
Alex
In the firmware configuration, I should select CC2530 under Board Type? As there is no CC2531 option.
This is a general question, is the Zigbee2MQTT journal the best way to receive the reports from the CC2531? I am very new to this.
Owner
Usually, it is “CC2530 without an external oscillator”. But it may depend on your board.
Alex
Hi! I have a few questions. Can I indeed use your configurable firmware to flash a hex file onto a CC2531?
Further, what is the easiest way to use your configurable software to make end devices which can be used to send wireless reports of voltage(s) on the 8 input pins? Perhaps using the reliable voltage source on the chip as a “reference voltage”?
Owner
Hi!
My firmware also supports CC2531. You should configure 8 input pins as ADC pins. That’s all.
Alex
Hi, what is the software configuration I should use to send the output of the voltage regulator on my CC2531 chip to one of the GPIO pins? I want to use a GPIO pin as a voltage source.
Owner
In general, it is a simple GPIO output. You can use pins P10 or P11 for powering your sensors (max 20 ma). But these pins are not available on the IO connector.
Marc
Hi
I have a device with 8 Inputs and 8 Outputs. I need the inputs and outputs being independent of each other. But would still want the input state shown as ON/OFF instead of getting the action (pressed/released). Can this be done?
Owner
Hi. It is not possible.