Spotted Gecko Habitat Temperature Monitor/Thermostat W/Arduino & ESP8266 ESP12


Soooo….Wifey decided that it was time for a new pet. Spin the wheel….A Spotted Gecko!! Well, Geckos are apparently very temperature sensitive creatures so we invested in a UTH (Under Tank Heatpad) for those of us that are new to the world of reptiles. The purpose of said UTH is to provide warmth from below, to about 1/3rd of his enclosure…in this case a 10 gallon aquarium for the time being. The geckos like their bellies warm when they sleep from what I understand. This UTH only has ON/OFF and no temperature regulation. The thought of needing to check it every hour 24X7 and turning it on or off depending on his comfort wasn’t gonna happen (nothing personal Mr. Gecko but ‘been there done that’ with my own human babies 20 years ago, please no more)…sooooo…ENTER ARDUINO and ESP8266 (and a few other goodies)! Automation of the temperature monitoring and regulating, and hosting a web page to display the current temperature statuses to any internet browser. Mr. Leonardo Gecko is happy…as am I!

Step 1: What’s NeededSubstitute

Substitute as needed for your individual requirements/parameters. Links to products are only for examples and not promotion. I did not use a resistor for the DS18B20. Please use your own judgement.

1. ESP8266 ESP12 NodeMCU SOC

2. Relay

3. DS18B20 Temperature Sensor

4. HeatPad (UTH)

5. NodeMCU Base

Jumpers, USB Micro Cable

Step 2: Software Setup – Initial (Assuming Arduino IDE Is Already Installed)Software Setup Initial Assuming Arduino IDE

We will also assume that you are familiar/comfortable with utilizing Arduino libraries.

All libraries should be available via github for free, if not already installed in your IDE.

You’ll be needing the following libraries/etc:

Step 3: Hardware SetupHardware Setup 1

For this section, the steps explained are based on my setup. Adjust as needed. DS18B20=sensor

  • Install NodeMCU board onto Node Base. (confirm the correct orientation by antenna locations matching on each or pin numbers matching if listed on base)
  • Install female terminator connections on sensor(s). (I snipped, stripped, soldered and wrapped jumpers to the DS1820B’s lines)
  • Attach Posi of both sensors to same 3.3v rail on Node Base. (Assuming 2 sensors are present. If only one, then connect just the one) See Pic.
  • Attach Neg of both sensors to same ground rail on Node Base. (Assuming 2 sensors are present. If only one, then connect just the one) See Pic.
  • Attach Data of both sensors to same pin D3 rail on Node Base. (Assuming 2 sensors are present. If only one, then connect just the one) See Pic.
  • Identify the DS18B20(s) unique device address:
    1. Temporarily disconnect one of the sensors from the NodeMCU.
      • Follow the steps provided here:DS18B20 Device Address Finder It looks like a lot of steps but really is rather quick and painless…and DEFINITELY necessary.
      • Mark the current sensor in some manner (piece of tape, etc) for later identification to match to address.
    2. Power off your Node and repeat step 1 with additional sensor(s) is needed.
    3. Reconnect all sensors as described in initial steps above.

Step 4: Time to Check Some TEMPS!Time to Check Some TEMPS

  • Assumptions/Pre-Req’s:
    1. You have obtained and installed all necessary libraries from the Software Setup step of this Instructable.
    2. You have obtained the unique device addresses(s) of the sensors from the Hardware Setup step.
  • Make/Confirm all connections and power up your Node.
  • Load the attached NODE_DS18B20_Gecko_WEB_SHARE_12Aug17.ino I have called out via OBNOXIOUS comments in the source…all of the fields that need changing.
    1. Modify the code with your unique specific details for the following at the least:
      • Your Network SSID and SSID Password
      • DS18B20 device address(s) obtained in previous step.
      • TCP Port (default is 80, the code is set to 6969 at this time)
    2. COMPILE! (I usually start praying at this point for no errors).
    3. Load it to your Node.
    4. Open Serial monitor. With any luck you are seeing data here, hopefully with temperatures. Force a Temp. change on the sensor probe to see if it is in fact fluctuating.
      • Take note of the field names being displayed and personalize the source accordingly.
    5. Open a web browser to http://123.456.789.123:2017 (This was an example)
      • EG – Mine loads with
      • Take note of the field names being displayed and personalize the source accordingly.


See what I did there? Relay…Electricity…SHOCKING. OK…nevermind! Haaaaaaa


When I work with relays, I mod an extension cord instead of risking harm to the wires of the ‘device to be controlled’.

For detailed steps on that process, head here first. (Added “how-to bonus” included in video) How to safely mod extension cord to attach to relay.

  • Depending on your project requirements, the power connection has 2 options on the relay, ‘Normal Open’ or ‘Normal Closed’. Consider your implementation for how to wire. “Will this only be turned on occasionally?” “Will it be on a lot?” “When do I want it to turn on or off?” etc…
  • Modify your source code (IF statements in LOOP) with some high/low temperature thresholds.You may also need to change the logic depending on the relay wiring and your decisions. (Flipflopping the pin’s HIGH and LOW setting). Trial and Error…Experiment…that is half the fun in learning here. (Without hurting yourself or anyone/anything in the process of course)
  • Modify the Relay Data pin assignment in source to match the physical connection. Mine is D8.
  • Connect everything up and take your project for a spin!!
    1. Relay Posi to Node 5v.
    2. Relay Neg to Node Ground
    3. Relay Data to Node D8. (Or your data pin)

Read more: Spotted Gecko Habitat Temperature Monitor/Thermostat W/Arduino & ESP8266 ESP12

Leave a Comment

Your email address will not be published. Required fields are marked *