2
votes

I get the following error message from nodeMCU on esp8266 : attempt to call field "adc.force_init_mode" (a nil value). Can somebody point out the mistake please?

if adc.force_init_mode(adc.INIT_ADC) 
  then
    node.restart()
  return
end
val = adc.read(0)
print("Input number:", val )
val2 = 5000000 - (val*5000000/1023)
print("R (ohm):", val2 )
1
Do you have a adc = require 'adc' anywhere? - hjpotter92
If it's possible, put it before the snippet you provided. - user6245072
Do you need any more info? If not, consider accepting (and/or upvoting) the answer so that SO can mark this as answered. - Marcel Stör

1 Answers

2
votes

Your firmware does either not have the ADC module compiled in or it's got an ADC module without the force_init_mode function.

Therefore, build a recent firmware and flash it to upgrade your current firmware.