Skip to content

Grove_Generic_PWM

Ten Wong edited this page Jun 8, 2016 · 3 revisions

The Grove Generic PWM can output a pwm signal whit specified frequency and duty. It also can be read for current state.

API Description

GET /v1/node/GenericPWMOutD0/pwm

Read back the parameters of PWM.

Request method: GET

Returns:

HTTP 200 { "duty_percent": [float value],"freq": [uint32_t value] }
duty_percent: float value, 0.0~100.0, float number
freq: uint32_t value, unit: Hz
HTTP 400 {"error": "failure reason here"}
Curl example: 
curl -k https://iot.seeed.cc/v1/node/GenericPWMOutD0/pwm

Response: 
{"freq": 1000, "duty_percent": 50.0}

POST /v1/node/GenericPWMOutD0/pwm/[duty_percent]

Output a PWM wave on specified IO. The default frequency is 1K Hz.

Request method: POST

Arguments in URL:

[duty_percent]: float value, 0.0~100.0, float number
Returns:

HTTP 200 {"result": "OK"}
HTTP 400 {"error": "failure reason here"}
Curl example: 
curl -k -X POST https://iot.seeed.cc/v1/node/GenericPWMOutD0/pwm/20

Response: 
{"result": "ok"}

POST /v1/node/GenericPWMOutD0/pwm_with_freq/[duty_percent]/[freq]

Output a PWM wave on speicfied IO with specified frequency.

Request method: POST

Arguments in URL:

[duty_percent]: float value, 0.0~100.0, float number
[freq]: uint32_t value, unit: Hz
Returns:

HTTP 200 {"result": "OK"}
HTTP 400 {"error": "failure reason here"}
Curl example: 
curl -k -X POST https://iot.seeed.cc/v1/node/GenericPWMOutD0/pwm_with_freq/20/2000

Response: 
{"result": "ok"}