offgridtech.xyz

A Blog about IT, Security, Cloud and Off-Grid Technologies.

Off-Grid IoT Part 1: Setting Up an IoT Server

Introduction

Well, I didn’t name this blog “Off-Grid Tech” for nothing. Although this platform serves as a professional portfolio highlighting my experiences in Cyber Security and Cloud Technologies, I also have a unique personal interest with lots of crossovers. My current off-grid living situation provides an outdoor-oriented and adventurous lifestyle, but it’s not without its quirks and deficiencies. My love for technology and learning new things inspires me to find smart solutions wherever I can.

Project Overview

IoT stands at the forefront of enabling smart, efficient environments. For my off-grid home, after careful consideration, I decided to choose IoTStack as the framework to power my server. IoTStack is a Docker-compose builder that easily creates and maintains IoT server stacks for Raspberry Pi, serving as an excellent introduction to IoT connectivity before committing to cloud efforts. Each component in the stack plays a vital role in collecting, managing, and visualizing data for smart decision-making.

Setting Up the Server

You can download my complete user-guide for this set up here.

Thanks to IoTStack, setting up my IoT server was simplified. Its Docker-compose environment allowed for seamless deployment and operation of the services I needed. The deliberate choice of Mosquitto, InfluxDB, NodeRed, Grafana, and Portainer catered to every need from data collection to visualization and management.

  • Mosquitto (MQTT Broker): All of my IoT devices need a destination for their data. As the sensors collect data, they send out information in messages neatly packed in JSON format. The MQTT Broker (Message Queuing Telemetry Transport) queues these messages for entities like databases to subscribe and collect them. The MQTT protocol is specifically designed for connections with resource and bandwidth-constrained devices, like your average IoT sensor.
  • InfluxDB for IoT: InfluxDB is a database designed specifically to handle time-series data, such as data collected over time, much like the data queued by the MQTT broker from my sensors. The database subscribes to a topic (or directory) where the MQTT broker queues all the collected messages.
    • Example of message: {“temperature”: msg.payload.t, “humidity”: msg.payload.h}
  • Node-RED: Node-RED is a programming tool for linking together devices, online services, and APIs (Application Programming Interfaces) with a visual interface. It allowed me to select from a list of services, drag and drop, connect them, and then customize configurations all using a convenient user interface where I can visualize the data flow on
  • Grafana: Grafana is a tool for visualizing data. It connects to various data sources, including InfluxDB, to create dashboards filled with charts and graphs that make it easier to see trends and patterns in the data.
  • Portainer: Portainer is a management tool for Docker and Kubernetes, which are platforms used to deploy and manage containers. Although I still found myself accessing my containers via the CLI, it was neat to play around with the software.

Configuration and Integration

The crux of the project lay in the technical orchestration of these components. MQTT serves as the backbone for communication, with Mosquitto facilitating this protocol. Data formatting with JSON ensures that information is standardized and easily interpretable by different components. NodeRed bridges the gap between data collection and action, enabling automated workflows based on the data ingested from various sensors.

Building a Temperature Sensor

As part of my dedication to building a smart off-grid paradise, I have been learning how to program Arduino and ESP32 microcontrollers. I have built and configured many devices, but most recently, I built a temperature and humidity sensor using the DHT11 sensor and SSD1306 OLED screen. This sensor utilizes libraries such as ArduinoJson for data formatting and the PubSubClient for MQTT communication. This practical application underscored the importance of establishing a reliable data pipeline to the MQTT broker, utilizing JSON-formatted data, and accurately configuring topics for efficient data transmission.

You can view the code for my sensor here: https://github.com/theo314/Arduino/blob/main/TempSensorESP32withOLED.ino

Conclusion and Takeaways

This project not only advanced my understanding of IoT networks and security but also moved me closer to achieving a smart, sustainable off-grid living environment. For anyone embarking on similar IoT projects, the journey is both challenging and rewarding, offering invaluable insights into the power of connected technologies.

References:

  • https://sensorsiot.github.io/IOTstack/
  • https://nodered.org/docs/user-guide/
  • https://docs.influxdata.com/influxdb/v2/get-started/
  • https://www.raspberrypi.com/documentation/computers/getting-started.html

Leave a Reply

Your email address will not be published. Required fields are marked *