Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Terraformer
#58187 Searched exactly for this solution! Unfortunately, it does not work. Any idea where my fault is?

ESP-12f, Arduino IDE 1.6.9, ESP Core 2.3.0. My Sketch:
Code: Select alluint8_t adc_what_I_want = ADC_TOUT;
ADC_MODE(adc_what_I_want);

extern "C" {
  #include "user_interface.h"
}
#define PIN_ADC_PWR 14


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
 
  pinMode(PIN_ADC_PWR,OUTPUT);
  pinMode(A0,INPUT);
  digitalWrite(PIN_ADC_PWR,HIGH);
 
}

void loop() {
  delay(500);
  adc_what_I_want = ADC_TOUT;
  delay(100);
 
  unsigned int val = analogRead(A0);
  delay(100);
  Serial.print("read A0 ");
  Serial.println(val);
  adc_what_I_want = ADC_VCC;
  delay(100);
  float ppp = ESP.getVcc();
  Serial.print("read Vcc ");
  Serial.println(ppp);
}

martinayotte wrote:Ugly, right ? ;) :ugeek:
Well, yeah. But I don't care as long as it works ;)

Thanks & best!
User avatar
By Jindrich Sirucek
#73493 I thing that code
uint8_t adc_what_I_want = ADC_TOUT;
ADC_MODE(adc_what_I_want);
etc..
Was written as assumption, not as tested working solution.

I have thoroughly tested this example by myself and it really doesnt work. the ADC mode is for the whole program run in mode which was the first one set..

Does anybody find a way how to switch those two modes?
User avatar
By rudy
#73593
Jindrich Sirucek wrote:Does anybody find a way how to switch those two modes?

From the reading I have done on the subject it is either one or the other. No option to change.