-4

I directly copy-pasted the dht.md example from the official NodeMCU GitHub into my Script window like so:

enter image description here

But upon saving to ESP8266 I get an error:

init.lua:3: attempt to index global 'dht' (a nil value)
halfer
  • 19,824
  • 17
  • 99
  • 186
pulsar100
  • 41
  • 7
  • 2
    Please refrain from begging - [the community discussed this recently](http://meta.stackoverflow.com/q/326569/472495). – halfer Jul 05 '16 at 16:34

1 Answers1

1

Which NodeMcu firmware (version) do you use? Make sure you get (build) the latest (1.5.1), easiest to get it from here: http://nodemcu-build.com/

And -make sure- you click the little box saying 'DHT' there.

bluemind
  • 1,591
  • 11
  • 16
  • Using esplorer.ru is there any way I can download just DHT for that? – pulsar100 Jul 05 '16 at 16:40
  • No, you need DHT compiled into the firmware. The only option is to use the build service to compile a new firmware, which includes it, and then to re-flash that onto the ESP. – bluemind Jul 05 '16 at 16:51
  • This site gave me a binary file, is there another site available that would give me the firmware in a better format? – pulsar100 Jul 05 '16 at 18:49
  • I'm affraid that firmware only comes in a binary format. I assume you originally flashed your ESP? Didn't that use a binary file? – bluemind Jul 05 '16 at 20:35
  • You want to use these instructions to flash it: https://nodemcu.readthedocs.io/en/dev/en/flash/ – bluemind Jul 05 '16 at 20:36
  • You want to flash that binary (what's the file name?) to address 0x00000, This tool: https://github.com/nodemcu/nodemcu-flasher/tree/master/Win32/Release is probably the easiest to use for that, you probably want to read these instructions also: https://learn.adafruit.com/building-and-running-micropython-on-the-esp8266/flash-firmware, and you will need to set your ESP in flash mode, which requires pulling the right pins up/down, if your ESP doesn't have a flash button – bluemind Jul 05 '16 at 20:40