ESP8266 with NodeMCU & AM2321 Temperature & Humidity sensor with web interface. Basically this project allow you to show AM2321 readings in web browser in normal HTML format or XML format. You should treat this as example than fully working "remote sensor". I have still trouble with heap (that goes too low) because of my software i2c lib.
To communicate with AM2321 I had to create (copy my i2c library for AVRs) software I2C library because library builtin into NodeMcu didn't want to talk with AM2321 (I don't know why, and I didn't dug into).
I assume that you have working ESP8266 with flashed NodeMCU...
I'm using ESPloer for loading scripts. After loading script the ESPloere have "feature" (annoying one) that runs the script. So after loading each script you have to hard reset (by hardware - not by software because this does not release all heap).
After reset, you compile uploaded script. You only do not compile init.lua
and this script should be the last one to be uploaded ๐ .
I have tested this "installation" of my scripts ๐
- upload to ESP
my-i2c.lua
- Hard-reset ESP and compile
my-i2c.lua
- upload
am2321.lua
- Hard-reset ESP and compile
am2321.lua
- upload
httpd-sensor.lua
- Hard-reset ESP and compile
httpd-sensor.lua
- Upload
configServer1.lua
- Hard-reset ESP and compile
configServer1.lua
- Now you can configure sensor if you want (connect to created SSID by ESP and save configuration)
- upload
init.lua
and hard-reset
Now if you didn't connected your ESP to your WiFi. ESP should start config server by creating new WiFi network with "SvrSens-" prefix and 3 last bytes of MAC address.
Now connect to this network (I have used tablet) and open in web browser address 192.168.4.1
.
If you want to reconfigure ESP with this sensor-server, then the fastest way is to connect serial console and rename init.lua
to anything else e.g.: =file.rename("init.lua","init0.lua")
, then hard-reset ESP and manually run ```dofile("configServer1.lc")```` .
Or walking out of range your AP should should also load from init configServer1 but I didn't tested it.