Sending IoT Data From Arduino to Questdb

Sending IoT Data From Arduino to Questdb

In this article, we discuss how to send IoT data from Arduino to Questdb in a few simple steps. So I immediately went to connect an IoT device to QuestDB to see how it went. Unsurprisingly, it went quite well. So here's how it went, from start to finish.

IoT on QuestDB

As you can well imagine, I've been super busy in my new job at QuestDB so this has taken me longer than I would have liked, but here we are. If you know me at all, you know that one of the first things I always do with new things is, well, connect things to them! So I immediately went to connect an IoT device to QuestDB to see how it went. Unsurprisingly, it went quite well. So here's how it went, from start to finish.

The Database Part

The first thing I had to do was to get QuestDB up and running. Luckily, this is very straightforward. I guess I could have gone the Docker route, but as you're probably aware, I'm not a huge fan of Docker (in no small part due to the fact that it will literally suck the life out of a macOS laptop). There's also (for you MacOS users) brew install questdb but since I work here, and I wanted to test out the latest and greatest web console, I decided to build from source:

code gif

It builds really quickly due to the lack of external dependencies, so that is great! Then all I have to do is start it:

Terminal recording

That is literally all there is to getting QuestDB built and running. But that's just the first part. Now it's time to do something mildly useful with it. First, I'll need to create a table in QuestDB to store my IoT Data (A bit more on this later, so store a pointer to this).

code screenshot

Remember, we're doing SQL here, so there's no new language or syntax to learn. This is a really simple table that I'm building because I'm going to be using an ESP8266 with a (really awful) DHT11 temperature and humidity sensor on it.

The Sensor Part

For this, I'm going to use an ESP8266-based WEMOS D1 Mini only because I happen to have a giant pile of them lying around. I buy them in bulk because they are a dollar or 2 each, easy to use, and largely disposable if I blow one up (which I do with alarming regularity.). The circuit is extremely simple to do:

Arduino sensor architecture

I used an actual WEMOS Shield with the DHT11 on it, so I didn't have to breadboard it, but this schematic gives you an idea of how simple the wiring is. It's literally 3 wires.

The Code Part

Here is where the magic happens. How I actually send the sensor data to the database. There is a simple example program included with the Adafruit DHT Unified Sensor Library that I recommend starting with in order to make this a bit easier. It already has all the parts to read from the sensor so you don't have to write those from scratch. Remember: Good developers copy, but great developers paste!

Since I'm using the 8266, and I'll need internet connectivity, I'll need all the WiFi bits:



#include <WiFiServerSecure.h>


#include <WiFiClientSecure.h>


#include <WiFiClientSecureBearSSL.h>


#include <ESP8266WiFi.h>


#include <ESP8266WiFiMulti.h>


#include <WiFiUdp.h>


#include <ESP8266WiFiType.h>


#include <CertStoreBearSSL.h>


#include <ESP8266WiFiAP.h>


#include <WiFiClient.h>


#include <BearSSLHelpers.h>


#include <WiFiServer.h>


#include <ESP8266WiFiScan.h>


#include <WiFiServerSecureBearSSL.h>


#include <ESP8266WiFiGeneric.h>


#include <ESP8266WiFiSTA.h>


#include <WiFiClientSecureAxTLS.h>


#include <WiFiServerSecureAxTLS.h>

internet of things databases arduino arduino tutorial

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Are the days of Internet Freedom Numbered?

That ideal world is one where there is widespread support for an open Internet that ensures that publicly available information is equally transmittable from - and accessible to - all people and businesses.

Data Visualization in R with ggplot2: A Beginner Tutorial

Data Visualization in R with ggplot2: A Beginner Tutorial. Learn to visualize your data using R and ggplot2 in this beginner-friendly tutorial that walks you through building a chart for data analysis.

Tutorial: Getting Started with R and RStudio

Get your R programming journey off on the right foot with this RStudio tutorial that walks through everything from installation to best practices.

Tutorial: Loading and Cleaning Data with R and the tidyverse

Learn how to load a data set and clean it using R programming and tidyverse tools in this free beginner-level data analysis tutorial.

Benchmarking the Mainstream Open Source Distributed Graph Databases

The deep learning and knowledge graph technologies have been developing rapidly in recent years. Find out more about graph databases.