Introduction
Ethernet modules like the W5500 and ENC28J60 are the backbone of wired IoT connectivity. They allow microcontrollers (ESP32, Arduino, STM32) to communicate over local networks and the internet with low latency and high reliability — essential for smart home hubs, industrial sensors, and automation controllers. However, programming these modules to talk to cloud AI agents traditionally requires custom firmware, middleware, and constant maintenance.
ASI Biont changes that. Instead of writing integration code yourself, you simply describe your device in a chat conversation with the AI agent. The AI selects the right protocol (MQTT, Modbus/TCP, or HTTP), generates the Python script, and executes it — all in seconds. This article walks through a real scenario: connecting an ESP32 with a W5500 Ethernet module and a temperature/humidity sensor to ASI Biont via MQTT. We’ll cover the architecture, code examples, and automation scenarios you can deploy immediately.
Why Ethernet for IoT?
| Feature | Wi-Fi | Ethernet (W5500/ENC28J60) |
|---|---|---|
| Latency | 10–50 ms | < 5 ms |
| Reliability | Interference-prone | Stable wired connection |
| Power consumption | Higher (Wi-Fi radio) | Lower (no radio) |
| Security | WPA2/3 (shared medium) | Physically isolated |
| Range | 30–100 m | 100 m (CAT5e) |
According to the IEEE 802.3 standard, Ethernet provides deterministic latency, which is critical for industrial control loops. The W5500 (from WIZnet) and ENC28J60 (Microchip) are the two most popular SPI-to-Ethernet controllers. The W5500 has a hardware TCP/IP stack, offloading the microcontroller, while ENC28J60 is cheaper but requires more CPU resources. Both are well-supported in the Arduino ecosystem.
How ASI Biont Connects to Ethernet Devices
ASI Biont supports multiple integration methods, as described in the official documentation. For Ethernet modules, the most practical approach is MQTT (via paho-mqtt) running inside the execute_python sandbox. Here’s why:
- MQTT is lightweight: perfect for resource-constrained devices.
- Publish/subscribe model: the AI agent subscribes to sensor topics and publishes commands.
- No open ports: the device connects outbound to a broker (e.g., Mosquitto, HiveMQ), avoiding firewall issues.
Alternatively, you can use Modbus/TCP (via pymodbus) for industrial sensors, or HTTP API (via aiohttp) if your device exposes a REST endpoint. All code runs in the sandbox with full access to libraries like paho.mqtt, pymodbus, aiohttp, and requests.
Real Scenario: ESP32 + W5500 + DHT22 → ASI Biont
Problem
A smart home user wants to monitor temperature and humidity in a server room. The room has no Wi-Fi, only a wired Ethernet drop. They have an ESP32 with a W5500 Ethernet module and a DHT22 sensor. Manually writing MQTT firmware and a cloud bridge would take hours.
Solution
- Flash the ESP32 with a simple MQTT client (MicroPython or Arduino).
- Connect the ESP32 to the local network via W5500.
- Describe the task to ASI Biont: “Connect to MQTT broker at 192.168.1.100:1883, subscribe to 'sensor/temp' and 'sensor/humidity', log data to a file, and send a Telegram alert if temperature > 35°C.”
- AI does the rest: generates and runs the Python script.
Step-by-Step Implementation
1. ESP32 Firmware (Arduino IDE)
Below is the sketch that reads DHT22 every 10 seconds and publishes to MQTT. You need the libraries: Ethernet, PubSubClient, DHT sensor library.
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <DHT.h>
// DHT22 config
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
// Ethernet config
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 1, 200);
// MQTT config
const char* mqtt_server = "192.168.1.100";
const int mqtt_port = 1883;
const char* temp_topic = "sensor/temp";
const char* hum_topic = "sensor/humidity";
EthernetClient ethClient;
PubSubClient client(ethClient);
void setup() {
Serial.begin(115200);
dht.begin();
Ethernet.begin(mac, ip);
client.setServer(mqtt_server, mqtt_port);
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
float t = dht.readTemperature();
float h = dht.readHumidity();
if (!isnan(t) && !isnan(h)) {
char tStr[8];
char hStr[8];
dtostrf(t, 1, 2, tStr);
dtostrf(h, 1, 2, hStr);
client.publish(temp_topic, tStr);
client.publish(hum_topic, hStr);
Serial.print("Published: ");
Serial.print(tStr);
Serial.print("°C, ");
Serial.print(hStr);
Serial.println("%");
}
delay(10000);
}
void reconnect() {
while (!client.connected()) {
if (client.connect("ESP32_W5500")) {
Serial.println("MQTT connected");
} else {
delay(5000);
}
}
}
Upload this to the ESP32. It will start publishing sensor data to the MQTT broker.
2. ASI Biont Integration (AI-Generated Script)
Now, in the ASI Biont chat, you type:
“Connect to MQTT broker 192.168.1.100:1883. Subscribe to sensor/temp and sensor/humidity. Log each reading with timestamp to a CSV file. If temperature exceeds 35°C, send a Telegram alert using token YOUR_TOKEN and chat_id YOUR_CHAT_ID.”
The AI generates the following Python script and runs it inside the execute_python sandbox:
import paho.mqtt.client as mqtt
import csv
import time
from datetime import datetime
import requests
# Telegram config
TELEGRAM_TOKEN = "YOUR_TOKEN"
CHAT_ID = "YOUR_CHAT_ID"
# MQTT config
BROKER = "192.168.1.100"
PORT = 1883
TOPIC_TEMP = "sensor/temp"
TOPIC_HUM = "sensor/humidity"
def send_telegram(message):
url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
payload = {"chat_id": CHAT_ID, "text": message}
try:
requests.post(url, json=payload, timeout=5)
except Exception as e:
print(f"Telegram error: {e}")
def on_message(client, userdata, msg):
topic = msg.topic
value = msg.payload.decode()
timestamp = datetime.now().isoformat()
print(f"{timestamp} - {topic}: {value}")
# Log to CSV
with open("sensor_log.csv", "a", newline="") as f:
writer = csv.writer(f)
writer.writerow([timestamp, topic, value])
# Alert if temperature > 35°C
if topic == TOPIC_TEMP:
temp = float(value)
if temp > 35.0:
send_telegram(f"⚠️ High temperature alert: {temp}°C")
def on_connect(client, userdata, flags, rc):
print("Connected to MQTT broker")
client.subscribe(TOPIC_TEMP)
client.subscribe(TOPIC_HUM)
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(BROKER, PORT, 60)
client.loop_start()
# Keep alive for 30 seconds (sandbox limit)
time.sleep(30)
client.loop_stop()
The AI runs this script, which connects to the broker, logs data, and triggers alerts. You see the output in the chat instantly.
How to Scale: Automation Scenarios
Once the basic integration works, you can extend it by simply asking the AI:
- “Plot the last 24 hours of temperature readings as a line chart and send it to Telegram every morning.”
- “If humidity drops below 30%, turn on a humidifier via a second MQTT topic.”
- “Forward the data to an InfluxDB database for Grafana dashboards.”
The AI will generate the corresponding Python code using matplotlib, paho.mqtt, or requests — all within the sandbox.
Alternative Protocols for Ethernet Devices
| Use Case | Recommended Protocol | ASI Biont Tool |
|---|---|---|
| Sensor data (ESPs) | MQTT | execute_python + paho.mqtt |
| Industrial controllers | Modbus/TCP | industrial_command with protocol='modbus_tcp' |
| REST API devices | HTTP | execute_python + aiohttp |
| OPC UA factory servers | OPC-UA | industrial_command with protocol='opcua' |
For example, to read a Modbus register from a PLC with IP 192.168.1.50, you just say:
“Read holding register 0 from 192.168.1.50:502, unit ID 1”
The AI uses industrial_command(protocol='modbus_tcp', command='read_registers', args={'host':'192.168.1.50', 'port':502, 'unit':1, 'address':0, 'count':1}) and returns the value.
Why ASI Biont vs. Manual Coding?
- Zero boilerplate: No need to set up Flask servers, cron jobs, or cloud functions. The AI writes everything.
- Adaptable: Change the logic in real-time by typing a new instruction.
- Secure: The sandbox has no access to your local network unless you explicitly provide credentials. All communication goes through the MQTT broker or SSH.
- Extensible: Add new devices by simply describing them — no firmware changes needed.
According to a 2025 survey by IoT Analytics, 73% of IoT projects fail due to integration complexity. ASI Biont eliminates that complexity by letting you focus on what you want to achieve, not how to wire the code.
Conclusion
Ethernet modules like W5500 and ENC28J60 bring stable, low-latency connectivity to microcontrollers. Pairing them with ASI Biont unlocks true conversational automation: you describe the device and the desired behavior, and the AI agent connects, monitors, and controls everything via MQTT, Modbus, or HTTP.
Ready to automate your Ethernet IoT devices without writing a single line of Python? Go to asibiont.com, start a chat, and tell the AI what you want to connect. It’s that simple.
Comments