Author Topic: SwitchMotes won't sync [solved]  (Read 2242 times)

Banjo13

  • NewMember
  • *
  • Posts: 7
  • Country: us
SwitchMotes won't sync [solved]
« on: March 30, 2020, 08:49:02 PM »
  I've done an extensive search on the forum here and have been unable to find anyone else having a similar problem.

Here it is, I have 3 switch motes each with 3 buttons.  They have been installed and working for about 2 years now. By working, I mean they are all synced to one another.  A button push on any of the 3 buttons on any of the 3 switches will activate the corresponding button on the other two switches.  About 4 months ago, I noticed that one of the switchmotes (front door lights) would not activate the other 2 switchmotes.  The front door light switchmote would activate(turn on or off) when one of the other two switchmotes were activated.  Just a few days ago, I finally built my pi gateway and started using it to investigate what was going on with these switches.  All of the switchmotes had adequate signal(rssi) but the one by the front door and the one in the utility room were acting as if they had lost sync.  The one by the back door and the one in the utility room worked perfectly.  The pi gateway did not record any "ack" from the front door to the utility room and vice versa but did record "ack" from back door to utility room.

At this point I figured I would reload the switchmote sketch to the front door and check the EEPROM configuration data.  I thought this was a bit overkill but couldn't hurt.  After reloading the sketch, I used putty to check the EEPROM data and interestingly enough many of the sync data points were 0's with -1's at the end.  Other than that all the other data was good.

I then tried to sync the front door switchmote to the utility room switchmote and here is where it gets fun.....they both went into sync mode.  I started at the utility room, placed it into sync mode and immediately went to the front door and attempted to sync  but the front door switchmote went into sync mode.  I then went fully stupid and reloaded all the switchmotes with a fresh switchmote R2 sketch, checked all the EEPROM data and deleted all the sync data from the EEPROM from each switchmote. 

Now, none will sync.  Attempting to sync one to another just turns the sync on for both.  I've been searching the forum and trying to troubleshoot this problem for two days.  Fortunately the gateway is providing a graceful degradation at this time but I would like to sort this out.  Sorry for the long post but wanted to include as much data as possible.

thanks,

Josh

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: SwitchMotes won't sync
« Reply #1 on: March 31, 2020, 11:26:44 AM »
I doubt there's a problem with the EEPROM in those motes going haywire, or something being wrong with those atmegas. I have used SMs since inception and they still work flawlessly.

It sounds like a button is stuck or intermittent somewhere.
That causes the SM to sync and ultimately delete the sycn info. I have seen this when my kids played with my SM's and kept them pressed.
That could explain why you're seeing no data (empty?) EEPROM and them being out of sync.
That is controlled by this setting:

Code: [Select]
#define ERASE_HOLD       6000  //time required to hold a button before SYNC data is erased

I don't think the gateway itself will help a lot in debugging. SYNC'ing is completely independend and only requires the SM's themselves. When they SYNC they will only talk to each other, and then of course inform the gateway when they do turn ON/OFF after SYNC'ing. Otherwise the gateway will not "spy" on that activity or report anything other than direct messaging between itself and the SMs.

