High Precision Analog IO With Digital Pins

Reading the temperature of your environment is pretty easy right? A quick search suggests the utterly ubiquitous DHT11, which speaks a well documented protocol and has libraries for every conceivable microcontroller and platform. Plug that into your Arduino and boom, temperature (and humidity!) readings. But the simple solution doesn’t hit every need, sometimes things need to get more esoteric.

The technique summarized by an image from Microchip Appnote AN685

For years we’ve been watching [Edward]’s heroic efforts to build accessible underwater sensing hardware. When we last heard from him he was working on improving the accuracy of his Arduino’s measurements of the humble NTC thermistor. Now the goal is the same but he has an even more surprising plan, throw the ADC out entirely and sample an analog thermistor using digital IO. It’s actually a pretty simple trick based on an intuitive observation, that microcontrollers are better at measuring time than voltage.¬†

The basic circuit

The circuit has a minimum of four components: a reference resistor, the thermistor, and a small capacitor with discharge resistor. To sense you configure a timer to count, and an edge interrupt to capture the value in the timer when its input toggles. One sensing cycle consists of discharging the cap through the discharge resistor, enabling the timer and interrupt, then charging it through the value to measure. The value captured from the timer will be correlated to how long it took the cap to charge above the logic-high threshold when the interrupt triggers. By comparing the time to charge through the reference against the time to charge through the thermistor you can calculate their relative resistance. And by performing a few calibration cycles at different temperatures ([Edward] suggests at least 10 degrees apart) you can anchor the measurement system to real temperature.

For all the gory details, including tips for how to save every last joule of energy, check out [Edward]’s post and the Microchip appnote AN685 he references. Besides this series [Edward]’s Cave Pearl Project has already yielded an impressive number of Hackday posts. For more great hardware writeups check out a general hardware build for a single sensing node, or the “temperature sensor” [Edward] made with no external parts at all!

An Achievable Underwater Camera

We are surrounded by sensors for all forms of environmental measurement, and a casual browse through an electronics catalogue can see an experimenter tooled up with the whole array for a relatively small outlay. When the environment in question is not the still air of your bench but the turbulence, sand, grit, and mud of a sea floor, that pile of sensors becomes rather useless. [Ellie T] has been addressing this problem as part of the study of hypoxia in marine life, and part of her solution is to create an underwater camera by encasing a Raspberry Pi Zero W and camera in a sturdy enclosure made from PVC pipe. She’s called the project LoBSTAS, which stands for Low-cost Benthic Sensing Trap-Attached System.

The housing is simple enough, the PVC has a transparent acrylic disk mounted in a pipe coupler at one end, with the seal being provided at the other by an expansion plug. A neopixel ring is mounted in the clear end, with the Pi camera mounted in its centre. Meanwhile the Pi itself occupies the body of the unit, with power coming from a USB battery bank. The camera isn’t the only sensor on this build though, and Atlas Scientific oxygen sensor¬† completes the package and is mounted in a hole drilled in the expansion plug and sealed with silicone sealant.

Underwater cameras seem to have featured more in the earlier years of Hackaday’s existence, but that’s not to say matters underwater haven’t been on the agenda. The 2017 Hackaday Prize was carried off by the Open Source Underwater Glider.