Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analog Attenuation API? #87

Closed
torntrousers opened this issue Dec 10, 2016 · 6 comments
Closed

Analog Attenuation API? #87

torntrousers opened this issue Dec 10, 2016 · 6 comments

Comments

@torntrousers
Copy link
Contributor

Thanks for the recently committed analog functions.
Is there a problem with analog attenuation or some reason why its not exposed as an API to Arduino sketches? Or is it coming soon perhaps?

@me-no-dev
Copy link
Member

Tried it and it did not work :)

@torntrousers
Copy link
Contributor Author

Heh, yes me too fiddling about in esp32-hal-adc and it didn't work for me either. Could I raise this as a bug with Espressif somewhere - (I don't properly understand how all the components fit together ) - is it hardware thing or the sdk or idf ...?

@me-no-dev
Copy link
Member

it's either hardware or we are missing some setting in the software that I do not know about. You can raise an issue in esp-idf as lower level guys visit that repo :)

@torntrousers
Copy link
Contributor Author

torntrousers commented Dec 13, 2016

Over here it was suggested to use adc1_config_channel_atten, thats seems to work ok.

Its in #include <driver/adc.h> and can do:
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_11db);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_6db);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_2_5db);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_0db);

That seems to give a max input voltage of:
0db = 1.1v
2.5db = 1.4v
6db = 1.9v
11db = 3.2v

Was hoping for a little wider range.

@me-no-dev
Copy link
Member

no wonder... I was writing to the wrong register

@me-no-dev
Copy link
Member

please try the latest commit

    analogSetAttenuation(ADC_0db);
    analogSetPinAttenuation(A18, ADC_0db);
    analogSetPinAttenuation(A19, ADC_2_5db);
    analogSetPinAttenuation(A6, ADC_6db);
    analogSetPinAttenuation(A7, ADC_11db);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants