Analog read lolin v3

Posted on
  • Can you analogread with a NodeMcu esp8266 lolin v3 board? Can't set pinmode, since it ain't supported ?

  • You should be able to analogRead() on an ESP8266. There's only that one ADC pin, but last I checked reading from it worked fine.

    You don't need to do pinMode(). Actually, with Espruino, you don't need pinMode() at all for doing basic GPIO - if pinMode() hasn't been called yet on the pin, digitalRead() will set it as input and digitalWrite() will set it as output. If pinMode() has been called already, it will leave it as is.

    As an aside, you don't need to use pinMode() before analogRead in Arduino-land either, since pins start as inputs (at least for AVRs; I think same is true for ESP8266 though)

  • Well that's lovely! Thank you for such a great answer! Do i need some kind of resistor for reading a basic soil sensor?

  • What kind of sensor is this? There are several designs.

    You'll probably need a voltage divider to get the 0~3.3v or 0~5v output of sensor into the 0~1v range of the ADC - however, this may have already been done for you on the lolin board - some of the ESP8266 development boards do this.

  • It's one of thoose chines sensors, posting pic, i think they might do it for me.
    http://i.ebayimg.com/images/i/271967983438-0-1/s-l1000.jpg

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Analog read lolin v3

Posted by Avatar for Gustav @Gustav

Actions