RAK11720 ADC voltage measurement

Hello everyone,

Iam currently using a RAK 11720 and i want to measure a voltage between 5-30V with ADC. I want to know if there is a way to do this with this module and how. The reason for my question is that i read some problems with the internal voltage reference why it can be difficult to measure voltages.

I hope someone can help me out,

Kind regards,
Marnick

I saw the breakout board doesnt support ADC measurement, is this correct? I want to test the ADC of the RAK11720 but it looks like its impossible with the breakout board. Can someone help me out with this problem?

Kind regards,
Marnick

Hi @Marnick ,

You should be able to use two ADC input on the breakout board (PIN_A3 and PIN_A7)

I tried to use these pins but i dont receive any raw data. This is my code, Iam using a 120K and 15 K resistor for voltage dividing and i measure a voltage of 0.5V on pin 7. Can you help me with this?

/***
 *  This example read WB_A1 pin in analog signal.
***/
//Set pin number
//#if defined(WISBLOCK_BASE_5005) || defined(WISBLOCK_BASE_5005_O)
//uint8_t analogPin = WB_A1;
//#else
#warning Please set the right pin refer to the documentation
uint8_t analogPin = WB_SPI_MOSI;	//analog Pins 
//uint8_t analogPin = PIN_A7;	//analog Pins 
//#endif

void setup()
{
    // initialize serial communication at 115200 bits per second
    Serial.begin(115200);
    delay(2000);
    Serial.println("RAKwireless Arduino Analog Example");
    Serial.println("------------------------------------------------------");

    //Assume RAK5811 is plugged, so turn on RAK5811 first.
  //  pinMode(WB_IO1, OUTPUT);
 //   digitalWrite(WB_IO1, HIGH);

    analogReadResolution(14);
}

void loop()
{
    float max, ref;

    switch (udrv_adc_get_resolution()) {
        case UDRV_ADC_RESOLUTION_6BIT:
        {
            max = 64.0;
            break;
        }
        case UDRV_ADC_RESOLUTION_8BIT:
        {
            max = 256.0;
            break;
        }
        case UDRV_ADC_RESOLUTION_10BIT:
        default:
        {
            max = 1024.0;
            break;
        }
        case UDRV_ADC_RESOLUTION_12BIT:
        {
            max = 4096.0;
            break;
        }
        case UDRV_ADC_RESOLUTION_14BIT:
        {
            max = 16384.0;
            break;
        }
    }

    switch (udrv_adc_get_mode()) {
        case UDRV_ADC_MODE_DEFAULT:
        default:
        {
            #ifdef rak11720
            ref = 2.0;
            #else
            ref = 3.6;
            #endif
            break;
        }
        #ifdef rak11720
        case UDRV_ADC_MODE_1_5:
        {
            ref = 1.5;
            break;
        }
        #else
        case UDRV_ADC_MODE_3_3:
        {
            ref = 3.3;
            break;
        }
        case UDRV_ADC_MODE_3_0:
        {
            ref = 3.0;
            break;
        }
        case UDRV_ADC_MODE_2_4:
        {
            ref = 2.4;
            break;
        }
        case UDRV_ADC_MODE_1_8:
        {
            ref = 1.8;
            break;
        }
        case UDRV_ADC_MODE_1_2:
        {
            ref = 1.2;
            break;
        }
        #endif
    }
    int adc_value = analogRead(analogPin);
    Serial.printf("ADC pin value = %d\r\n", adc_value);	// print analogPin adc value 
    // This is the formula to get the input voltage of RAK5811:
    Serial.printf("Voltage value = %f V\r\n", ref*(((float)adc_value)/max)*(5.0f)/(3.0f));
    delay(1000);
}

You removed the code part that is actually switching on the RAK5811:

Hello @beegee , iam not using the RAK5811. Iam just using the RAK11720 breakout board only. So in my opinion i can remove this code?

Another question i need to use 4 different ADC measurements at the same time. Is this possible?

@carlrowan I cant measure any voltage on PIN_A7 or PIN_A3. on both pins i measure a voltage of +/-1,7 V but i dont receive any raw data.

Do you have a example code or ideas how this can happen?

Kind regards.

with the PIN_A7 and PIN_A3 its i couldnt measure ADC. But i soldered a cable to pin 32 of the module and this one is working. So this problem is solved.

Is there a way to use a external reference of 3.3V. I need this 3.3V external reference instead of the 1.5 or 2V internal reference.

Can you help me out?

Hi @Marnick ,

I am sorry for the wrong pins. We will update our variant file.

These are the five pins you can use for the ADC.

image

As for the reference, the Apollo 3 Blue is limited to 1.5V or 2.0V either using the internal bandgap or external. 3.3V is not supported.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.