[SOLVED] New to Photon -- can't get servo to work

I have a Photon and an Emax ES08AII Analog Servo. I connected Yellow to A0, Brown to GND, and Red to VIN per the Servo example at Wireless Servo control with Emax ES08A Servo and Spark Core

I then flashed that example and tested out a quick CURL. I double-checked and triple-checked my access token was correct, but for some reason I always get this:

Header: HTTP/1.1 400 Bad Request
"error": “invalid_request”,
“error_description”: “The access token was not found”

Can anyone see what I might be doing incorrectly? Thank you.

1 Like

You definetly are using the access-token (40 hex digits) and not your device ID (24 hex digits)?

If you are absolutely certain it’s the correct access-token, then you might just want to try creating a new one and use this.

Yep – I am using the device ID in the address and the access token in the -d of the curl.

I already tried to reset the token and use it – that doesn’t work (I tried it twice).

I’m not quite sure what I’m doing incorrectly.

So you are doing:

curl https://api.spark.io/v1/devices/<<my device name or number>>/servo -d access_token=<<my hex token here>> -d "args=180"

Where <<my device name or number>> is the name or hex ID of your Photon, and <<my hex token here>> is the cut-and-paste token you got out of the build.particle.io web screen.


1 Like

If you show your own command (best already in your first post), we might not have to guess what’s wrong and could help quicker.

The command @bko has shown should work.
Have you by any chance added the line break symbols (\) from the code comment you linked to? That might be a possible reason.

Okay, so I have an update. I think my original problem was that I was using an online curl sender, I hopped on Ubuntu and did curl the proper way and I started getting a response of connected and “200” which the script says is good.

But the servo doesn’t move. I put “args=” 0, 180, 100, it doesn’t matter, it doesn’t move. I reflashed Tinker to make sure the thing works. When I put A0 to high or low, the servo bumps a tiny bit forward. I have to do it about 20 times to get a few degrees. So I think the servo works, but I’m not sure. I’m wondering if I should buy another and try it out?

Thanks for all your help so far.

A0 is not one of the pins that has PWM on the Photon. The docs say PWM is available on D0, D1, D2, D3, A4, A5, WKP, RX, and TX. Try one of those, and it should work properly.

1 Like

It worked great. Thank you!