Two temperature sensors

Well depth sensing: it begins

I’ve begun another Arduino/ESP8266 project: reporting the level of water in our well tank. This project will involve the ESP8266, MAX31820 temperature sensors, some mechanical work, sending data to a web-based database, and interpreting the temperature data to estimate the well water level.

Our house uses well water because the nearest city water pipe is about 5 miles away. Once every few years, usually early in the summer, we have the nasty surprise of running our well dry.  It’s usually because the garden irrigation is using too much water, but sometimes it’s random things like power washing the deck or breaking a pipe. With the right technology, we could get an early warning that the well tank water level is dropping quickly.

There are nice solutions to this problem – assuming you don’t mind drilling into your water pipes or sinking circuitry into your well tank. I wanted a solution that was less invasive.

So I’ve started a new project, the details of which are on my github repository.

I began by soldering headers onto a Sparkfun ESP8266 Thing Dev board.

An easy way to solder headers onto a board
An easy way to solder headers onto a board

A while ago I found a neat trick to keep the headers straight: clamp the board (lightly!) to a table. This clamping holds the headers tightly against the board, so they don’t move when you solder them down.

Next I wired up two MAX31820 chips  in a 1-Wire bus (really 3 wires) and tried to read them from the ESP8266… no luck.

After a lot of debugging I found the problem was the I/O pin I was trying to use as the 1-Wire data pin: The OneWire library I’m using has a bug that prevents ESP8266 pin 16 from working. Once I found out about that (I love github Issue notes), I switched to Pin 4 and Voila!

Here are a few things I’ve learned so far:

  1. I’ve had good luck so far with Paul Stoffregen’s OneWire library. This seems to be the most up-to-date version and works with many Arduino-compatible boards.
  2. I’ve had equally good luck with Miles Burton’s Dallas Temperature library.  I found a lot of broken links to earlier versions of it, but finally found it at the URL above.
  3. If you can, avoid the following pins on ESP8266 chips:  GPIO0 is connected to a 10K ohm pull-up resistor. GPIO2 is connected to a 10K ohm pull-up resistor. GPIO5 is (on the Sparkfun board) connected to an on-board LED ohm and 220 ohm resistor to Vcc. GPIO15 is connected to a 10K pull-down resistor. GPIO16 requires special treatment in the low-level I/O code and so is often incorrectly supported by libraries (such as OneWire) that perform low-level pin I/O instead of using digitalWrite() and digitalRead().

There is much left to do. The current code barely reads the 1-Wire address of the first temperature sensor. In my next post, I measure the height of the well tank, and report on the hardware and software progress.