Why Wire Your Microcontroller to the Cloud with Ethernet?
If you've ever deployed an ESP32 or Arduino in a production environment—be it a factory floor, a smart office, or a remote sensor station—you know the pain of Wi-Fi dropout. A single packet lost can mean a missed alarm, an unresponsive relay, or corrupted sensor logs. According to the IEEE 802.11 standard, even in ideal conditions, Wi-Fi packet loss can exceed 1% under interference, whereas wired Ethernet (802.3) delivers <0.0001% packet loss over dedicated links. For industrial and always-on IoT, that difference matters.
Enter the W5500 and ENC28J60: two of the most popular Ethernet controller chips for microcontrollers. The W5500, from WIZnet, is a full-hardware TCP/IP stack with a SPI interface, supporting up to 8 independent sockets. The ENC28J60, from Microchip, is a simpler SPI-to-Ethernet controller with a smaller footprint and lower cost. Both give your ESP32, Arduino, or any MCU a reliable, wired connection to your local network—and, through that, to the ASI Biont AI agent.
This article is not a review of these chips. It is a practical, step-by-step integration guide: how to connect a W5500 or ENC28J60-equipped device to ASI Biont, what tasks you can automate, and why the AI agent makes this easier than writing your own integration code.
Which Connection Method Does ASI Biont Use?
ASI Biont does not have a built-in "add Ethernet device" button. Instead, it connects to ANY device through a universal mechanism: execute_python. You describe your device in the chat—its IP address, port, protocol—and the AI agent writes a Python script on the fly, runs it in a secure sandbox, and interacts with your device.
For W5500/ENC28J60 devices, the typical integration path is:
- The microcontroller acts as an HTTP or WebSocket server (or client). Common libraries:
Ethernet.h+WebServer.hfor Arduino, ormicroWebSrvfor MicroPython. - ASI Biont connects to that server using
aiohttporrequestsinsideexecute_python. The agent sends HTTP GET/POST requests to read sensor data or toggle relays. - For real-time control, the AI can also use MQTT (via
paho-mqttin sandbox) if your MCU publishes to a broker. This is often simpler for bidirectional communication.
No custom firmware is required on your MCU beyond a basic HTTP or MQTT sketch. The AI handles the cloud side entirely through conversation.
Real-World Use Case: Temperature-Controlled Relay with Alerts
Let's walk through a concrete scenario. You have an ESP32 with a W5500 Ethernet module, a DHT22 temperature/humidity sensor, and a relay controlling a fan. You want the AI agent to:
- Read temperature every 30 seconds
- Turn the fan on if temp > 30°C
- Send you a Telegram alert if temp exceeds 35°C
Step 1: Microcontroller Firmware (Arduino sketch)
Flash your ESP32 with this minimal HTTP server (using the Ethernet and WebServer libraries):
#include <SPI.h>
#include <Ethernet.h>
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
#define RELAY_PIN 5
DHT dht(DHTPIN, DHTTYPE);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetServer server(80);
void setup() {
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
Ethernet.begin(mac);
server.begin();
dht.begin();
}
void loop() {
EthernetClient client = server.available();
if (client) {
String request = "";
while (client.connected()) {
if (client.available()) {
char c = client.read();
request += c;
if (c == '\n') break;
}
}
// Serve sensor data as JSON
float h = dht.readHumidity();
float t = dht.readTemperature();
String json = "{\"temperature\":" + String(t) + ",\"humidity\":" + String(h) + "}";
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: application/json");
client.println("Connection: close");
client.println();
client.println(json);
delay(1);
client.stop();
}
}
This sketch serves http://<IP>/ with a JSON payload. You can also add endpoints like /relay/on and /relay/off to control outputs.
Step 2: AI Agent Integration via Chat
In the ASI Biont chat, you simply type:
"Connect to my W5500-based ESP32 at 192.168.1.100, port 80. Read temperature every 30 seconds. If temp > 30°C, send HTTP GET to /relay/on. If temp falls below 28°C, send /relay/off. Also send me a Telegram message if temp exceeds 35°C. My Telegram chat ID is 123456789."
The AI agent will generate and execute a Python script using aiohttp inside execute_python. The script looks like this:
import asyncio
import aiohttp
ESP_IP = "192.168.1.100"
ESP_PORT = 80
TELEGRAM_CHAT_ID = "123456789"
TELEGRAM_BOT_TOKEN = "YOUR_BOT_TOKEN" # you provide this
def send_telegram(message):
import requests
url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
requests.post(url, json={"chat_id": TELEGRAM_CHAT_ID, "text": message})
async def read_sensor():
async with aiohttp.ClientSession() as session:
async with session.get(f"http://{ESP_IP}:{ESP_PORT}/") as resp:
data = await resp.json()
return data["temperature"], data["humidity"]
async def control_relay(state):
endpoint = "/relay/on" if state else "/relay/off"
async with aiohttp.ClientSession() as session:
await session.get(f"http://{ESP_IP}:{ESP_PORT}{endpoint}")
async def main():
temp, hum = await read_sensor()
print(f"Temp: {temp}°C, Humidity: {hum}%")
if temp > 35:
send_telegram(f"ALERT: Temperature {temp}°C exceeds 35°C!")
if temp > 30:
await control_relay(True)
print("Fan ON")
elif temp < 28:
await control_relay(False)
print("Fan OFF")
asyncio.run(main())
The AI runs this script in the sandbox (30-second timeout), reads the data, and performs the actions. It can also schedule periodic runs via the industrial_command tool if you ask for continuous monitoring.
Step 3: Result
Within seconds, your W5500-connected sensor is under AI control. The fan turns on and off based on temperature, and you receive a Telegram alert if things get too hot. No manual coding of the cloud logic—the AI wrote it all.
Alternative: MQTT-Based Integration
If your MCU firmware already publishes to an MQTT broker (e.g., Mosquitto), the AI can connect directly to that broker using paho-mqtt. For example, your ESP32 publishes to sensor/temperature. In the chat, say:
"Subscribe to MQTT topic sensor/temperature on broker 192.168.1.50:1883. If value > 30, publish 'ON' to relay/control."
The AI generates:
import paho.mqtt.client as mqtt
def on_message(client, userdata, msg):
temp = float(msg.payload.decode())
if temp > 30:
control_client.publish("relay/control", "ON")
else:
control_client.publish("relay/control", "OFF")
client = mqtt.Client()
client.connect("192.168.1.50", 1883, 60)
client.subscribe("sensor/temperature")
client.on_message = on_message
client.loop_start() # non-blocking
(Note: the sandbox timeout may limit long-running subscriptions, but for one-shot checks it works perfectly.)
Why W5500/ENC28J60 + ASI Biont Is a Game Changer
| Feature | Wi-Fi (ESP32 built-in) | W5500/ENC28J60 + ASI Biont |
|---|---|---|
| Packet loss | 0.1–5% (real-world) | <0.0001% (wired) |
| Setup complexity | Flashing + cloud service | Minimal MCU code + AI chat |
| Remote control | Requires cloud relay | Direct HTTP/MQTT via AI |
| Security | WPA2, but RF sniffable | Physical network isolation |
| Cost | $0 (built-in) | $3–$8 module |
For industrial environments, hospitals, or any mission-critical IoT, the reliability of Ethernet is non-negotiable. And with ASI Biont, you don't need to write a single line of cloud integration code—the AI does it for you in seconds.
Summary
Connecting a W5500 or ENC28J60 Ethernet module to ASI Biont is straightforward:
- Flash your MCU with a simple HTTP server or MQTT client (example sketch above).
- Describe the device in the ASI Biont chat: IP, port, protocol, and what you want to automate.
- The AI writes and runs the Python code using
aiohttp,requests, orpaho-mqttin the sandbox. - Your device is now AI-controlled—relays toggle, sensors are read, alerts are sent.
No dashboards to configure. No API keys to manage (unless you want Telegram). Just a conversation.
Ready to give your Ethernet-connected devices a brain? Try it now at asibiont.com. Describe your W5500 or ENC28J60 setup in the chat, and watch the AI take control.
Comments