So not sure what to suggest but here's something:
Try to take the caps off those switchmotes. It's also possible the lasercut holes in the acrylic (+the wear of the buttons?) causing the buttons to become easily self-pressed. Just theory here but I thought I've also seen this happen a few times but could not repeat it unless I tried really hard (and my SM's are far older). So take the caps off and try to sync them again. Maybe first erase everything with the 6 second hold to start from scratch.

FWIW - I need to simplify how they sync and how the SYNC mode works, but just haven't gotten the time to do it. Namely I now feel the SYNC mode should by default fully sync (ON and OFF) two SM's with a long-press on each button. But this is kind of beside the point of this thread...

Banjo13

  • NewMember
  • *
  • Posts: 7
  • Country: us
Re: SwitchMotes won't sync
« Reply #2 on: March 31, 2020, 04:22:12 PM »
Felix,

Thank you for the response.  I think you are on to something with the switch hanging up.  After discussing with my wife about ever seeing the kids play with the switches (she said she has never witnessed them playing with the SM) she told me one of the buttons hung up once.  I've also noticed on occasion the buttons don't quite make the same sound as each other.  I will most definitely try your suggestions.  It'll be early next week before I am able to, but I will post what I find.  I do have a spare SM that I still need to assemble which might be helpful in the process...we shall see.

Mostly I was using the Gateway to look at RSSI just to make sure each SM was transmitting a strong enough signal.  I originally suspected that one of my switchmotes was having transmission issues.  My thinking was biased due to an outdoor temp sensor that failed because some of the solder connections corroded on the Moteino.  Moteino would quit working below approximately 40 degrees F.  Tested the temps sensor (SHT-31) and the moteino and the moteino was having issues.  I have since potted my outside moteinos to protect them against this type of corrosion in the future.

Thanks again.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: SwitchMotes won't sync
« Reply #3 on: March 31, 2020, 04:50:10 PM »
No problem,
One thing to add, the buttons themselves are OEM from OMRON, not aftermarket, rejects from aliexpress/chinese fakes.
So ...... I don't think they should fail under normal circumstances.
Even my "hyper sledgehammer kids" did not manage to destroy them SMs  ;D
If you determine the rectangular cutouts ate too "tight" then maybe that's the problem. File the openings a bit more or use a blade to shave off a few thou on each side equally.
Let me know your findings...

Banjo13

  • NewMember
  • *
  • Posts: 7
  • Country: us
Re: SwitchMotes won't sync
« Reply #4 on: April 22, 2020, 12:10:38 PM »
I was finally able to squeeze in some time to troubleshoot.  Instead of pulling the faceplates on all three SM's, I cut the breaker on two of the SM's only leaving one up and running.  I recently built a SM that was purchased at the same time as the other three.  I built this SM for sole purpose of troubleshooting each of the other three switches.  I did not install the faceplate on the newly built SM.  None of the three existing SM would sync.  Just to be clear, I tried each existing SM with the other two completely off(circuit breaker in the off position) and tested them individually against the new SM, each time with only one installed SM with power applied.  None of them would sync against the newly built switch with no faceplate.

This isn't a big problem since I now have my gateway operational to control these lights at sunrise/sunset.  Mostly a challenge to figure out why something that was previously working perfectly is no longer functioning correctly.  Either way, I will continue to troubleshoot until I figure it out

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: SwitchMotes won't sync
« Reply #5 on: April 24, 2020, 09:32:07 AM »
If this was working, and no longer working, I would safely eliminate the hardware. Unless physical damage has happened, or RF interference but in that case nothing would work at all.
Take an SM and troubleshoot in the IDE/serial monitor. If the button presses work, and the packets go through, then there is no reason why a SYNC would not work.
Ensure they all run on the same version of the library, or the latest.

Banjo13

  • NewMember
  • *
  • Posts: 7
  • Country: us
Re: SwitchMotes won't sync
« Reply #6 on: April 27, 2020, 09:19:04 PM »
Felix,

I reloaded all three with a fresh install of the SM sketch and it appears the hardware is working.  I used the SM I recently built and ran it through putty to watch all the outputs while trying to sync to different switches.  I have attached the output screen for 2 of those attempts....they all look the same.  I put one SM into sync mode, walk to the other SM and press and hold.  Instead of sync'ing, it goes into sync mode.  From the putty screen, it shows a sync ack mismatch then into sync mode.   

I have no clue, all the SMs are controllable by the gateway, I can see the data each button press sends to the gateway.  The SM connected to my laptop "see's" the data coming off the other SMs.  I've popped the faceplates on two of the SMs with no effect.  I completely deleted all arduino files off of my wife's laptop and started with a fresh arduino software reload.  All fresh updates for the moteino's and all associated libraries needed for the SMs.  I used my wifes's laptop to then refresh the software via OTA.  I typically beat my skull against the wall until it forces the knowledge via high pressure reverse osmosis but this problem has me bleeding profusely feeling like I've lost some crucial childhood memories but I can't seem to remember which ones  :D.

That being said, thank you for the insight and help so far.  I'm just hoping we might be able to sort this out. 

thanks again,

Josh

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: SwitchMotes won't sync
« Reply #7 on: April 28, 2020, 12:28:59 PM »
Thanks for the follow up. Sorry for all the trouble you're having but I am sure its something simple.
I will have to look further into this.

As I do that I will likely plan to update the whole SYNC feature to require a single SYNC for a button instead of 4, defaulting to ON-ON and OFF-OFF, both ways. The original functionality allows SYNC-ing ON-OFF and one way only, so a lot more granular but I personally haven't had a need to do that (ie switch a SM ON when another is turned OFF) and it probably makes no sense in most normal situations.

Unfortunately i don't have an ETA for all this.
« Last Edit: April 28, 2020, 12:30:54 PM by Felix »

Banjo13

  • NewMember
  • *
  • Posts: 7
  • Country: us
Re: SwitchMotes won't sync
« Reply #8 on: April 28, 2020, 01:41:15 PM »
No need for apologies as this is most likely something I’m doing wrong.  I’ll keep experimenting until I figure it out.  I think it will be something simple as well.  As soon as I know I’ll post the fix. 

Thanks again


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: SwitchMotes won't sync
« Reply #9 on: April 30, 2020, 04:03:11 PM »
I didn't spend the time to track this down to exactly the cause, I know this worked because all my SMs still work with the old code, and now a pair of SMs no longer SYNC.
My observation is that strlen or sprintf changed behavior and caused the SYNC messages to not include the expected null terminations.
Sosprintf(buff,"SYNC%d:%d", btnIndex, mode[btnIndex]) would cause the string to be SYNC90:1ptyString. The underlined is the excess in the buffer declaration:
char * buff="justAnEmptyString";
And strlen would return 17 (the original declaration length) instead of 8 (after sprintf'ing a shorter string to it). ???

Anyway I submitted a fix so please try the updated sketch.
This sketch also includes simplified SYNCing, which now requires only 2 button presses - 1 on each side, and it will SYNC those 2 buttons both ways (ON:ON, OFF:OFF).
« Last Edit: May 01, 2020, 02:20:31 PM by Felix »

Banjo13

  • NewMember
  • *
  • Posts: 7
  • Country: us
Re: SwitchMotes won't sync
« Reply #10 on: May 01, 2020, 09:31:06 PM »
Brother you nailed it.   I just finished testing it out and it works fantastically.  I can’t thank you enough for tracking this down.   The simplified sync mode is awesome.

Thank you

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: SwitchMotes won't sync [solved]
« Reply #11 on: May 03, 2020, 08:43:45 PM »
Thanks for the follow up, good to know everything is in order, I have to update all my SM's too. Thanks to OTA/wireless programming that is very easy.

gigawatts

  • NewMember
  • *
  • Posts: 23
Re: SwitchMotes won't sync [solved]
« Reply #12 on: November 23, 2020, 09:29:55 PM »
Thank you very much, I was just experiencing the exact same issues, not being able to sync anymore. I just updated to the latest SwitchMoteR2 on all my nodes and sync is working great now!