Boron Function not showing up in cloud

boron function not working
Please help. I have read all of the documentation on the device OS API on function and flashed firmware 1.4.4 to the device. I can ping it and flash fine, but the function here never publishes to the Particle cloud so I have 0 functionality with the device currently. It will flip a switch when told to from the particle cloud when finished correctly.

Can you make sure that your code actually stuck?

A simple way to do that is to add some D7 LED blink code into loop() and check if the expected blinking actually occures.

Thank you for your reply! I will do that right now and get back to you.

I was able to upload the blink LED program and get it to work. Then I added a servo object and servo.write(100) into the loop and the LEDs still blink, but servo does nothing. I have servo on external 5V PSU that I tested with multimeter. Everything grounded to the same bus and control pin attached to D0 on boron board. I am starting to go crazy

That is a different issue and has nothing to do with the function not being registered but D0 not being a pin that can be used with Servo

https://docs.particle.io/reference/device-os/firmware/boron/#attach-

1 Like

Using D2 allowed me to get the servo to work with the blink LED program, but the original program with the function still doesn’t show up in the cloud when using the correct pin for servo.

I just tried this with my Boron 3G on 1.5.0 and it worked as expected

void setup() {
  pinMode(D7, OUTPUT);
  Particle.function("toggle", toggleLED);
}

void loop() {

}

int toggleLED(String arg) {
  digitalWrite(D7, !digitalRead(D7));
  return digitalRead(D7);
}

Thank you for your help. I was able to get it to work after going home frustrated and coming back this morning. I think it has something to do with the poor connection at 35%. The device goes up and down, however, when I can ping it and it is online the function publishes and works! I also learned that the ground on the board must be jumped to the ground on the servo when you are using an external power source for the servo… that is kind of tricky if you are new to this.

That is true and perfectly reasonable.
When you measure anything (including voltages) you need a common reference.

Imagine you have a chair with a seating hight of 42cm and a table with 75cm but both are not on the same floor in a multi-storey building you’d have a hard time eating from the table while sat on the chair despite their individual heights being perfectly standard :wink:

That makes sense. Do you know how to improve signal strength? I have 4 bars 4G LTE on Verizon on my phone, but at the same location I get 21% 3G on TMobile on the Boron?

Verizon and TMobile are typically not sharing the same cell transmitters, so it’s not surprising that you see different singal strengths - especially when also comparing different technologies.

To improve signal strength you need to either change location and/or us a different antenna.
However, when going for a different antenna you need to consider that the certification of the Boron requires an antenna with same or less gain as the original.

Are you able to recommend any antenna’s in particular? I apologize for all of the questions, but there just isn’t as much info on the web compared to arduino (only other “maker” device I’ve used before).

For personal use, you can use a variety of cellular antennas. (If you are manufacturing a product, there are certification issues that can occur with other antennas.)

The Boron comes with a u.FL connector. Most GSM antennas require an SMA connector. A small adapter can be purchased:

At Adafruit, you can get this adapter. At SparkFun this adapter. At Amazon this adapter.

Once you have an SMA connector, you can most cellular phone antennas. For example, I use this antenna from Amazon which is about 4" long and has a magnetic mount to improve reception in fringe areas.

2 Likes

Thank you so much! This is a small business (I work here) so no problems with certifications.

This is my entire program. Even when it has 25% signal and I can ping it, the functions do not show up on the particle cloud or in the iphone app. The firmware is 1.5.0. Do you see anything wrong?


#include "Particle.h"

Servo myservo; //unlike arduino, servo is in Particle.h so no need for #include <Servo.h>

int pos = 0;
int led1 = A5; //pin headers are treates as ints - this is why you have to read the OS API documentation! 

int cycleP(String command);
int testFunction(String arg);

unsigned long old_time = 0;
unsigned long old_time2 = 0; //we need this in order to implement "soft delay" with millis() rather than "hard" delay()

//functions in setup are only run once - via OS API it is recommended to declare "cloud functions" as soon as possible 
//setup is also where you want to declare hardware "attaches" such assigning pins to LEDs, pumps, switches, relays, etc.
void setup() {
Particle.function("onOff", cycleP);
Particle.function("inputTest", testFunction);

myservo.attach(D2);
myservo.write(0);

pinMode(led1, OUTPUT);
}

