Git Product home page Git Product logo

pxbee-trigger's Introduction

pxbee-trigger

Programmable XBee Trigger that is ZigBee Home Automation profile compliant. Possible to integrate with SmartThings Hub v3 or a separate ZigBee / XBee network. Includes a reference hardware design up to 4 channels with a full BOM, perfect for DIYselfers out there.

Used in real life to automate garage / gate automatons.

Hardware example

Picture

An assembled board without a mounted XBee radio. Metric scale for reference (cm.). Board dimension - 51 x 57 mm.

Bill of Materials (BOM)

Designator Component Manufacturer Quantity SKU / Part nr. Spec Option
XB1 Programmable XBee (with RPSMA) Digi 1 XBP24CZ7SITB003 PDF
BR1 Bridge Rectifier DF01M ON Semiconductor 1 Mouser No: 512-DF01M PDF
C1 (C2) Electrolytic Capacitor - Radial 220uF 50V Panasonic. 1-2 Mouser No: 667-EEU-FM1H221. PDF.
PS1 DC/DC Isolated Converter Cosel MGFS1R5243R3 Cosel 1 Mouser No: 436-MGFS1R5243R3 PDF
Q1,Q2,Q3,Q4 Bipolar Transistor BC548BTA ON Semiconductor 4 Mouser No: 512-BC548BTA PDF
D1,D2,D3,D4 Diode 1N4004 ON Semiconductor 4 Mouser No: 863-1N4004RLG PDF
K1,K2,K3,K4 General Purpose Relay (APAN3103) Panasonic 4 Mouser No: 769-APAN3103 PDF
R1,R2,R3,R4 Resistor RN55D1801FB14 Vishay 4 Mouser No: 71-RN55D1801FB14 PDF
XB1 10 pin header for XBee Harwin 2 Mouser No: 855-M22-7131042 PDF
J1 2 pin Terminal Block (PCB) Molex 1 Mouser No: 538-39501-1002 PDF A
2 pin Terminal Plug Molex 1 Mouser No: 538-39500-0002 PDF A
J2 9 pin Terminal Block (PCB) Molex 1 Mouser No: 538-39501-1009 PDF A
9 pin Terminal Plug Molex 1 Mouser No: 651-1908101 PDF A
J1 2 pin Fixed Terminal Block (PCB) Molex 1 Mouser No: 538-39357-0002 PDF B
J2 9 pin Fixed Terminal Block (PCB) Molex 1 Mouser No: 538-39357-0009 PDF B
Antenna with RP-SMA Connector Linx Technologies 1 Mouser No: 712-ANT-2.4-CW-RAH PDF
JP1 6 pin Debug Header Molex 1 Mouser No: 538-22-28-8065 PDF O
J3 2 pin Reset Header Molex 1 Mouser No: 538-22-28-5027 PDF O

Standard 3.5 width headers are used. Option A) uses pluggable termination; B) Fixed screw termination; O) Parts are optional and meant for development; Components can easily be switched with other termination blocks or use direct wire soldering.

Compiling

  • On 32bit Linux target, simply: make
  • On 64bit Linux target:
    • Intall 32bit compatible libraries: sudo apt-get install lib32stdc++6
    • make
  • On MacOS:
    • Install Docker
    • make builddocker
    • make dall

Firmware

Trigger

Send a Unicast ZCL "On" command to trigger the connected relay for 125ms (Relay 1). The state of the switch remains in "Off" state. Broadcast command is ignored by default.

Endpoint: 0xEA,
clusterId: 0x0006,
profileId: 0x0104,
command: 0x01

Settings

The following defines can be altered in custom.h prior to compilation to change the behavior how the Trigger works:

Name Description Default
PXBEE_TRIGGER_IGNORE_BROADCAST When enabled, ignores broadcast commands and reacts only when unicast messages are sent to the specific address (ignores All On/All Off commands). Enabled
ZCL_MANUFACTURER The reported manufacturer string. For SmartThings local execution support without custom device handler, set this to "Leviton". "PXBee"
ZCL_MODEL The reported model string. For SmartThings local execution support without custom device handler, set this to "ZSS-10". "Trigger"

