Compilation error: analogRead Ai-WB2-32S-Kit bl602

Hello everyone,

I am currently developing a programming code for the Ai-WB2-32S-Kit board, which is equipped with a BL602 microchip. I am interfacing the board with the Arduino IDE as a PINE64 PineCone. I am seeking to implement the ADC (analog-to-digital converter) function. However, when I compile the code, the Arduino IDE displays the following error: 'Compilation error: 'analogRead' was not declared in this scope' (I am attaching a screenshot).

The board has the ADC function on multiple pins. I am using pin 14, configured with ADC function on channel 2. (I will send an image of the board specifications).

The code I am implementing is:

#include "bl602_adc.h"
#include "bl602_gpio.h"
#include "bl602_hbn.h"

float val;

void setup() {
  pinMode(14, INPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(12, OUTPUT);

  Serial.begin(115200);
}

void loop() {
  val=analogRead(14);

  Serial.println(val);

  delay(500);

  if (val>=0,val<255) {

    digitalWrite(4, HIGH);

    digitalWrite(5, LOW);

    digitalWrite(12, LOW);
  }

  if (val>=255,val<511) {

    digitalWrite(4, LOW);

    digitalWrite(5, HIGH);

    digitalWrite(12, LOW);
  }

  if (val>=511,val<767) {

    digitalWrite(4, LOW);

    digitalWrite(5, LOW);

    digitalWrite(12, HIGH);
  }
}

Could you please assist me and guide me on how to correct the error, or inform me of what I am doing wrong?

Thank you very much.

Stiven Cortazar C.

Hi @stiven121212. The reason for this error is that the developers of the "Bouffalo Arduino Core" boards platform of your PINE64 PineCore board never implemented the analogRead function in their core:

https://github.com/pine64/ArduinoCore-bouffalo/projects/1#card-50698578

If you want to use the ADC, you will need to use lower level code to do so.

Dear Mr. @ptillisch,

I understand that the analogRead function is not implemented. Could you please provide me with an example of low-level code to guide me, or with web pages or repositories, please?

Thank you very much for your help and time, you are very kind.

Unfortunately I don't have any experience with this architecture so I will not be able to provide assistance. Hopefully one of the other forum members will be able to help you out.

I understand Mr. @ptillisch, thank you very much for the information, thank you very much for your time. You are very kind.

1 Like

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