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 Epic Tale Of Thermistors: Tricks For Much Better Temperature Sensing

For years [Edward] has been building professional grade underwater sensing nodes at prices approachable for an interested individual without a government grant. An important component of these is temperature, and he has been on a quest to get the highest accuracy temperature readings from whatever parts hit that sweet optimum between cost and complexity. First there were traditional temperature sensor ICs, but after deploying numerous nodes [Edward] was running into the limit of their accuracy. Could he use clever code and circuitry to get better results? The short answer is yes, but the long answer is a many part series of posts starting in 2016 detailing [Edward]’s exploration to get there.

Orange is 12 bits, red is 24

The first step is a thermistor, a conceptually simple device: resistance varies with temperature (seriously, how much more simple can a sensor get?). You can measure them by tapping the center of a voltage divider the same way you’d measure any other resistance, but [Edward] had discarded this idea because the naive approach combined with his Arduino’s 10 bit ADC yielded resolution too poor to be worthwhile for his needs. But by using the right analog reference voltage and adjusting the voltage divider he could get a 20x improvement in resolution, down to 0.05°C in the relevant temperature range. This and more is the subject of the first post.

What comes next? Oversampling. Apparently fueled by a project featured on Hackaday back in 2015 [Edward] embarked on a journey to applying it to his thermistor problem. To quote [Edward] directly, to get “n extra bits of resolution, you need to read the ADC four to the power of n times”. Three bits gives about an order of magnitude better resolution. This effectively lets you resolve signals smaller than a single sample but only if there is some jitter in the signal you’re measuring. Reading the same analog line with no perturbation gives no benefit. The rest of the post deals with the process of artificially perturbing the signal, which turns out to be significantly complex, but the result is roughly 16 bit accuracy from a 10 bit ADC!

What’s the upside? High quality sensor readings from a few passives and a cheap Arduino. If that’s your jam check out this excellent series when designing your next sensing project!

Move Aside Mercury: Measuring Temperature Accurately With An RTD

Temperature is one of the most frequently measured physical quantities, and features prominently in many of our projects, from weather stations to 3D printers. Most commonly we’ll see thermistors, thermocouples, infrared sensors, or a dedicated IC used to measure temperature. It’s even possible to use only an ordinary diode, leading to some interesting techniques.

Often we only need to know the temperature within a degree Celsius or two, and any of these tools are fine. Until fairly recently, when we needed to know the temperature precisely, reliably, and over a wide range we used mercury thermometers. The devices themselves were marvels of instrumentation, but mercury is a hazardous substance, and since 2011 NIST will no longer calibrate mercury thermometers.

A typical Pt100 RTD probe

Luckily, resistance temperature detectors (RTDs) are an excellent alternative. These usually consist of very thin wires of pure platinum, and are identified by their resistance at 0 °C. For example, a Pt100 RTD has a resistance of 100 Ω at 0 °C.

An accuracy of +/- 0.15 °C at 0 °C is typical, but accuracies down to +/- 0.03 °C are available. The functional temperature range is typically quite high, with -70 °C to 200 °C being common, with some specialized probes working well over 900 °C.

It’s not uncommon for the lead wires on these probes to be a meter or more in length, and this can be a significant source of error. To account for this, you will see that RTD probes are sold in two, three, and four wire configurations. Two-wire configurations do not account for lead wire resistance, three-wire probes account for lead resistance but assume all lead wires have the same resistance, and four-wire configurations are most effective at eliminating this error.

In this article we’ll be using a 3-wire probe as it’s a good balance between cost, space, and accuracy. I found this detailed treatment of the differences between probe types useful in making this decision.

Continue reading “Move Aside Mercury: Measuring Temperature Accurately With An RTD”

Hackaday Prize Entry: Ebers – Diabetes Care, Step By Step

Diabetes is a disease that, among other things, has significant effects on the feet due to a combination of neuropathy, vascular issues, and other factors. You may have seen special diabetes socks with features like non-elasticated cuffs for better circulation and a lack of seams to prevent the formation of blisters. Taking care of  your feet is essential in diabetes to prevent injury and infection. Ebers is a project that seeks to help in just this area.

