DIY Sensors with Signal K Part 2 – The Hardware

(This post was originally published on the Signal K Blog site in August 2019. http://signalk.org/2019/08/20/sensors-part-2.html It was written as part of a 3-article series. I decided to post all three of them on the Smartini Life blog. If you’re not a bit of a nerd, this may not be your cup of tea.)

In a previous blog post, I wrote in general terms about using small, inexpensive microcontrollers to gather all kinds of data around your boat and make it available on your boat’s network through Signal K. In this post, I’m going to describe, in detail, the device I built and deployed on my boat to gather and report four temperatures from my main engine. I hope it’s detailed enough so that you could duplicate the project yourself. Don’t be intimidated by the idea of doing this yourself – this was only my second ever real microcontroller project – it’s not complicated.

In this post, I’ll detail the hardware aspect of the device, and will address the software details in the next post.

The Project
Build a device that monitors four temperatures on your boat and reports them to your Signal K server, so that you can see them on any device that can run a browser, and that has access your boat’s network (via wifi or ethernet). It will consist of a microcontroller, four temperature sensors, a power supply for the microcontroller, and a resistor or two. You can build it on a breadboard, but if you want to deploy it on your boat, you’ll have to do a little soldering. If you have a 3D printer, you could make a really cool enclosure for it, but I don’t have one, so that’s not part of my project.

The Microcontroller
The Arduino (including all its variants – Uno, Due, Mega, etc.) is the most well-known hobbyist microcontroller, but we won’t be using an Arduino. We will be using a microcontroller called the Wemos D1 Mini, which is used like an Arduino, but which has two processors, 4 megabytes of RAM, and built-in wifi capabilities. It’s based on the ESP8266 processor. For simplicity, I will refer to “the Wemos” in this post – when you read that, you can think “Arduino” if you like, or the more generic “microcontroller”. Basically, a tiny computer that can read data from all kinds of sensors, process that data, and then send that to your boat’s Signal K server. However, to complete this particular project, you should probably use the Wemos D1 Mini (NOT the D1 Mini LITE!), to make sure it’s compatible with the software. Other ESP8266-based microcontrollers should work, but if you’re going to buy one, be safe and buy the Wemos.

Wemos D1 Mini
Wemos D1 Mini – a tiny computer with built-in wifi capability

The Sensors
The DS18B20 is one of many temperature sensors that use the 1-Wire method of communicating with the microcontroller. I chose them for my project because I found some that come with the sensor enclosed in a small, waterproof, stainless steel tube at the end of a long cable, allowing me to reach all parts of my main engine. But you can use any 1-Wire sensor you choose, based on what temperatures you want to monitor on your boat.

DS18B20
The DS18B20 digital temperature sensor, which is tiny, is housed in the tip of the metal “probe”, and the whole assembly is waterproof. Perfect for use on a boat!

The Power Supply
While there are a lot of ways to power a microcontroller project (battery, “wall wart”, etc.), I decided I would tap into all the 12V wiring running all over the boat. I have now done this (converted 12V boat power to a clean 5V for the microcontroller) two different ways on two different projects, and I just purchased a “DC power shield” for the Wemos that I think I’m going to use from this point forward. In the details, I’ll show you all three.

The Prototyping Board
After only a few projects, I have settled on the prototyping board called “stripboard.” (Also known as Veroboard.) I find it easy to design with, and easy to actually assemble projects on that will be able to be deployed permanently. But there’s nothing magic about it – by all means, use whatever works for you. (If you want to buy stripboard, be sure that’s what you’re getting. It’s NOT the same as other prototyping board that doesn’t have all the holes in a single row connected to each other. See the video link at the end of this post.)

Stripboard

The Design Tool
I’ve scratched out plenty of project ideas with a pencil and paper, but when it comes to designing something that you’re going to actually build, I suggest you use some software created for that purpose. The only one I have experience with is called Fritzing. It’s not perfect, and I’m not sure it’s even being developed anymore, but it’s free, and it’s worked well for me to create schematics when necessary, and it works really well to design the physical layout of your project. I’ve included some screenshots from my Fritzing project to illustrate the project, and I think you’ll see why I like it.

Fritzing schematic example

How Do You Learn This Stuff?
In a word, Google. In a few more words, forums and datasheets. I’ve spent countless hours searching for, and reading about, the projects of other people who have used the microcontrollers, and libraries, and sensors, and every other component I’m interested in. I typically start looking for a tutorial, and can usually find something, although some are much better than others. I’ve also joined at least five different forums so I can post questions there. At the end of this post, I’ll list some of them. But if you’re going to sign up for any one thing, make it signalk-dev.slack.com.

The Details
Let’s start with the Fritzing view of the whole project, in the image below. At the top, you see a voltage regulator with a couple of capacitors, providing 5V to the Wemos. On the bottom (see the close-up image), you see the four temperature sensors, with all of their like wires (3.3v power, ground, and data – red, black, and yellow wires) on the same strip of the stripboard, so that they all go to the same pin on the Wemos. The 1-Wire specification calls for a 4.7K ohm resistor between the data line and 3.3V, which you can see. The wires from the sensors attach to the project with screw termininals that are soldered to the stripboard. The Wemos attaches to the stripboard by plugging into two headers, which you can’t see in this 2-D view of the project. You could solder it directly to the stripboard, but I much prefer to solder headers to the stripboard, solder pins to the Wemos, and plug the Wemos into the headers. (See the photo below.)

Fritzing view of project
Fritzing close up
Wemos inserted into headere
The Wemos with pins soldered on, partially inserted into the headers.
Solder side of stripboard
All the soldering happens on the bottom of the stripboard, opposite the side with all the components.

The voltage regulator in this image is a very basic LM7805 fixed voltage regulator. If you look at the datasheet (ALWAYS look at the datasheet!), you’ll see that it can take up to 35VDC input, and output a constant 5VDC, which is perfect for the Wemos. I tapped into the wires providing 12V and GND to one of my bilge pumps to provide the input into the voltage regulator. Also in the datasheet, you’ll see that it recommends a couple of capacitors, so I put them in. The Wemos’s onboard voltage regulator probably makes the capacitors unnecessary, but I put them in anyway. (See image below, from datasheet.)

LM7805 with caps

I used the LM7805 in my very first boat project, and it’s been working fine with an Arduino Nano for well over a year. But in my second project (the one I’m writing about here), I went with an adjustable “buck converter” type voltage regulator. They’re a little more expensive than the LM7805 (still only about a dollar each), but they don’t heat up like the LM7805. There are a lot of these on the market – search on Amazon or wherever you like to buy electronic parts. Even though the Wemos’s power input pin is labeled “5V”, everything in my project (including the Wemos) operates at 3.3V, so I dialed the voltage down to 3.3, and input that into the “5V” pin. (First picture below.) Like the Wemos, I used pins soldered to the regulator and a header soldered to the stripboard, rather than soldering the regulator to the stripboard. (Second picture below.)

Regulator
Voltage regulator side view

Since I built this project, someone in the Signal K workspace on Slack suggested an even nicer voltage regulator, and I’ve purchased some for my next project. I like them for two reasons: they’re in the form of a “shield” designed for the Wemos, so they plug right into a header that you solder to the top of the Wemos. (See picture below.) Secondly, they have two different methods for connecting power right on the PCB – a barrel connector for a wall wart to plug into, and two screw terminals (which I will use), for a POS and GND wire to connect to. It takes 7 – 24VDC and passes a clean 5V right into the Wemos through the “5V” and “GND” pins. This saves me from having to solder screw terminals onto my project, but almost as important, it gives me a way to power the project while I’m still testing it (through the wall wart connector).

Wemos DC power shield

The connection of the 1-Wire sensors’ wires, and the 4.7K ohms resistor, is easier described with a picture than with words, so here you go. It looks a LOT like the Fritzing design, above, which is one of the things I really like about Fritzing.

ME temp device installed

The Installation
As described earlier, I’m using this to monitor four temperatures on the main engine in my boat: the case of the 12V alternator, the case of the 24V alternator, the coolant thermostat housing, and the elbow where the raw water is injected into the exhaust. In each case, I’ve used zip-ties or stainless safety wire to attach the sensor to the item being sensed (see image below), and I know that this doesn’t give me exact temperatures. For example, if I wanted to get the exact temperature of the inside of the elbow where the raw water injects into the exhaust, I would have to drill a hole into the elbow and somehow insert the sensor into the coolant itself. For my puposes, zip-tying the sensor to the elbow provides me with readings that are CONSISTENT, and by using an infrared thermometer, I can easily determine the difference between the sensor’s reading and the actual temperature. In my case, when the engine is fully warmed up, the temperature at the elbow is about 102 degrees Fahrenheit. The sensor outputs 96 degrees, because it’s strapped to the outside of the elbow, and only a small part of it touches the elbow – the rest isn’t touching anything other than the air. In the software, I simply add 6 degrees to the sensor output so that the displayed temperature is what I expect. Besides – as with so many things we monitor on engines, it’s not the actual reading that we care about, it’s knowing what’s normal, and then monitoring to make sure the reading stays in the normal range. I also like having the displayed temperature of each thing be the same as the temperature I measure with my infrared thermometer, simply for consistency.

12V alternator case sensor
24V alternator case sensor
Thermostat housing sensor
Temp sensor on raw water elbow

I found a location for the device that all of the DS18B20 cables can reach, and that doesn’t vibrate much while the engine is running, and that’s not especially hot. (The ambient temperature in my engine room at cruise is about 110 F, which is well under the maximum environmental temperature for the Wemos.) It’s on the mounting base of my generator, only a foot away from the main engine. Then I simply drilled a hole in the stripboard and screwed it to the mounting location. I added an on-off switch to the 12V line that provides power to the device so that I can turn it off when the boat isn’t running. (See picture below.)

Device installation

That’s about it for the hardware part of the project. In the next post, I’ll describe the software that the Wemos runs to read the sensors and send their output to my Signal K server.

Helpful Links

  1. Link for each product mentioned.
    Wemos D1 Mini product page: https://wiki.wemos.cc/products:d1:d1_mini
    DS18B20 sensors on Amazon: https://smile.amazon.com/gp/product/B07CPTCZ65/
    1-Wire wikipedia page: https://en.wikipedia.org/wiki/1-Wire
    Long, detailed video of using stripboard: https://www.youtube.com/watch?v=DSk5DQhi1r0
    Video of using Fritzing to design a stripboard circuit: https://www.youtube.com/watch?v=MoDhyi4eNYo
    7805 fixed 5V voltage regulator, on Amazon: https://smile.amazon.com/Voltage-Regulator-Linear-L7805CV-Positive/dp/B07H9M9SFM/
    Adjustable buck converter I used, on Amazon: https://smile.amazon.com/gp/product/B0758ZTS61/
    Wemos DC power shield product page: https://wiki.wemos.cc/products:d1_mini_shields:dc_power_shield
    Fritzing home page: https://fritzing.org/home/
  2. Link for each forum I’ve joined and gotten good answers from. (You dont have to join most forums unless you want to post. Often, reading existing posts is all you need.)
    Signal K Development on Slack – this is a must! http://slack-invite.signalk.org/
    Arduino Forum: https://forum.arduino.cc/
    All About Circuits – excellent for project design questions: https://forum.allaboutcircuits.com/

One thought on “DIY Sensors with Signal K Part 2 – The Hardware”

Leave a Reply