Endpoints

Endpoint Description
0xEA Relay 1
0xEB Relay 2
0xEC Relay 3
0xED Relay 4
0xEE Auxiliary binary input endpoint

License

This project is based on exsilium/pxbee-blink-led boilerplate and includes the full Digi XBee SDK version 1.6.0 sources.

Includes the necessary build binaries:

HI-CROSS+ ANSI-C Compiler for HC08 V-5.0.39, Dec 13 2011
HI-CROSS+ SmartLinker V-5.0.48, Dec 13 2011
HI-CROSS+ Burner V-5.0.16, Dec 13 2011
(c) Copyright Freescale 1987-2010

If not otherwise noted, the added code is BSD licensed.

pxbee-trigger's People

Contributors

cybexer-vlm avatar exsilium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pxbee-trigger's Issues

Trigger works when ZigBee All On is sent

When testing OSRAM Lightify ZigBee 4-button switch, which by default has a function to send out "All On" / "All Off" command it was seen that the Trigger also reacted to the On command. As the aim of the trigger is to control gates etc. This should not happen. Ignore broadcast commands and only Trigger when signal is explicitly sent to the device.

trigger();

Post remarks to PCB fabrication (v0.1.1-pcbfab.1)

Dump the Phoenix connectors, 5.08mm is too big, and 2.54mm is too small (no normal screw based termination solutions seem available atm. One option would be to replace the connectors with 3.5mm Molex Eurotype plug which would allow either one-piece or header+plug type of termination. Either way, the connectors seem to be more reasonably priced with stock available.

Proposed to change the following:

  • Phoenix Contact - 2 pin Terminal Block (PCB) (5452153) -> Molex 39501-1002 (Alternative one-piece: Molex 39357-0002)
  • Phoenix Contact - 8 pin Terminal Block (PCB) (1963599) -> Molex 39501-1008 (Alternative one-piece: Molex 39357-0008)
  • Dimension the board 75x75mm, so that it can fit to a small size plastic junction box
  • Use 9 pin terminal block and add additional connection for another status/button pin (Molex 39501-1009)

Get a quote for minimal PCBA service from PCBWay

Idea is to request a full PCBA service from PCBWay for the minimal prototype run (5 pcs.). Sourcing components from Mouser.

  1. Lead time - slack
  2. Parts source - Turn-key
  3. Assembly options - TH one-sided
  4. Types of solder - Lead-free
  5. Stencils - N/A
  6. Minimum order - 5
  7. Component size - Large
  8. Component package - Loose
  9. Board dimension - 51 x 57 mm
  10. Board shape - Rectangular
  11. Board type - Rigid
  12. Repair & Rework - N/A

Trouble connecting to SmartThings

I'm trying to reproduce your results with my SmartThings hub but I'm completely new to both smartthings handlers and zigbee. I followed your instructions to set

#define ZCL_MANUFACTURER "Leviton"
#define ZCL_MODEL "ZSS-10"

in custom.h in order to try to avoid having to write a custom handler. I have built and uploaded the new firmware and I am greeted with the devices interactive prompt if I open a serial terminal to it. Is there anything else I need to do to add the device from within my smartthings app? Do I need to initiate pairing or something?

Can you recommend any useful way of debugging zigbee / smartthings?

Thanks again for your help!

Post remarks to PCB fabrication (v0.1.3-pcbfab.1)

Prototype run of 5 boards was ordered from PCBWay on 28th of March 2020 with the following parameters. (Gerber project files available and tagged as v0.1.3-pcbfab.1

Board type Single pieces Panel Way  
Different Designin Panel 1 X-out Allowance in Panel  
Size 51 x 57 mm Quantity 5
Layer 2 Layers Material FR-4: TG130
Thickness 1.6 mm Min Track/Spacing 6/6mil
Min Hole Size 0.3mm ↑ Solder Mask Black
Silkscreen White Gold fingers No
Surface Finish HASL with lead "HASL" to "ENIG" Yes
Via Process Tenting vias Finished Copper 1 oz Cu
Extra pcb product number   Additional Options UL Marking:None

Implement support for GPIO_IRQ_EDGE_BOTH type of ISR

Programmable XBee SDK v1.6.0 does not have built in support for detecting and running ISR on both edge slopes.

To be able to address issues in #14 and to be able to make the implementation coded much cleaner, add support for GPIO_IRQ_EDGE_BOTH interrupt type.

The implication is that this change will be made in the SDK. Altough this is an unofficial addition - it can be reused in other projects when required.

PCB design does not work with 24VAC input

One of the goals of the project is to be able to interface the PCB with BFT gate drivers which uses 24VAC for auxiliary devices. The v0.1.3 PCB design does not work with VAC input due to a missing smoothing capacitor.

The following needs to be fixed:

  1. Add a missing smoothing capacitor after the bridge rectifier (needs to be dimensioned)
  2. re-check the bridge rectifier for 24VAC as the current DF005M doesn't seem to carry sufficient reverse voltage rating
  3. Update the pcb design to v0.3.0 to reflect the next full release

Logic error in status pin Interrupt service routines

The current logic is faulty, does not operate correctly and can cause the XBee module to become unresponsive to external Zigbee communications losing ability to control the automaton connected to the module.

The initial thinking was:

  • Have a global variable to keep state of GPIO IRQ ISR (status_1_InterruptFree)
  • Check if TPM timer has been started (status_1_TimerSet)
  • Record the present negated value of the GPIO in the Zigbee data structure
  • Start a PERIODIC timer and set the global that the Timer is set

pxbee-trigger/src/main.c

Lines 591 to 603 in aab446b

void status_1_irq(void)
{
if(status_1_InterruptFree) {
status_1_InterruptFree = FALSE;
if(!status_1_TimerSet) {
binaryInput.present_value = !gpio_get(STATUS_1);
if(timer_config(status_1_CheckTimer, TRUE, PERIODIC, DEBOUNCE_TIMER) == 0) {
status_1_TimerSet = TRUE;
}
}
status_1_InterruptFree = TRUE;
}
}

  • The timer ISR would send the state update message and keep the state (status_1_SendStatus)
  • The timer would keep running until a contact open state would be reached, in which case another update message would be sent out and the time associated with origan interrupt be terminated

pxbee-trigger/src/main.c

Lines 555 to 569 in aab446b

void status_1_CheckTimer_irq(void) {
if (!((!gpio_get(STATUS_1)) ^ binaryInput.present_value) && status_1_SendStatus) {
puts("EVENT TRIGGERED: status_1_irq (CONTACT CLOSED)");
send_status(&zcl_binin_attributes, wpan_endpoint_match(&xdev.wpan_dev, CUSTOM_ENDPOINT, CUSTOM_EP_PROFILE));
status_1_SendStatus = FALSE;
}
else if(gpio_get(STATUS_1) && !status_1_SendStatus) {
puts("EVENT TRIGGERED: status_1_irq (CONTACT OPEN)");
binaryInput.present_value = ZCL_BOOL_FALSE;
send_status(&zcl_binin_attributes, wpan_endpoint_match(&xdev.wpan_dev, CUSTOM_ENDPOINT, CUSTOM_EP_PROFILE));
status_1_SendStatus = TRUE;
status_1_TimerSet = FALSE;
timer_enable(status_1_CheckTimer, FALSE);
}
}

In reality the flow does not work as expected for multiple reasons:

  • The default state of the gate automaton is actually contact closed, because the gate remains closed majority of the time
  • The timer will remain triggering ISR (status_1_CheckTimer_irq)
  • On edge cases (due to debounce), an incorrect value may be set to binaryInput.present_value which would further break down the logic by sending an incorrect status notification
  • It was noted that under real life conditions the module became unresponsive to external ZigBee messaging after certain time had passed. This is possibly due to the excessive processing caused by the ISRs in the MCU

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.