Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

ESP32 ADCs won't enable in js

I am trying to read any channel of the ESP32's ADC. Does the "pin" refer to the ESP32 pin number or the GPIO number? In any case, I can't seem to get any ADC channel to enable, as follows. No matter what "pin" is selected, the ADC.enable(pin) always returns 0. Is there some adjustment that must be made to mos.yml or conf0.json? Has any one got experience with ESP32's ADCs. Thanks for your help. JSW

load('api_config.js');
load('api_events.js');
load('api_net.js');
load('api_sys.js');
load('api_timer.js');
load("api_adc.js");

/*
let fooo=ADC.enable(20);
let gooo=ADC.enable(21);
let hooo=ADC.enable(22);
let iooo=ADC.enable(23);
let jooo=ADC.enable(24);

let fooo=ADC.enable(25);
let gooo=ADC.enable(26);
let hooo=ADC.enable(27);
let iooo=ADC.enable(28);
let jooo=ADC.enable(29);

let fooo=ADC.enable(10);
let gooo=ADC.enable(11);
let hooo=ADC.enable(12);
let iooo=ADC.enable(13);
let jooo=ADC.enable(14);
*/
let fooo=ADC.enable(15);
let gooo=ADC.enable(16);
let hooo=ADC.enable(17);
let iooo=ADC.enable(18);
let jooo=ADC.enable(19);

let getInfo = function() {
return JSON.stringify({
total_ram: Sys.total_ram(),
free_ram: Sys.free_ram()
});
};

let time0=Timer.set(3000, Timer.REPEAT, function() {
print(fooo,gooo,hooo,iooo,jooo,'Tick', 'uptime:', Sys.uptime(), getInfo());}, null);

Comments

Sign In or Register to comment.