How to Develop a Mobile App with Flowcode to Monitor Temperature and Humidity Levels

This article shows how a single piece of software – Flowcode – can be used to create web-enabled systems based on low-cost devices like ESP32 and single board computers, such as ROCK SBCs, to monitor temperature and humidity levels.

Flowcode has been around for nearly 25 years now. Traditionally, Flowcode was used to create embedded systems based on popular microcontrollers like PIC, Arduino, AVR, and ARM.

A recent addition to the program was Flowcode App Developer, which allows users to create Windows-based Human Machine Interfaces for embedded systems.

New in the recent version 10.1 release is Flowcode Web Developer, which allows developers to use the same software to create Browser based Human Machine Interfaces for embedded systems rapidly. This means that you can easily use your mobile phone to control and monitor your embedded projects. Let’s see how that works:

Hardware Setup:

Imagine a web-enabled ESP32 integrated with temperature and humidity sensors. The hardware configuration includes:

  • ESP32 Lolin Lite board
  • Grove Temperature and Humidity Sensor SHT31

Development Steps:

Step 1. Embedded System Creation

Step 1 is to create an embedded system that – in this case – connects to the local WiFi network and then publishes temperature and humidity information to the Web. We also use a couple of outputs on the ESP32 to control a heater and a fan using relay modules.

We use Flowcode embedded to create the C code for this. Flowcode Embedded has all the libraries for all the sensors as well as the comms protocols needed, in this case, MQTT. You can see the embedded system side program here:

Step 2. Mobile Application Development

Step 2 is to create the mobile phone software application. Flowcode Web Developer allows you to drag the required components onto a Browser panel and develop a Phone side program that runs in a Browser on a phone. Flowcode creates the page graphics, the Javascript software that runs them, and the communications code – in this case MQTT again. You can see the mobile phone side program here:

Step 3. Setting Up MQTT Server

Next, we set up a MQTT server in the cloud. There are a few ways to do this – popular utilities like ThingSpeak and HiveMQ can be used, or you can create your own local server using a Raspberry Pi or a ROCK single board computer. The embedded program connects via TCP, and the Web Developer program connects via Websockets.

Step 4. Completion

The system now allows users to see the temperature and the humidity and control the heater and fan.

Summary

The MQTT server (or broker) is a bit like a mailbox in the cloud using a “publish-subscribe” model for machine-to-machine data exchange. The web app and embedded app are both MQTT clients, and they communicate with the server using messages that are organised into named “topics”. When received by the server, these topics contain data that are automatically sent to all clients that have subscribed to that particular topic.

For example, the embedded app could periodically send data by publishing the current temperature to a topic called “temperature”. The web app has subscribed to the “temperature” topic so when the MQTT server receives this data from the embedded app, it knows to forward this message to the web app. Similarly, the embedded app could subscribe to command topics published by the web app, which would allow a fan or heater to be controlled or an ambient temperature value to be maintained.

You can learn more about how to build a secure Mosquitto MQTT edge gateway for IIoT applications based on ROCK 4SE in the project here.

Flowcode 10 is now available from the RS website.

Find more information about Flowcode in the Flowcode Wiki.

ROCK SBC shop on OKdo

Let’s invent the future together

What’s your challenge? From augmented reality to machine learning and automation, send us your questions, problems or ideas… We have the solution to help you design the world. Get in touch today.

Looking for something else? Discover our BlogsGetting Started Guides and Projects for more inspiration!

Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.

Privacy

Our website uses cookies and similar technologies to provide you with a better service while searching or placing an order, for analytical purposes and to personalise our advertising. You can change your cookie settings by reading our cookie policy. Otherwise, we’ll assume you’re OK with our use of cookies.

Location

Please select an option to see content specific to your location and shop online.

Browse the US site