void loop() {
    //following 2 if statements make the LED turn on for 1 sec then off for 5 - this allows me to know when updated firmware has flashed and device is online
    if(millis()-old_time>=1000){
        digitalWrite(led1, LOW);
        old_time = millis();
    } 
    if(millis()-old_time2>=5000){
        digitalWrite(led1, HIGH);
        old_time2 = millis();
    }
}

int testFunction(String arg){
    if(arg=="test"){
    return 1;
    }
    else return -1;
}

int cycleP(String command){
    if(command=="Y"||command=="y"){
        unsigned long hammerTime = millis();
        //myservo.attach(D2);
        myservo.write(0);
        if(hammerTime>=5000){
        myservo.write(130);
        }
        if(hammerTime>=30000){
        myservo.write(0);
        }
        //myservo.detach();
        //delay(600000); giving error - fixed by implementing millis() logic
        return 1;    
    }
    else return -1;
}

I have modified the firmware slightly, but nothing to the function signatures. I have installed a higher gain third party SMA antenna with the converter cable. I can ping the device, but my cloud functions STILL don’t show up consistently. If I leave the device on over night they will usually show up the next day, but I need the functions to show up as soon as a signal is established. Also it doesn’t make any sense to me why Particle would store cloud function in the firmware of an individual device. They should be stored in… the cloud. That way if I want to implement one I just point it at a device rather than having to re flash every device that I want to be able to run that code. Also if the device was down I would get that error rather then now where I don’t see any functions at all. The development time for this simple project is getting ridiculous because I have wait hours before I can even test a change made to the firmware. I do not live in the middle of nowhere either. I live 10 minutes from a city with population 250,000. I cannot even connect the IFTT application because it doesn’t see the cloud functions… starting to look for a new platform at this point.

For reference, this is my entire program running on firmware 1.5.0

#include "Particle.h"

Servo myservo; //unlike arduino, servo is in Particle.h so no need for #include <Servo.h>

int pos = 0;
int led1 = A5; //pin headers are treates as ints - this is why you have to read the OS API documentation! 

int cycleP(String command);
int testFunction(String arg);

unsigned long old_time = 0;
unsigned long old_time2 = 0;
unsigned long old_time3 = 0;
unsigned long old_time4 = 0;
//we need this in order to implement "soft delay" with millis() rather than "hard" delay()

//functions in setup are only run once - via OS API it is recommended to declare "cloud functions" as soon as possible 
//setup is also where you want to declare hardware "attaches" such assigning pins to LEDs, pumps, switches, relays, etc.
void setup() {
Particle.function("onOff", cycleP);
Particle.function("inputTest", testFunction);

myservo.attach(D2);
myservo.write(0);

pinMode(led1, OUTPUT);
}

void loop() {
    //following 2 if statements make the LED turn on for 1 sec then off for 5 - this allows me to know when updated firmware has flashed and device is online
    if(millis()-old_time>=1000){
        digitalWrite(led1, LOW);
        old_time = millis();
    } 
    if(millis()-old_time2>=5000){
        digitalWrite(led1, HIGH);
        old_time2 = millis();
    }
}

int testFunction(String arg){
    if(arg=="test"){
    return 1;
    }
    else return -1;
}

int cycleP(String command){
    if(command=="Y"||command=="y"){
        unsigned long hammerTime = millis();
        unsigned long hammerTime2 = millis();
      
        myservo.write(0);
        
        if(hammerTime - old_time3>=5000){
        myservo.write(130);
        old_time3 = hammerTime;
        }
        if(hammerTime - old_time4>=30000){
        myservo.write(0);
        old_time4 = hammerTime2;
        }
        //delay(600000); giving error - fixed by implementing millis() logic
        return 1;    
    }
    else return -1;
}

Hi, perhaps is worth opening a support ticket directly with Particle at this point in time.
Cheers,
Gustavo.

Probably unrelated to the issue, but you generally don’t want to be running code in function handlers.
Instead, use it to set a ‘flag’ and then check, and deal with that accordingly in the loop. Try keeping your function calls as short as possible.

1 Like

Problem solved from support team.
Added:
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

Particle.connect(); //end of setup()

1 Like