Ebers monitors plantar pressure, temperature, and humidity in the sole of the shoe. It then feeds this data back to a smartphone for analysis over Bluetooth. The brain of the project is an Arduino Pro Mini which is tasked with interfacing with the various sensors.

The project relies on 3D printed insoles which fit inside the shoe of the wearer. This is a particularly useful application of 3D printing, as it means the insole can be customised to fit the individual, rather than relying on a smaller selection of pre-sized forms. This has the additional benefit of allowing the insole to be designed to minimise pressure on the foot in the first place, further reducing the likelihood of injury and infection. The pressure sensing is actually built into the insole itself, and can measure pressure at several different areas of the foot.

Overall, it’s a project with huge potential health benefits for those with diabetes. We look forward to seeing where this project goes in future, and how it can bring improvements to the quality of life for people the world over.

Low-cost Drift Buoy Plies The Atlantic For Nearly A Year

Put a message in a bottle and toss it in the ocean, and if you’re very lucky, years later you might get a response. Drop a floating Arduino-fied buoy into the ocean and if you’ve engineered it well, it may send data back to you for even longer.

At least that’s what [Wayne] has learned since his MDBuoyProject went live with the launching of a DIY drift buoy last year. The BOM for the buoy reads like a page from the Adafruit website: Arduino Trinket, an RTC, GPS module, Iridium satellite modem, sensors, and a solar panel. Everything lives in a clear plastic dry box along with a can of desiccant and a LiPo battery.

The solar panel has a view through the case lid, and the buoy is kept upright by a long PVC boom on the bottom of the case. Two versions have been built and launched so far; alas, the Pacific buoy was lost shortly after it was launched. But the Atlantic buoy picked up the Gulf Stream and has been drifting slowly toward Europe since last summer, sending back telemetry. A future version aims to incorporate an Automatic Identification System (AIS) receiver, presumably to report the signals of AIS transponders on nearby ships as they pass.

We like the attention to detail as well as the low cost of this build. It’s a project that’s well within reach of a STEM program, akin to the many high-altitude DIY balloon projects we’ve featured before.

Continue reading “Low-cost Drift Buoy Plies The Atlantic For Nearly A Year”

Hackaday Prize Entry: SunLeaf

If there’s one place where the Internet of Things makes sense, it’s agriculture. From vast fields of soybeans, corn, and a different variety of corn, to the backyard garden, knowing how much sun, and rain crops get can vastly increase yields. For their Hackaday Prize project, [Adam] and [Shane] are building  a board designed explicitly for plants. It’s called the SunLeaf, and it has all the sensors and radios a good remote sensing board needs.

The SunLeaf is built around an ARM Cortex M4 microcontroller with an ESP8266 module for WiFi connectivity. Sensors are important for any remote sensing board, and for this the guys are going with SeeedStudio Grove connectors, providing four UARTs, four I2C, and four analog ports.For remote sensing applications, you generally can’t rely on mains power, so SunLeaf includes a port for a solar panel and a battery charger.

Although this project was originally a redesign of [Adam] and [Shane]’s Hackaday Prize entry from last year, what they’ve come up with is a great device for data logging, autonomous control, and environmental sensing for anything, from farms to weather stations.

The HackadayPrize2016 is Sponsored by:

Simple Robot Knows Its Bounds

table_top_bot

The [Dallas Personal Robotics Group] recently put together a set of tutorials for their members, including the build process of a table-top robot, they call the Tiny Wanderer. The bot can be constructed pretty easily, and is meant as an introduction to robot building.

The small servo-driven bot uses simple edge sensors to ensure that it doesn’t fall off a raised surface. The sensors were built using a small IR LED and photo transistor, which is partially isolated from the LED by a piece of shrink tubing. An ATiny micro-controller takes two measurements of the amount of IR light entering the photo transistor – one with the LED on, the other with the LED off. The difference of these measurements is compared to determine if the edge sensors are hanging off the side of the table. The logic used here is pretty simple – the difference will be high if the sensors are hovering over a surface, due to reflected light, and low if the sensors are hanging over open space.

The writeup contains templates for building the bot’s structure, as well as source code and schematics for all of the electronic bits.

Be sure to stick around to see a video of the robot in action.

Continue reading “Simple Robot Knows Its Bounds”