GithubHelp home page GithubHelp logo

intrudera6 / esp8266-dht Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mathew-hall/esp8266-dht

0.0 1.0 0.0 629 KB

Temperature logging and web UI for the ESP8266 WiFi module

Makefile 5.66% C 89.43% Smarty 4.02% CSS 0.28% HTML 0.16% C++ 0.44%

esp8266-dht's Introduction

ESP8266-based DHT11 (and 22) logger

This application builds on Martin's DHT22 webserver implementation, which uses sprite_tm's ESP8266 httpd.

This version adds a check to make sure a DHT sensor is connected, and prevents the sensor being polled past the manufacturer's maximum frequency. It also logs sensor readings to a remote machine over the network as JSON, sent over UDP.

In addition to a DHT sensor, a DS18B20 1wire temperature sensor can be attached to port 0. If there's one attached, readings will be sent to the logging server and shown in the dht22.tpl page on the webserver.

If enabled (default is off), the code will try to sleep the ESP chip rather than leave it running. This requires a physical connection between the RST and GPIO16 pin, otherwise the chip won't wake up after going to sleep. The cycle time in "sleep mode" is about one minute. See Issue #3 for the needed fix to allow the board to wake back up.

Configuration

There are a few parameters that can be changed:

  • user/user_main.c: sensor type (DHT11 or DHT22) and poll rate
  • tempd.c: hostname and UDP port to send readings, poll rate for readings, fallback IP (needs to be set in dnsLookupCb), and sleep mode setting (default off)

Building

Make sure the IoT SDK and toolchain are set up according to the instructions on the ESP8266 wiki. The makefile in this project relies on some environment variables that need to be set. It should be enough to add these to your .profile:

PATH="/opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin/:$PATH"
export SDK_BASE="/opt/Espressif/ESP8266_SDK"
export XTENSA_TOOLS_ROOT="/opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin/"
export ESPTOOL="/opt/Espressif/esptool-py/esptool.py"

From the root of this repository, run make. This will build the two firmware images. To update the webserver's HTML files, run make webpages.espfs.

Hardware

The whole circuit runs on 3.3V power, which can be obtained using a cheap AMS1117 3.3V module or regulator circuit.

Pin Connection
VCC and CH_PD +3.3V
GPIO0 DS18B20 DQ pin, pulled to 3.3V through a 4.7k resistor
GPIO2 DHT11 pin 2, pulled to 3.3V through a 10k resistor
GND ground
TX UART adapter RX
RX UART adapter TX
RST N/C [or solder to GPIO16 on the module for sleep mode]

The sensors both need their VCC and GND pins connecting to power and ground respectively.

Sleep mode

The sleep mode requires the RST pin to be tied to GPIO16 to allow the chip to wake itself back up. If this change isn't made (and sleep mode is turned on in tempd.c) then the board will post a single update and then not do anything until manually reset.

You'll need to solder a wire from RST to GPIO16. See Issue #3 for the needed bodge. The pitch on the chip is very small, so use a very thin wire. I used an individual strand from an IDE cable.

This might not apply for newer ESP modules.

Licenses

This code is entirely based on Sprite_tm's httpd implementation for the ESP8266, licensed under the Beer-ware license. See the license headers in the user directory for the full text of the license.

The webserver uses Scott Vokes's heatshrink library. See the LICENSE file in lib/heatshrink for the full text of the license.

The DHT code is based on Martin's DHT22 cgi script. The revised DHT driver itself is based on the implementation from Adafruit Industries. See the comment in dht.c for the full text of the license. Code for the CRC calculation is taken from Maxim AN162.

The ds18b20 driver includes code based on Grant Forest's Energia code and licensed under the GPL. See the file for the full license text.

The temperature logger is licensed under a modified Beer-wrare license. See the header for tempd.c for details.

esp8266-dht's People

Contributors

mathew-hall avatar spritetm avatar

Watchers

Guilherme Gomes Santos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.