How to control ESP8266/ESP32 with Parse Server

IoT with Parse platform (parse-server) and ESP8266/ESP32

#iot #parse #ESP8266 #ESP32

Connecting ESP to a backend

I like to connect ESPs (ESP8266 and ESP32) to all sort of backend systems.

Once I played with Google Firebase database, and did in fact find some ESP library to connect to Firebase. I managed to blink LED in the device in real time by changing values in the database.

But Firebase is proprietary and I like open source and self hosting.

Parse platform

“Parse” is a backend service for mainly mobile applications. It provides object and file storage, user authentication, push notifications, dashboard and more.

I saw it as an open source alternative to Google Firebase and similar services.

Why good for IoT

Parse platform is quite versatile backend for especially mobile applications and also makes making web applications quite pleasant.

It also has working real time support. Live queries can be used in real-time reactive applications. And controlling an IoT device fits that category quite nicely.

My Parse-ESP experiment

There was an official Arduino Parse library, but it looks like it has been abandoned, and also it did not support real time queries. So I tried to do my own version.

After a brief study of relevant specs (https://docs.parseplatform.org/rest/guide/ and https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification), I eventually managed to get a reasonable demo system together.

In this system, Parse server contains a class “Devices”, whose object corresponds to one ESP device. Object contains attributes (key-value pairs) like ‘online’ and ‘light’. In the demo ESP device turns its corresponding ‘online’ key to true when it connects to server. It then listens to changes in ‘light’ key and turns on and off its LED light correspondingly.

A simple web UI can be used to toggle ‘light’ on all connected devices. And it works!

The source code of my implementation for ESP8266 and ESP32, and a simple web interface is available at https://github.com/jukkas/parse-esp-example . It uses ESP-Arduino libraries and can be build with PlatformIO.

Implementation is rough, insecure and far from production level, but it has worked for small non essential home control system for a while now.