[Solved] Tinker device error: bad request (400)

Hi All

Just started with my electron and having some getting started related problems.

My device has a custom tinker firmware with correctly configured APN (waiting to hear back from Particle engineers on whether my Particle sims will work) and appears to be normally connected, breathing cyan.

Trying to do a simple D7 LED control from the Tinker iOS app persistently fails with the error “bad request (400)” as shown below:

After a number of initial attempts, I did successfully get it to work once, but several successive attempts all return this same error.

Is anyone able to assist me with identifying where in the chain of communication between the Tinker app on my iPhone and my device this particular error is occurring?
I’d also like to know if this is something I can debug/troubleshoot myself (and if so, a pointer to the relevant docs would be a great help) or if it’s something that only Particle support can assist with.

Thanks for your time

Some more info about the customisations would be required

The firmware that I flashed to the device is the one downloaded during set up of the electron with a non-Particle sim card.

The only input requested during the set up process is for the mobile provider’s APN, so I infer it differs from standard firmware by at least that aspect.

I don’t really know enough at this stage to provide details of any other differences between this custom firmware and the standard firmware, but am hopeful that those with experience of the non-Particle sim set up would be able to advise any further differences that there may be.

I believe you need to make an even more custom version of Tinker, setting the keep-alive value to be much smaller.


Particle SIM cards have a really long keep alive interval of 23 minutes. 3rd party SIM cards can range from about 30 seconds to several minutes. What happens is if the cellular network does not get a keep alive ping often enough, it shuts down the incoming port to the Electron. This prevents things like variables, functions and OTA code flash from working, which is what you’re seeing here.

You take the Tinker example code from


and paste in at the top your APN setting

STARTUP(cellular_credentials_set(PASTE_YOUR_APN_HERE, "", "", NULL));

and in setup() the keep alive. This sets it to 30 seconds, but you probably want to make it longer to avoid using a lot of data. The specific value depends on your carrier.

1 Like

Brilliant, thank you!!

I will give this a try.

Ok, this is embarrassing.

I copied the code, added the cellular credentials at the top and modified my setup as follows:

void setup()
    // Set custom keep alive

    //Setup the Tinker application here

    //Register all the Tinker functions
    Particle.function("digitalread", tinkerDigitalRead);
    Particle.function("digitalwrite", tinkerDigitalWrite);

    Particle.function("analogread", tinkerAnalogRead);
    Particle.function("analogwrite", tinkerAnalogWrite);

However I can’t get the code to build. Fails with this error:

mytinker.cpp: In function 'void setup()':
mytinker.cpp:16:11: error: 'class CloudClass' has no member named 'keepAlive'

I’m building in Web IDE. The reference docs indicate keepAlive() as a cloud function under particle device firmware. Reference doesn’t mention any particular headers being required, unless I missed that in my quick skim through.

If I comment the keepAlive line out, firmware builds just fine, so it can find the Particle.function() member fine, just not keepAlive().

I’m sure the answer is obvious, I’m just losing it in the forest of trees…


My guess is that your Electron is running 0.4.8 and your build is targeting 0.4.8. Or the build target isn’t set to an Electron.

You’ll probably want to upgrade your Electron system firmware to the current version (0.5.2) using particle update and then make sure you’ve selected that version in your build environment. The keep alive feature was added in 0.5.0; sorry I forgot that you had a factory fresh Electron which probably has 0.4.8.

Which build environment are you using? Particle Build (Web IDE), Particle Dev (Atom IDE) or Particle CLI?

I have all three. :laughing:

I have CLI installed as I used that to push the modified firmware I downloaded as part of the setup process to the Electron.
I also installed Particle Dev, but that failed to build my tinker app in cloud with an error "build didn’t produce binary Error: Command failed: …/…"
Clicking that message displayed “There were no compile errors”, so that was no help.

Eventually I got something sensible to chase down using the Web IDE…

Thanks for your insights. Will do a system firmware update and try again.

After updating the system firmware from 0.4.8 to 0.5.2 and implementing keepAlive(), this appears to have solved my problem. I can now set D7 high and low successfully from my iPhone, even after several minutes, which means I can now tinker with Tinker.

At some point in the future, I’ll have to experiment with various values for the keepalive pings, but for now I’m not concerned about bandwidth and will leave it at 30s.

Many thanks @rickkas7.

Now if only I can find a way to edit this topic subject and mark it [SOLVED]…

1 Like