Skip to content

drivers: add driver for APDS9007 illuminance sensor#8989

Closed
Hyungsin wants to merge 1 commit intoRIOT-OS:masterfrom
Hyungsin:forupstream_apds9007
Closed

drivers: add driver for APDS9007 illuminance sensor#8989
Hyungsin wants to merge 1 commit intoRIOT-OS:masterfrom
Hyungsin:forupstream_apds9007

Conversation

@Hyungsin
Copy link
Copy Markdown

@Hyungsin Hyungsin commented Apr 19, 2018

This PR provides a driver implementation for APDS9007 illuminance sensor.
APDS9007 gives raw voltage value which is proportional to "lux".
This driver reads this voltage value through ADC, which needs to be converted to "lux" according to passive components. The voltage->lux conversion is out of the scope of this PR.

Note:
APDS9007's illuminance output is 3 to 70,000 lux, which cannot be captured by a 16 bit variable.
But raw voltage output is 0 to 3000 mV, which is durable.

Dependencies

#9013

@Hyungsin Hyungsin force-pushed the forupstream_apds9007 branch 3 times, most recently from 12317bb to a7a0a9a Compare April 20, 2018 00:05
@tcschmidt tcschmidt requested a review from kYc0o June 21, 2018 11:30
Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good. I don't have have the hardware so I can't test.

You need to uncrustify apds9007.c and apds9007_saul.c (opening curly braces of a function should be on next line).

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jul 3, 2018

Also this PR needs to be rebased.

@Hyungsin Hyungsin force-pushed the forupstream_apds9007 branch 2 times, most recently from 79ba77e to 5b05a33 Compare July 3, 2018 07:24
@Hyungsin
Copy link
Copy Markdown
Author

Hyungsin commented Jul 3, 2018

@aabadie, done!

Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis is reporting issues. And it seems the apds9007.h file is missing !

@Hyungsin Hyungsin force-pushed the forupstream_apds9007 branch 4 times, most recently from 74e52c2 to b162ffe Compare July 3, 2018 07:56
@Hyungsin
Copy link
Copy Markdown
Author

Hyungsin commented Jul 3, 2018

@aabadie. Oops. resolved again :)

@Hyungsin Hyungsin force-pushed the forupstream_apds9007 branch 2 times, most recently from 38d6acc to 6f63efd Compare July 3, 2018 17:37
@miri64 miri64 added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: drivers Area: Device drivers labels Oct 17, 2018
@PeterKietzmann PeterKietzmann added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 5, 2019
@PeterKietzmann
Copy link
Copy Markdown
Member

@Hyungsin is this part of the Hamilton board? If so, @danpetry could you test it?

@PeterKietzmann PeterKietzmann added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 5, 2019
@Hyungsin
Copy link
Copy Markdown
Author

@PeterKietzmann, @danpetry, yes please! I just came back to the development world and believe that #9013 is almost done.

@danpetry danpetry added the State: waiting for other PR State: The PR requires another PR to be merged first label Mar 20, 2019
@PeterKietzmann
Copy link
Copy Markdown
Member

#9013 was merged, @danpetry disappeared. Is there anyone else with access to this sensor or a Hamilton board? @emmanuelsearch? @jcarrano? @SemjonKerner?

@ghost
Copy link
Copy Markdown

ghost commented May 24, 2019

I did find some Hamilton boards, but none with the sensor so far. I'll keep looking.

@jcarrano
Copy link
Copy Markdown
Contributor

Yeah, I have a Hamilton.

@stale
Copy link
Copy Markdown

stale bot commented Nov 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Nov 28, 2019
@benpicco benpicco removed the State: waiting for other PR State: The PR requires another PR to be merged first label Nov 28, 2019
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Nov 28, 2019
@benpicco
Copy link
Copy Markdown
Contributor

The board is merged now and the driver is pretty simple.
Want to give this a rebase?

@Hyungsin Hyungsin closed this Nov 28, 2019
@Hyungsin Hyungsin force-pushed the forupstream_apds9007 branch from cfc0dcb to c68470f Compare November 28, 2019 23:21
@Hyungsin Hyungsin deleted the forupstream_apds9007 branch November 28, 2019 23:28
@Hyungsin Hyungsin reopened this Nov 28, 2019
@Hyungsin
Copy link
Copy Markdown
Author

Want to give this a rebase?

done

@Hyungsin Hyungsin force-pushed the forupstream_apds9007 branch from 57f07b0 to 1237d00 Compare November 29, 2019 08:16
@Hyungsin Hyungsin force-pushed the forupstream_apds9007 branch from 1237d00 to 1496634 Compare November 29, 2019 08:29
Copy link
Copy Markdown
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long dormancy, it took the stale bot to bring this back to live.

Some minor things: I'd rename the 'gpio' to shutdown so it matches the data sheet and it's function.
Since it's not needed for basic sensor operation, you should also handle the GPIO_UNDEF case.

I agree that it doesn't make much sense to convert this to lux since that would just mean multiplying it by an unknown factor and introducing inaccuracies.

* @brief Parameters needed for device initialization
*/
typedef struct {
gpio_t gpio; /**< GPIO pin that sensor is connected to */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data sheet calls this pin 'shutdown' which also makes sense given it's function.

dev->p.adcline = params->adcline;
dev->p.adcres = params->adcres;

gpio_init(params->gpio, GPIO_OUT);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gpio_init(params->gpio, GPIO_OUT);
if (params->gpio != GPIO_UNDEF) {
gpio_init(params->gpio, GPIO_OUT);
}

The sensor will still work if the shutdown pin is not connected / connected to ground and some platforms will crash if you try to initialize / access GPIO_UNDEF.


void apds9007_set_active(const apds9007_t *dev)
{
gpio_write(dev->p.gpio, 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

* @{
*/
#ifndef APDS9007_PARAM_GPIO
#define APDS9007_PARAM_GPIO GPIO_PIN(PA,6)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPIO_UNDEF would also be a good default here.

@stale
Copy link
Copy Markdown

stale bot commented Jun 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Jun 1, 2020
@stale stale bot closed this Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR State: stale State: The issue / PR has no activity for >185 days Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants