I had been wanting to build a project with the Atom Lite I bought some time ago, and the start of winter in the southern hemisphere gave me the perfect excuse. So I got to work and built this monitor that measures environmental variables like temperature, humidity, and atmospheric pressure outside, and displays them in a series of widgets on my phone screen—helping me decide how to dress before heading to work (because listening to the radio forecast or checking the weather app would be way too easy, of course 😊)
Up next, I’ll explain how the monitor works and how you can build it step by step—understanding both the logic behind its operation and the materials and connections needed to put it all together.
The Atom Lite is one of the simplest and most affordable controllers from M5Stack. It features an ESP32-PICO module, Wi-Fi and Bluetooth connectivity, and 4MB of Flash memory, all in a compact 24 x 24 mm package. Unlike other Atom models, the Lite version doesn’t include a screen or LED matrix, but it does come with a top RGB LED, an IR LED, two buttons, a USB-C connector for power and programming, and a Grove port for connecting external modules or units.
Its small size, low cost, and built-in Wi-Fi make it ideal for compact IoT nodes in countless applications such as temperature and humidity monitors, security alarms, light controllers, or motion and presence sensors. Its lightweight design also makes it suitable for wearable applications when combined with a battery.
In addition to the Grove connector, the bottom of the Atom Lite has two headers that expose 5V and GND power pins, a 3.3V output, and six GPIO pins that can be used to connect external circuits.
ENV IV UnitAlong with the Atom Lite, this monitor also includes the ENV IV Unit, also from M5Stack. It can measure temperature, humidity, and atmospheric pressure using its onboard SHT40 and BMP280 sensors. It features a Grove connector for easy connection to a controller and communicates via the I2C protocol.
ThingSpeak is a popular platform in the IoT world, as it allows you to store, visualize, and analyze sensor data easily. It’s super easy to use and offers a generous free tier—ideal for educational projects or personal experiments.
In this project, I used ThingSpeak as an intermediary: the Atom sends sensor readings to the ThingSpeak server using MQTT, and then I use the ThingShow app to read and display the data on my phone using customizable widgets. That way, I always have updated weather info right at hand.
Of course, the data can also be viewed on a ThingSpeak dashboard, using different types of graphs and widgets to display the values in various ways.
For this project, I created a channel with four fields to store temperature, humidity, atmospheric pressure, and Wi-Fi signal strength (RSSI). The last one isn’t related to weather, but it’s useful for checking signal quality in different installation spots.
MQTT
ThingSpeak supports both HTTP and MQTT protocols for sending data. In this project, I chose MQTT since it’s more efficient in terms of power consumption—making it ideal for IoT devices. Even though this monitor is powered from the grid and not battery-operated, I still went with MQTT to stick to best practices and ensure more stable and lightweight communication.
To use the ThingSpeak MQTT server, you first need to configure a device. From the main menu, go to Devices > MQTT and click the Add a new device button.
You’ll then be prompted to enter a device name (you can choose any), an optional description, and the ThingSpeak channel this device will be linked to (the channel must already exist). Select a channel, click Add channel, and then Add device to finish.
Once your MQTT device is created, ThingSpeak will generate important credentials you’ll need to save: the Client ID, Username, and Password.
Be sure to save this info—especially the password—because if you lose it, ThingSpeak can’t recover it. You’ll have to generate a new one and update it in all your clients, which can be a hassle.
In the image above, you can see my device’s MQTT configuration on ThingSpeak. It’s authorized to publish, but not to subscribe, since I don’t plan to receive data from the broker in this project.
The CircuitThe circuit includes a power supply module that converts mains voltage (220V in my country) to 5V, which powers the Atom Lite. As basic protection, I added a varistor (S20K250 or similar) at the input to guard against transient overvoltages, and a 2A fuse that will blow if the varistor activates. (When an overvoltage occurs, the varistor conducts, draws high current, and the fuse blows—protecting the power supply module)
To run the first tests, I built a prototype like the one shown in the image below, using a multipurpose board. The connection to the mains wires is made through a screw terminal block. All components are soldered to the board, except for the ENV IV unit, which is connected to the Atom Lite via a Grove cable.
After confirming that the prototype was working properly for several days, I designed a PCB using KiCad 9. For the manufacturing, I relied on PCBWay, who kindly provided the boards.
Just a few days later, I received the finished boards. The quality of the work is truly outstanding: flawless finishes, sharp silkscreen, and precise cuts — a highly recommended service. 👍
The program was developed using UIFlow 2. For those unfamiliar with it, UIFlow is a powerful development platform built for M5Stack products. It allows you to create programs using a visual block-based language, and also includes tools for managing the file system, uploading code to the controller, sharing projects, and more. You can also write pure MicroPython code directly—no need to use blocks if you prefer coding.
Here’s a quick overview of how the program works:
- Initialization: The hardware is initialized, including the RGB LED, I2C bus, and ENV IV unit. MQTT connection parameters (URL, username, and password) are also set up.
- Loop: The program reads data from the ENV unit, connects to the Wi-Fi network, establishes an MQTT connection, and sends the variable values to the server. Then it waits for 15 minutes before repeating the cycle.
Before starting to build the program, UIFlow needs to be configured to include the hardware units and software modules you’ll use. In this case, you'll need to add the ENV IV unit and the MQTT module.
Let’s take a closer look at the initialization process:
The RGB init
block specifies the pin where the Atom’s internal RGB LED is connected, and the next block initializes the I2C bus. After that, the ENV IV unit is also initialized.
The next block sets up the MQTT server configuration. The required parameters are:
- Client ID: The identifier assigned by ThingSpeak
- Server: ThingSpeak’s MQTT server (
mqtt3.thingspeak.com
) - Port: MQTT port (
1883)
- User: Same as the Client ID
- Password: The password assigned by ThingSpeak
- Keepalive: Time limit (in seconds) the broker and client wait for messages (
0
means no limit) - SSL: Secure connection (optional)
Now let’s explore the loop section and see how its blocks work together in a continuous cycle.
At the start of each loop, the RGB LED is set to blue for one second. Since there’s no screen, the LED is used to indicate the monitor’s current status. Blue means the loop has just started.
Next, the temperature, humidity, and pressure variables are read from the ENV IV unit.
Then, the device attempts to connect to the Wi-Fi network using the ConnectWifi
function. If successful, the RGB LED turns green, and the device attempts to connect to the MQTT broker. If that connection is also successful, the following message is published to the assigned ThingSpeak channel:
field1=temp&field2=hum&field3=press&field4=RSSI
The image below shows how this message is assembled in more detail:
This isn’t the typical way variables are published to a broker, but it’s how ThingSpeak expects to receive the data.
In the same block, the QoS
(Quality of Service) parameter is set to 0
, meaning the message is sent once without requiring confirmation.
After publishing, the device disconnects from the MQTT broker.
If the Wi-Fi or broker connection fails at any point, the RGB LED turns red, indicating a problem.
In either case—success or error—a 15-minute delay follows before the next reading and upload. (If the monitor were battery-powered, it would make sense to put the Atom into low-power mode during this time.)
Wi-Fi ConnectionThe ConnectWifi
function tries to connect to the Wi-Fi network in STATION mode using the provided SSID and password.
Once the code is complete, it must be uploaded to the controller so the program can run independently of the UIFlow environment:
With the program uploaded, I mounted the assembled board inside a weatherproof plastic enclosure, suitable for protecting the electronic components. The ENV IV unit was attached to the lid using double-sided tape, and the cables pass through a rectangular hole made in the same lid.
Since the ENV IV unit is not water-resistant and not intended for direct outdoor use, I installed the box outside, but under a roof overhang, so it's protected from direct rain. (Time will tell if this setup holds up under those conditions.)
Power from the AC mains enters through an existing hole in the wall, which was originally used to power a lamp.
The final goal of the project is to view weather data directly on your phone, so there’s one key piece left to complete the setup: the ThingShow app.
ThingShow is an app available for Android (unfortunately, there's no iOS version). It’s free to use, though it includes some ads. If you prefer an ad-free experience, you can upgrade to the premium version for just $2 USD.
Once installed on your phone or tablet, ThingShow lets you add various widgets to display data from your ThingSpeak channels. It offers many customization options, giving you quick and clear access to your information.
Some of the features include customizable update intervals, measurement units, text sizes, and colors. You can also use visual elements like gauges (analog dials) with colored ranges, indicator lamps for alerts, and even a compass.
Here are some of the things you can do with ThingShow:
- View public or private channels: Display data from various fields in a ThingSpeak channel. For private channels, you’ll need to provide the corresponding API Key.
- Create virtual channels: Combine data from multiple channels into a single dashboard to view them together.
- Multiple charts: Display several graphs at once on the same screen.
- Local channels: Visualize real-time data without an internet connection by using your local Wi-Fi network. Data can be sent from a device directly to the app, with the option to sync with ThingSpeak when the internet is available.
ThingShow is easy to configure and very intuitive to use. Below is a video tutorial that explains the different options.
View the ChannelsYou can see the real-time data from the monitor at this link
ConclusionsThis project is a great example of how, with just a few components and accessible tools, you can build a fully functional environmental monitoring system. By combining the Atom Lite, the ENV IV unit, and the ThingSpeak platform, we’re able to measure temperature, humidity, and atmospheric pressure in real time—and view the data comfortably on a smartphone thanks to the ThingShow app.
Programming with UIFlow makes development much easier, even for those just starting out in the world of IoT. Plus, choosing the MQTT protocol adds efficiency and stability to the communication process.
It’s worth highlighting the huge advantage of M5Stack products, which simplify electronic project design thanks to their compact form factor, plug-and-play connectivity, and intuitive programming environment. This ecosystem is ideal for both educational settings and developers looking for quick, functional solutions.
In short, it’s a simple yet super useful project—perfect for getting started with IoT or as a classroom activity. And best of all: you’ve got no excuse to leave home without a jacket this winter! 😄
If you have any questions or suggestions, feel free to leave them in the comment section below.
For more information and projects, you can check out my blog and social media.
See you next time! 🚀
Comments