ADC and ADC_battery doesnt work together

You can read the battery voltage with the function:

uint16_t voltage = getBatteryVoltage();

it worked fine.

You can read the voltage of the ADC-Pin with the function:

sensorValue = analogRead(ADC);

But when there is an analog signal, the battery voltage can no longer be read out, incorrect value is displayed.

When i open the connection to the ADC-Pin, the battery-voltage is shown right.

Here my test-Code:

void loop() {
// read the value from the sensor:
sensorValue = analogRead(ADC);

Serial.println (sensorValue);

batteryVoltage = getBatteryVoltage();

Serial.println (batteryVoltage);



Hope this document make sense to you:

In the new 6502 series, there have three ADC input channels.

1 Like

Thank you!

I will look for this device!


Is it possible to read an external analog signal on the CubeCell Capsule (HTCC-AC01), I don’t see an ADC signal on the pinout:

According to the description of CubeCell Capsule Solar Sensor, this device is also based on the 6502, is there a ADC input available for measurements besides the battery?

I’m also confused regarding the analog inputs. I’m using the plus board with three adc’s. I read that the maximum voltage on the analog inputs is 2.4 volts, so I added a voltage divider connected to the vext port and measured about 2.3 volts. If I now connect that power to e.g. adc2 the values of adc1 and 3 also go up and are almost equal to adc2. What am I doing wrong here?

Good Day - I have been doing some validation testing on the CubeCell AB02S board and see that the ADC2 and ADC3 channels are ‘interacting’. For example having the turned on the VBAT_ADC_CTL (it’s LOW for ‘ON’) and reading the ADC1 I get a sensible number (Yes I know this is halved by the resistor divider). But if I inject a separate voltage into either ADC2 or ADC2 this will then affect the VBAT result.

In fact they all interact with one another, if I inject 1.0V into ADC3 then all of the other ADC results will report around 1000 (mV).

Have a lot of experience with the CY8… family of PSoC Ics, I suspect the internal MUX selection is not programmed properly on the ASR6502 (I have made this error before on those PSoC projects!)

If I am correct with this it would mean we would need a file to flash into the 6502 to correct this error OR (Hopefully) there is another instruction I am missing that needs to be included between the ADC reads?

Here is the code snippet:

digitalWrite(VBAT_ADC_CTL,LOW); // enable battery (1/2) onto ADC1

voltage=analogRead(ADC1);//return the voltage in mV, max value can be read is 2400mV
Serial.print("ADC1 (Batt) = ");
digitalWrite(VBAT_ADC_CTL,HIGH); // disable battery from ADC1

pixels.setPixelColor(0, pixels.Color(0, i, 0)); // Green; // Send the updated pixel colors to the hardware.

voltage=analogRead(ADC2);//return the voltage in mV, max value can be read is 2400mV
Serial.print("ADC2 = ");

pixels.setPixelColor(0, pixels.Color(0, 0, i)); // Blu?; // Send the updated pixel colors to the hardware.

voltage=analogRead(ADC3);//return the voltage in mV, max value can be read is 2400mV
Serial.print(“ADC3 = “);

1 Like

@npaterson Thanks for the hint. I just tried flashing the firmware 3.1.1, but the adc’s are still all reacting to each other. If I apply a voltage to adc2 all adc’s go up and if I also attach a ground to adc3 all adc’s go down. Something is wrong here.

@Supporter Could you please take a look at this? Is this an error in the firmware?

This could be only a problem when there is an open connector.

Try to put different Voltage on the two ADC Inputs and then look at the result.

I’ve just tried that. I attached 1 volt to adc3 and 2 volts to acd2 and I get 1 volt on both adc’s. If I also pull adc1 to ground I get only about 500 mv on all pins. Any idea what could cause this problem?

Ok, that’s not good news. I hope then, it is only a bad implementation of arduino-ADC

Hi Ernst - I know exactly where the fault lines (in the PSOC Mux implementation), I was hoping that there might be an ‘Arduino’ level command to actually switch the onboard mux but as I am a very long time ‘c’ guy and only new to C++ I needed to ask.

If I could get my hands on the PSOC source I know I can fix this and as the SWD-Data and SWD-Clk are pinned out to the header we would have a good chance of sorting this out.

I have sent a seperate query to Support in the meantime I’ll avoid using ADC2 or ADC3

I guess the firmware is not open source. At least I didn’t find anything on GitHub. I hope that HellTec will take a look at this.

@npaterson Did you receive an answer from the support in the meantime? Or is there someone else we could ask here in the forum to take a look at this?

There’s a commit on GitHub “fixed an adc bug” in the compiled library from about 6 days ago. It would be worth updating your library (from GitHub) and repeating your tests.

@bwooce Thanks for the hint. I’m using to develop and I guess there the library there was not updated yet. I’ve now replaced the files manually with the one’s from the master repository and now the ADC’s are working. :grinning: Thanks again for the hint!