dzungpv / dnckatsw00x

Zigbee light switch with dim support base on chip cc2530
GNU General Public License v3.0
90 stars 19 forks source link

Great Project #9

Closed VertorixAU closed 5 years ago

VertorixAU commented 5 years ago

I can confirm the single relay .hex works with zigbee2MQTT.

It only joins on channel 15 (2425mHz) not the default channel 11 (2405mHz) of Zigbee2MQTT ZAP. So you will have to change the default channel to 15, but be aware that will require rejoining all zigbee devices to network!

I had no issues with re-join after reset which was noted on earlier posts.

I have been trying for far too long to build it from scratch and add more relays and I'm going to have to call it quits. My background isn't programming so its too much to learn Z-stack. I just couldn't get it to compile correctly.
EDIT: I just noticed you need a certain version of AIR to compile this, that's why I was having so many issues. Dzungpv can you please supply the .hex for the 4 channel or preferably 8ch relay/switch? It would also be beneficial to allow joining of all channels, not just channel 15.

You can send .hex to julius.sax546@gmail.com.

Thank you!

dzungpv commented 5 years ago

You can build yourself and follow my guide here: https://github.com/dzungpv/dnckatsw00x/blob/master/README.md Use IAR Embedded Workbench for 8051, V8.30.3 trial version, download here: https://www.iar.com/iar-embedded-workbench/partners/texas-instruments/ti-wireless/ To change the channel to all edit file: C:\Texas Instruments\Z-Stack Home 1.2.2a.44539\Projects\zstack\Tools\CC2530DB\f8wConfig.cfg

-DDEFAULT_CHANLIST=DMAX_CHANNELS_24GHZ
VertorixAU commented 5 years ago

Hi dzungpv please contact me on email above or other e-mail I sent you. I'm willing to pay for help on this project building 4 and 8 gang relay.

Regards

VertorixAU commented 5 years ago

Hi Viet Dzung

I have got the 2 relay switch working, I can now easily add more buttons/relays (I will make 4 relay version next). It is working perfectly with your configuration on zigbee2mqtt, and reports accurately for both relays.

Thanks for your tutorial otherwise I wouldn't have figured it out.

The only thing I'm confused about is the variable "zclSampleLight_OnOff":
"zclSampleLight_OnOff" I didn't have to use I/O pin P1_0 in commands but; "zclSampleLight_OnOff1" I had to use P1_1 = LIGHT_OFF or LIGHT_ON to make it work?

Is "zclSampleLight_OnOff" = P1_0 defined somewhere?

This is the code I ended up using:

/*****

static void zclSampleLight_HandleKeys( byte shift, byte keys ) { P1SEL |= 0x00; P1DIR = 0xFF; // set all as outputs

if ( keys & HAL_KEY_SW_1 ) { giLightScreenMode = LIGHT_MAINMODE;

// toggle local light immediately
zclSampleLight_OnOff = zclSampleLight_OnOff ? LIGHT_OFF : LIGHT_ON;

ifdef ZCL_LEVEL_CTRL

zclSampleLight_LevelCurrentLevel = zclSampleLight_OnOff ? zclSampleLight_LevelOnLevel : ATTR_LEVEL_MIN_LEVEL;

endif

}

if ( keys & HAL_KEY_SW_2 ) { giLightScreenMode = LIGHT_MAINMODE;

// toggle local light immediately  

zclSampleLight_OnOff1 = zclSampleLight_OnOff1 ? LIGHT_OFF : LIGHT_ON; P1_1 = P1_1 ? LIGHT_OFF : LIGHT_ON; // toggle P1_1 on and off }

/*****

static void zclSampleLight_OnOffCB( uint8 cmd ) { P1SEL |= 0x00; P1DIR = 0xFF; // set all as outputs

afIncomingMSGPacket_t *pPtr = zcl_getRawAFMsg();

zclSampleLight_DstAddr.addr.shortAddr = pPtr->srcAddr.addr.shortAddr;

zclSampleLightSeqNumState = pPtr->nwkSeqNum;

if (pPtr->endPoint == SAMPLELIGHT_ENDPOINT) //button 1 { // Turn on the light if ( cmd == COMMAND_ON ) { zclSampleLight_OnOff = LIGHT_ON; } // Turn off the light else if ( cmd == COMMAND_OFF ) { zclSampleLight_OnOff = LIGHT_OFF; } // Toggle the light else if ( cmd == COMMAND_TOGGLE ) { if ( zclSampleLight_OnOff == LIGHT_OFF ) { zclSampleLight_OnOff = LIGHT_ON; } else { zclSampleLight_OnOff = LIGHT_OFF; } } } else if (pPtr->endPoint == SAMPLELIGHT_ENDPOINT+1) //button 2 { // Turn on the light if ( cmd == COMMAND_ON ) { zclSampleLight_OnOff1 = LIGHT_ON; P1_1 = LIGHT_ON; } // Turn off the light else if ( cmd == COMMAND_OFF ) { zclSampleLight_OnOff1 = LIGHT_OFF; P1_1 = LIGHT_OFF; } // Toggle the light else if ( cmd == COMMAND_TOGGLE ) { if ( zclSampleLight_OnOff1 == LIGHT_OFF ) { zclSampleLight_OnOff1 = LIGHT_ON; P1_1 = LIGHT_ON; } else { zclSampleLight_OnOff1 = LIGHT_OFF; P1_1 = LIGHT_OFF; } } }

Thanks again for all your help.

Regards

MrAlester commented 5 years ago

@mquinn123 thanks for commenting on this great project. Could not figure out why it did not pair with zigbee2mqtt, I just changed the channel to 15 and worked perfectly.

@dzungpv is there a way to change the button behavior?? I'm looking forward to make it work with the good ol' wall switches, if the switch is on then the relay is on, if it's off, then the relay is off.

Thanks a lot to both of you guys.

MrAlester commented 5 years ago

Could you please share a pre-compiled hex file for a 3 switch board please? I'm not quite sure that my skills are enough to build it from scratch, even following your guide.

Thanks!