Monitor a break system

greenleaf
Posts: 4
Joined: Tue Jun 11, 2024 4:52 pm

Monitor a break system

Postby greenleaf » Sun Jun 16, 2024 1:20 am

I have a "thumb accelerator" similar to the ones found on most scooters. I want to read its value every time a user presses it.

What is the correct way to read an analog signal?

I have:

Code: Select all

    esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_DEFAULT, 0, &adc1_chars);
    adc1_config_width(ADC_WIDTH_BIT_DEFAULT);
    adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_DB_11);
But I get warnings that these functions are deprecated. And then this, that I saw from the documentation:

Code: Select all

    uint32_t reading =  adc1_get_raw(ADC1_CHANNEL_5);
    esp_adc_cal_characteristics_t *adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
    uint32_t voltage = esp_adc_cal_raw_to_voltage(reading, adc_chars);
What is the correct way to read the analog input from the device, and how should I structure my code, so it is efficient, given that I want to react as fast as possible?

greenleaf
Posts: 4
Joined: Tue Jun 11, 2024 4:52 pm

Re: Monitor a break system

Postby greenleaf » Thu Jun 20, 2024 8:17 pm

Does anyone know a better alternative forum for esp32 related questions at least?
Having to wait a few days for each post to be approved, and the forums not being very active is not helpful. I'd still want to try a bit more before switching to Arduino.

MicroController
Posts: 1549
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Monitor a break system

Postby MicroController » Mon Jun 24, 2024 6:49 pm

Needing approval for every post is only temporary, until you are found to not be a spam bot, which I believe is after having 3 posts approved.

I think your original question is not very clear. Obviously(?), the 'correct' way to do things is as indicated by the API documentation and demonstrated in the accompanying examples for the IDF version you are using - most of the time.
When documentation or examples fall short you may be able to get suggestions, ideas, or clarification on specific issues here.
One way of asking here that tends to get good results is by first helping people to understand what your problem is, like: This is what I'm trying to achieve, this is what I have, this is what I have tried (code,...), and this is the result I currently get, which is not what I want/need/expect because...

In your case, I get that you want to read an analog input signal. And you want it 'fast', which is an inherently relative concept. Because the signal comes from a manual input, I assume response times of a few tens of milliseconds are acceptable, which in terms of an ESP32 MCU is actually really slow.

Who is online

Users browsing this forum: No registered users and 141 guests