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.
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem