This content originally appeared on DEV Community and was authored by Yevhen Kozachenko
Why React Native + MicroPython = The Unexpected Duo That Will Change IoT Forever!
Ever wondered what happens when the sleek interface power of React Native meets the hardware-hacking flexibility of MicroPython? Spoiler alert: you get a cross-domain solution that bridges mobile and embedded development like never before.
If youβre a fullstack developer or hardware tinkerer stuck in the middle of disparate tools, this post is your Swiss army knife. Letβs deep dive into an unconventional yet game-changing architecture: Mobile to Microcontroller communication using React Native and MicroPython.
The Problem
IoT devices are coolβbut controlling them is notoriously annoying. Usually, you end up writing:
- Firmware in C (yikes)
- A web dashboard on React
- A server in Node.js or Python
- And maybe some MQTT glue logic
You waste weeks building what seems like a simple connected thermostat.
Wouldnβt it be amazing if you could simply:
- Write a mobile UI in React Native
- Control an ESP32 running MicroPython
- Communicate directly via Wi-Fi with no middle server
Yes, weβre doing just that. So buckle up.
What We’ll Build
A React Native mobile app that can:
- Scan and connect to a device (ESP32)
- Send a command (turn on/off or blink an LED)
- Get sensor data (e.g., temperature or humidity)
All this without MQTT, without cloud, without pain.
Hardware Setup
- ESP32 Dev Board
- DHT11 or DHT22 (for temp/humidity)
- LED + Resistor (for output control)
- Powered via USB or battery
Flash MicroPython firmware on your ESP32. Check official instructions.
MicroPython Code (ESP32 Firmware)
# boot.py (runs on boot)
import network
import socket
import machine
from time import sleep
led = machine.Pin(2, machine.Pin.OUT)
# Set up Wi-Fi AP
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid='ESP32-REACT', authmode=3, password='12345678')
# HTTP Server to receive mobile commands
def web_server():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('0.0.0.0', 80))
s.listen(1)
print('Listening on port 80...')
while True:
conn, addr = s.accept()
print('Connection from', addr)
request = conn.recv(1024)
request = str(request)
if '/led/on' in request:
led.value(1)
elif '/led/off' in request:
led.value(0)
response = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nOK"
conn.send(response)
conn.close()
web_server()
Once flashed, your ESP32 becomes a Wi-Fi hotspot that also runs a micro web server β your React Native mobile app can talk HTTP directly to it!
React Native App (Expo FTW)
Weβll use Expo for simplicity (you can eject later for advanced native stuff).
npx create-expo-app esp32-controller
cd esp32-controller
npx expo start
Install fetch polyfills:
npm install whatwg-fetch
App.js
import React, { useState } from 'react';
import { View, Button, Text, StyleSheet } from 'react-native';
export default function App() {
const [status, setStatus] = useState('Unknown');
const ESP_IP = 'http://192.168.4.1';
const sendCommand = async (command) => {
try {
const res = await fetch(`${ESP_IP}/led/${command}`);
const text = await res.text();
setStatus(`LED ${command.toUpperCase()} - Response: ${text}`);
} catch (err) {
setStatus(`Failed to send: ${err.message}`);
}
};
return (
<View style={styles.container}>
<Text style={styles.title}>ESP32 LED Controller</Text>
<Button title="Turn ON" onPress={() => sendCommand('on')} />
<Button title="Turn OFF" onPress={() => sendCommand('off')} />
<Text style={styles.status}>{status}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
title: { fontSize: 24, marginBottom: 20 },
status: { marginTop: 20, fontSize: 16 }
});
Now connect your smartphone to the ESP32 Wi-Fi network, and test your app. Each button tap sends a command to the MicroPython web server β and turns that tiny LED on/off. Magic, right?
Why This Matters
This pattern unlocks a TON of potential:
Rapid prototyping of IoT UIs
Direct control without servers
More secure (no cloud exposure)
Cheaper β no MQTT broker or backend hosting
Developer-friendly (Node/React/Python stack)
Extending the Pattern
Here are a few ideas:
- Add Sensor endpoints
/temp
,/humidity
- Add WebSocket for real-time updates
- Build QR code pairing into the app
- Use local storage to remember paired devices
- Re-flash ESP remotely via OTA
Final Thoughts
React Native and MicroPython may come from different universes: one rules the JavaScript-driven UI world, the other commands embedded devices in a lightweight interpreted Pythonic form. But together? They form a full-stack frontier for on-device edge computing.
This setup is perfect for startups, hobbyists, or professionals looking to build functional MVPs, control hardware directly, or even prototype custom hardware interfaces at lightning speed .
From mobile app to hardware signal β in under 100ms, with zero middleware. Thatβs a revolution.
Resources
- MicroPython ESP32: https://docs.micropython.org/en/latest/esp32/
- React Native Docs: https://reactnative.dev
- Expo Start Guide: https://docs.expo.dev/
Have you built something with RN + MicroPython? Drop a comment or DM me with your story!
If you need this done β we offer fullstack development services.
This content originally appeared on DEV Community and was authored by Yevhen Kozachenko