Hi @Aurithemas ,
You need to use three analog inputs.
If you are using RAK19001 as baseboard and RAK4631 (Not RUI3), you can use WB_A1, WB_SPI_MOSI and WB_SPI_MOSI as analog inputs. WB_A0 is connected to VBAT so you cannot use it (unless the voltage divider on WB_A0 wont have any on the sensor readings).
These are the pins.
Here’s a sample sketch on getting the analog reading.
#include "Wire.h"
// These constants won't change. They're used to give names to the pins used:
const int analogInPin = WB_A1; // Analog input pin that the potentiometer is attached to
const int analogInPin2 = WB_SPI_MOSI; // Analog input pin that the potentiometer is attached to
const int analogInPin3 = WB_SPI_MISO; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
int sensorValue2 = 0; // value read from the pot
int sensorValue3 = 0; // value read from the pot
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
sensorValue2 = analogRead(analogInPin2);
sensorValue3 = analogRead(analogInPin3);
// print the results to the Serial Monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print(" sensor2 = ");
Serial.print(sensorValue2);
Serial.print(" sensor3 = ");
Serial.println(sensorValue3);
// wait 500 milliseconds before the next loop for the analog-to-digital
// converter to settle after the last reading:
delay(500);
}
You also have the option to use the WisBlock ADC module RAK16001. This can give you more reliable readings than the built-in ADC. Of course, it still depends on your preference.