Temperature monitoring and alarming

Temperature sensors can ble placed on vital parts. The engine is obvious, cooling water, exhaust manifold, engine block, alternator etc. With almost costless sensors any part where it would be nice to know the temperature can be monitored. Charger, fridge, fridge's compressor, SSB radio power stage etc. The list can be long. The temperature sensors of the DS18B20 (DS18B20 datasheet) type are extremely easy to connect (One wire). All the output can be connected together just like a bus and every sensor has it's own address. Only 3 wires connect to the module (Pi or ESP board).

Internet of Things on Board (IoToB) solution

The temperature sensor client will transmit the temperature data over wifi and using the SignalK protocol to the OpenPlotter SignalK server. The box has connections for 3 One-wire temperature sensors, on the opposite side of the box is room for 3 more if ever that would be needed, room inside is set aside for expansion. The picture below show how it's currently put together. Currently engine block, alternator metal body and engine room is monitored (have considered switching to transmission). It's a sail yacht, but still the engine is often run for some hours. The alternator is the most critical component, with Li batteries and an external controller it's possible to fry the alternator. It's made for cars and no really designed to run at full amp for hours.

The sensor client is based on a ESP8266 / ESP12E, a simple little module that does this task nicely. For more information see Wikipedia on ESP8266 and the ESP12E module.

The picture on the left show the finished box with a 12V power input at the short side and 3 x three pin connections for the DS18B20 sensors. Initially interference caused the 1-wire to fail after some time (a few minutes) and just report the standard error code -127. Replacing the pullup resistor with a 2.2k as opposed to 4.7k before and introducing a single 100 ohm resistor in series with each signal lines (hidden under the yellow crimp-on-plastic) on the connectors.

Using connectors for all connections make it a simple matter to bring the box home for maintenance or reprogramming. The system is using a ND buck converter making 5+ from 12V with full isolation, to be sure that ground og sensors ground ar not in any way connected to the ground of the electrical systems on board. Having an aluminium boat stray current can be problematic.

Unfortunately I chose a 1W converter which can only supply 200mA, which is a but on the low side for initiation of the wifi connection. It does manage to start after some time, but a 2-3 W converter would be a better option. Adding an electrolytic condenser of 100 uF solved this problem as the peak current is only transient. It now works fine with the 1W power converter. I also connected power directly to the pins Vin and GND and eliminated the bulky micro USB plug (still present on the picture).

The systems works very well, until the engine is started, the power surge by the electric starter motor is enough to make the ESP8266 board and sensors to go bananas. The only thing that will reset it is a power cycle. It's a simple flip of a switch on the power distribution panel, but far from how things should be. I'll try to add a couple of capacitors on the 12V supply side. A ferrit choke is already installed on the power line.

The software to set this up is available at github. The names of the individual sensors are found inside this file, so any changes require the Arduino IDE to be called up and the module connected through USB. There are other project to set this up over a we page, bit so far I have kept using my own scripts with one per unit. A piece of core to restart the 1-wire connection in the event of a failure in reading is also now present.

Once connected to OpenPlotter data can be displayed on a SignalK web page application and maybe more important the values can be fed into OpenPlotter's action service. Thresholds for alarms can be set and different actions can be triggered, ranging from sounding alarms to setting IO pins that in turn can switch relays on or off.


In order to achieve electrical isolation and avoid drawing signal cables around the boat a wifi based IoToB solution is very close to an optimal solution. It's a stand alone server that feed the Signal K server running on the Raspberry/OpenPlotter. OpenPlotter receive the SignalK message strings and convert it to the web page display we all know so well.

The picture to the right show a prototype with an ESP8266 based ESP-12E module with two DS18B20 sensors connected. The one-wire bus is a very simple and easy to use connection and the processing complexity of well served with the simpler ESP8266 chip. This setup can handle up to several tens of temperature sensors, the software normally set a limit. The Arduino IDE sketch is available at github. It's only set up to use two sensors, but this is easy to expand, just figure out sensible names as labels for SignalK to display, but make sure the names follow the guidelines in the SignalK documentation.

The picture show the simplicity of the ESP8266 and one-wire combined, a simple module doing all conversion and connecting to wifi and sending data to OpenPlotter and SignalK. All at a cost of less than 10 Euro all together.

Raspberry Pi connection, directly to OpenPlotter

Connection is very simple, connect 3.3V to the red, GND to the black and connect the yellow signal cable to pin 4 GPIO CLK0, see Adafruit wiring.

Software to read the temperatures are very simple (pin 4 is default in the software), there are some initial installation, see instructions at Adafruit.

import os

import glob

import time

os.system('modprobe w1-gpio')

os.system('modprobe w1-therm')



base_dir = '/sys/bus/w1/devices/'

for j in 1,2:


device_folder[j] = glob.glob(base_dir + '28*')[j-1]

print("device_folder", device_folder[j])

device_file[j] = device_folder[j] + '/w1_slave'

def read_temp_raw(j):

f = open(device_file[j], 'r')

lines = f.readlines()


return lines

def read_temp(j):

lines = read_temp_raw(j)

while lines[0].strip()[-3:] != 'YES':


lines = read_temp_raw(j)

equals_pos = lines[1].find('t=')

if equals_pos != -1:

temp_string = lines[1][equals_pos+2:]

temp_c = float(temp_string) / 1000.0

return temp_c


while True:



print("Temperatur 1 :", temp[1]," C temp 2",temp[2]," C")