-
1Configure your web server
Install a web server and enable PHP support. I used a Raspberry Pi and Lighttpd for my web server. If one plans to go the same route, here's the commands to enter on the terminal:
apt-get install lighttpd php-cgi lighty-enable-mod fastcgi lighty-enable-mod fastcgi-php service lighttpd force-reload
The directory structure that I created was:
/var/www/html(web server document root)/sensorlogging
under the sensorlogging directory
php directory
logfiles directory
The ownership of the logfiles directory needs to be changed so that lighttpd can read-write contents:
chown www-data logfiles
Under the php directory and drop in the rsensor_dht22.php file. This file can be edited to match the directory structure used if it's different from the example. in the logfiles directory create a file named "rsensor_dht22.txt" and in the file put "enable" to enable logging.
-
2​Flash the ESP8266 board with MicroPython firmware and configure it to connect to your AP/router
Instructions can be found here:https://docs.micropython.org/en/latest/esp8266/tutorial/intro.html
Also be sure to enable WebREPL and set a password
-
3Connect the DHT22 sensor, Access WebREPL and upload the python file
Connect the DHT22 sensor. The + should go the the 3.3V pin and the - to the ground pin. The middle pin should connect to the pin labeled D11/MOSI/D7 on the WeMos D1 board.
Find out the IP address of the ESP8266 board. This can be discovered by either viewing the dhcp leases list on the router or by querying the ESP8266 board itself with the serial REPL.
After you get the IP address go to http://micropython.org/webrepl/ enter the IP address of your board and click connect. Enter the password that you created in step 1. Edit the esp8266_dht22.py file with the IP address of the web server to be used and if necessary, the rest of the URL if the directory structure differs. After doing that, send the file to the device and on the WebREPL terminal enter this:
import esp8266_dht22 esp8266_dht22.go()
If all goes well in the logfiles directory, the file "rsensor_dht22.csv" should show up after some time with readings. If not check the webserver error log file and the WebREPL browser window for any errors. If all is going well the WEBREPL window can be closed.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.