Particle Stepper Motor - software question

Hey all,

I’ve recently installed an awesome Automated Blinds for my office window using a Photon and a stepper motor (see code below). However, I’ve noticed that after I trigger the “Open” or “Close” buttons from my webpage, the motor continues a loud annoying buzz even after the motor stops moving. Before clicking either button, the motor is nice and quiet. And when I re-flash the Photon and it’s sitting waiting to be used, the motor is also quiet. The buzz just kicks in after I’ve used the motor.

Does anyone have an idea for how to reset the motor to that initial “sleeping” mode after use so I don’t have this loud buzz all day??

#include "PhoBot/PhoBot.h"

PhoBot p = PhoBot(12.0, 12.0);
int numSteps = 2080; // figure out how many steps you need to open the curtains, and change this number to that
int period = 3;
bool curtainsAreOpen;

void setup() {
    Particle.function("motor", motorSwitcher);
    curtainsAreOpen = true;
}

void loop() {
}


int motorSwitcher(String command) {
    if(command.equalsIgnoreCase("on") && curtainsAreOpen){ // I'm assuming that the "on" direction closes the curtains.
        for (int i = 0; i < numSteps; i++) {
            p.setMotors("M3-F-100");
            p.setMotors("M4-B-100");
            delay(period);
            p.setMotors("M3-F-100");
            p.setMotors("M4-F-100");
            delay(period);
            p.setMotors("M3-B-50");
            p.setMotors("M4-F-50");
            delay(period);
            p.setMotors("M3-B-50");
            p.setMotors("M4-B-50");
            delay(period);
        }
    curtainsAreOpen = false;
    
    
    }else if (!curtainsAreOpen){
        for (int i = 0; i < numSteps; i++) {
            p.setMotors("M3-B-100");
            p.setMotors("M4-B-100");
            delay(period);
            p.setMotors("M3-B-100");
            p.setMotors("M4-F-100");
            delay(period);
            p.setMotors("M3-F-50");
            p.setMotors("M4-F-50");
            delay(period);
            p.setMotors("M3-F-50");
            p.setMotors("M4-B-50");
            delay(period);
        }
    curtainsAreOpen = true;
    }
}

Could you try putting this in? Place it after the last movement command.

p.setMotors("M3-S");
p.setMotors("M4-S");

Hey Moors7,

Sorry for the late reply, things got super busy at work. I went to try editing my code per your suggestion, but now I can’t connect to my device.

Every time I tried to Setup back to Listening Mode and go through the steps to re-connect to wifi, the App says “Device Ownership Failed.” I tested the wifi on my laptop and phone, and it seems to be a strong signal, so I’m not sure what’s happening.

Right now it’s rapidly blinking cyan, and I can’t figure out what that means either.

Rapid cyan happens during cloud handshake.
Do you see short orange bursts?

Hey ScruffR, I wasn’t seeing any short orange bursts.

I just tried pairing again using the App, and it gave me the same “Setup Failed” message during “Verify Device Ownership.”

I see it says: “if your Particle device is blinking blue or green, this means you provided the wrong WiFi credentials” which is not possible. I’ve tried this several times, I’ve connected several other devices using these credentials. Something isn’t right.

If your device is showing cyan it has already connected to the WiFI network.
But if it can’t get beyond rapid cyan (without orange/red burst, which would indicate another issue) into breathing cyan it’s most likely that your network prevents the connection to the cloud.

Do you happen to be behind a captive portal or have a firewall/ISP blocking CoAP UDP port 5683?

Can you get your device connected to the cloud via your mobile phone AP?
This way you could at least get the ownership confirmed and won’t need to care about this anymore.

Definitely no captive portal, and I’ve used this same network successfully for several months. Though admittedly, it’s possible that our IT team made some configurations that I’m unaware of that is now preventing connection to the cloud.

Do you think that’s possible? If so, I could also try connecting to a Verizon Mifi or something like that.

1 Like

This would definetly be worth a try.

1 Like