ESP32 IoT Foundation

In this hands-on tutorial with code you can download and run, we guide you through creating an On-Premises IoT solution. By the end of this guide, you'll not only have a functional IoT server set up locally but also learn how to transition it to an online server.

Components Used:

  • IoT Server: Mako Server, which you can run on Windows, Linux, or embedded Linux, including RPI.
  • IoT Edge Node: An ESP32 and the Xedge32 development environment.
  • IoT Protocol: SMQ - a messaging protocol designed specifically for device management.


We will act as IoT consultants and design the complete solution based on the following fictitious requirements:

Pilot Project Requirements


Implement a simple use case scenario that demonstrates key functionality used in our final solution. This will allow us to experience the reliability and performance of the framework to give us the confidence to move to the full implementation. The idea is to make it as simple and quick to develop as possible. Console trace messaging is acceptable for user feedback.

Method Details



  1. ESP32 Data collection - Using an ESP32 running XEdge32 with a button switch, send button events to a host Mako server (win32) using SMQ. The Mako server shall record these events to an SQLite database table and acknowledge the result of the database write to the initiating ESP32 device.

Event data to include the esp32 RTC timestamp and if it is rising edge (value 1) or falling edge (value 2). The esp32 time does not need to be synchronized.

  1. ESP32 Framework heartbeat - On the ESP32 implement a flashing led to use as a visual heartbeat indicator. This should be implemented in LUA code (not PWM) to demonstrate the responsiveness consistency of the LUA framework under various load conditions.

The frequency should be adjustable (just in a code file variable) from 1 to 10Hz.

  1. Mako data recording and display - On the Mako server, implement a webpage that displays the contents of the SQLite event table. The page should show all records and all columns. No paging is required. Two buttons to be added to the page.
  • Refresh - reloads the data from the sqlite table
  • Delete All - deletes all data from the sqlite table.

Mako server sqlite database to contain the following columns.

    1. id INTEGER - Primary Key, autoincrement
    2. insert_ts INTEGER - insert timestamp (mako server time)
    3. record_ts INTEGER - event timestamp sent in the SMQ packet from the esp32.
    4. button_edge INTEGER - rising (1) or falling (2) indicator

The following video shows how the On-Premises solution must work:

How to use ChatGPT to Generate the Code Scaffolding

We used ChatGPT for our project's initial code. While the output, especially for SMQ, required corrections, ChatGPT was instrumental in simplifying the early design stages. It provided a base that we later refined. The complete ChatGPT conversation detailing the development of our IoT solution is available in an MHTML file included in the download. This file can be viewed in any standard web browser. The discussion in this file details the inner workings of the On-Premisses IoT solution.

Download the On-Premisses IoT Solution

Get the full experience of our On-Premises IoT Solution foundation by downloading the demo. The entire package is available as a zip file for your convenience.

Download the zip file, extract its contents, and begin by reading the demo/README.txt for guidance on how to proceed.

Next tutorial:

To learn more about building robust IoT solutions with ESP32, check out our comprehensive list of embedded web server tutorials.

Transitioning from On-Premises to an Online Server

Migrating your solution to an online server is straightforward. For detailed guidance, refer to the Mako Server tutorial titled How To Set Up an Environmentally Friendly IoT Solution, which outlines all the necessary steps.

Once you have installed the solution, ideally using the provided ready-to-use script, navigate to the online server's included Xedge IDE for the Mako Server. Within the IDE, you'll need to remove the existing solution. Then, replace it with the server code from this example to complete the transition.

Online Server Use Case: Graviti Technologies

Graviti Energy sought a cutting-edge IoT solution to power cycle their car charger stations remotely, and they turned to us for our expertise. We took the challenge by developing a robust IoT solution, leveraging our SMQ IoT protocol, and meeting their unique requirements.

IoT solution

Ready for a Professional Touch?

Our extensive collection of embedded web server and IoT tutorials is tailored to guide you every step of the way. Whether you're just starting out or looking to hone your skills, our resources are at your fingertips.

However, we understand that time is of the essence. Our consulting services are here to assist if you are stretched thin or seeking expert guidance. Let our seasoned professionals manage the complexities of networking, security, and device management for you.


OPC-UA Client & Server

An easy to use OPC UA stack that enables bridging of OPC-UA enabled industrial products with cloud services, IT, and HTML5 user interfaces.

Edge Controller

Edge Controller

Use our user programmable Edge-Controller as a tool to accelerate development of the next generation industrial edge products and to facilitate rapid IoT and IIoT development.

On-Premises IoT

On-Premises IoT Platform

Learn how to use the Barracuda App Server as your On-Premises IoT Foundation.

Embedded Web Server

Barracuda Embedded Web Server

The compact Web Server C library is included in the Barracuda App Server protocol suite but can also be used standalone.

WebSocket Server

Microcontroller Friendly

The tiny Minnow Server enables modern web server user interfaces to be used as the graphical front end for tiny microcontrollers. Make sure to check out the reference design and the Minnow Server design guide.

WebDAV Server

Network File System

Why use FTP when you can use your device as a secure network drive.

HTTP Client

Secure HTTP Client Library

PikeHTTP is a compact and secure HTTP client C library that greatly simplifies the design of HTTP/REST style apps in C or C++.

WebSocket Client

Microcontroller Friendly

The embedded WebSocket C library lets developers design tiny and secure IoT applications based on the WebSocket protocol.

SMTP Client

Secure Embedded SMTP Library

Send alarms and other notifications from any microcontroller powered product.

Crypto Library

RayCrypto C Library

The RayCrypto engine is an extremely small and fast embedded crypto library designed specifically for embedded resource-constrained devices.

Embedded PKI Service

Automatic SSL Certificate Management for Devices

Real Time Logic's SharkTrust™ service is an automatic Public Key Infrastructure (PKI) solution for products containing an Embedded Web Server.


Modbus TCP client

The Modbus client enables bridging of Modbus enabled industrial products with modern IoT devices and HTML5 powered HMIs.

Posted in Xedge32