Description
Hardware:
Board: ESP32 ?ESP32
Core Installation/update date: ?27/Mar/2018?
IDE name: ?Arduino IDE
Flash Frequency: ?80Mhz?
Upload Speed: ?115200?
yellow PIN 18 SDA, RED PIN 19 SCL
Description:
I have ESP32 connected to ADS1015 through i2C (PIN 18, 19), everything was cool when I first had the ESP8266 but when I changed to ESP32 first I got zeros from the function readADC_SingleEnded()
However when I changed to your arduino-esp32 I am getting a constant value of 4096 all the time.
any suggestions.
`#include "Arduino.h"
#include "Adafruit_ADS1015.h"
Adafruit_ADS1015 adc;
void getSolarCurrent() {
adc.setGain(adsGain_t::GAIN_TWO); //set upper limit vmax to 2.048V
uint16_t adc_res = adc.readADC_SingleEnded(1);
Serial.println("ADC res: "+String(adc_res));
Serial.flush();
//return (double) adc_res / 8.326; //Result is in mA (adc_val 2048mV/2047 / 8.33 / 1 Ohm)
}
void getCapVoltage() {
adc.setGain(adsGain_t::GAIN_ONE); //set vmax to 4.096V
uint16_t adc_res = adc.readADC_SingleEnded(0);
Serial.println("ADC res: "+String(adc_res));
Serial.flush();
//return (double)adc_res / 0.4998;//Result in mV (adc_res * 4096mV/2047)
}
void setup() {
//rtc_clk_cpu_freq_set(RTC_CPU_FREQ_80M);
Serial.begin(115200);
Serial.println();
Serial.println("Booted");
Serial.flush();
adc.begin(); /* own begin-method which sets sda=2 and scl=14 pins to the ones used on solar board (and data sheet) */
yield();
getSolarCurrent();
getCapVoltage();
esp_sleep_enable_timer_wakeup(10*1000000);
esp_deep_sleep_start();
}
void loop() {
}`
Debug Messages:
Booted
ADC res: 4095
ADC res: 4095
Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here