An Internet-of-things approach


After a visit to Shenzhen to discuss high performance computing with a major Chinese company, I was also shown how Internet

of Things (IoT) represent a major product line. A later a visit to the local University and a short visit to a IoT lab convinced me that the

IoT approach is the way to go. Taking the IoT approach onboard can relieve me of all cables and most of the isolation challenges. The

central OpenPlotter computer and it's local connections still have to be isolated from the high power 12 V service supply.

The sensors on the other hand need no signal cables and do nor require any isolation from the 12 V supply. A simple 12 to 5V or 3.3V

(7805/7833 regulator) will do the job. Common ground is no problem as it's only for the sensors. The signal from the sensors are then sent

over the WiFi network, either sharing will all other devices on board or on a separate channel and separated as one might use the RPi as a

private access point for all the wirelessly connected sensors. The solution will suddenly become much simpler. All sensors more than a

meter or so away from the central server (The RPi running OpenPlotter) can be wirelessly connected to SignalK. Which will happily display

the values on the web page.

The Raspberry Pi is very common in IoT projects, but it's often overkill for smaller less performance hungry. The smaller systems provides by Orange Pi, Banana Pi and Friendly ARM are ofter more suitable.

Initial testing

Selecting hardware

For IoT there are several a lot of hardware solutions. In the last years a Chinese set of chips/modules names ESP8266 and ESP32 from

Espressif in Shanghai. The ESP8266 is a bit older and simpler than the mode modern ESP32. Both provide WiFi and a range of IO pins and even a

built in Analog to Digital converter. In some way there are a bit like the Arduinos. You can use the same programming environment (IDE - just

as you would for an Arduino Uno of Nano card) and when the sketch is uploaded it's automatically started when power is applied to the

module. Quite simple, you only need to program then once for the single job that should be doing.

For more information about the maker check out

Measuring voltage and current using a ESP-12E module.

At the pages for Voltage and Current the new IoT approach is tested and prototypes are shown.

The page for voltage show how I use the ESP8266 based ESP-12E and the onchip Analog to digital (ADC) converter.

In addition the page about current measurement uses an ADS1115 16 bits ADC to read the output from Hall element current sensors.

First attempt

My first attempt after learning some initial lessons with the ESP8266 was to use the single Analog to Digital Converter (ADC) input to

measure the voltage of the 12V power supply in my office/lab without any connection to the RPi board. Earlier I have gone through exercises

using isolation amplifiers like AD202. This would be far simpler. The connections a trivial, just power through a micro USB, 12V to the +

and - rails on the breadboard, a voltage divider to get the 0-18 Volt range down to 0-3.25 Volt as the chip operates at 3.3 Volt the highest

voltage it can measure is 3.3 Volt. The Signal K accept UDP packets and I wrote a test routing to listen for messages from the ESP. The

simple server code s here, UDP is not TCP to it's important to note the difference :

import socket

# Initiate socket

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# socket.AF_INET is Internet


print("Trying to receive values as SignalK")

server_address = ('', 10002)

sock.bind(server_address) # Bind to localhost

while True:

data, addr = sock.recvfrom(128) # Short messages only

print data, addr

This little code prove useful for testing the ESP8266 until you get everything ready to send it to the SignalK server in Openplotter.

The sketch in IDE for getting the analog data

val=analogRead(A0); // Read the analog input on the ESP2866.



and actually sending it looks like this:

char cmd2[cmd.length()+1]; // Counting from zero, add one.

Udp.beginPacket(host,port); // Connect to to server and prepare for UDP transfer.

strncpy(cmd2,cmd.c_str(),sizeof(cmd2)); // Convert from String to array of characters.

// Serial.println(cmd2); Serial.print(" Message har length: "); Serial.println(sizeof(cmd2));

Udp.write(cmd2); // Send the message to the SignalK server.

Udp.endPacket(); // End the connection.

All the files are available at my gitlab repository.

Next step

The next logical step is to start testing the ESP32 with it's far higher processing power and more IO pins. It has a built in 12 bits

ADC and dedicated pins for SPI and I2C (you can use I2C with 8266 also). Current measurement is a bit tricky as it require differential

inputs and the ADS1115 is ideal for this and is also 16 bits. One wire temperature sensors are also nice to connect locally and send the

signal to OpenPlotter and SignalK. There is essential no limit of the IoT approach. Another usage is to set up tank level monitoring using

the 8266 or the 32. The much greater number of GPIO pins on the 32 makes it a better option for tank level monitoring.