Why Bridge Ethernet Modules with an AI Agent?
Ethernet modules like the W5500 (SPI-based, 10/100 Mbps) and ENC28J60 (SPI, 10 Mbps) are the backbone of wired IoT. They eliminate Wi-Fi interference, provide stable connections in industrial environments, and allow microcontrollers (ESP32, Arduino, STM32) to communicate over local networks without cloud dependency. Pairing them with ASI Biont’s AI agent means you can monitor sensors, control relays, and collect telemetry entirely through natural language commands—no manual coding for each integration.
How ASI Biont Connects to Ethernet-Based Devices
ASI Biont supports multiple connection methods, but for W5500/ENC28J60-based devices, the most practical are:
- MQTT via paho-mqtt – for publish/subscribe data exchange with an ESP32 running a lightweight MQTT client.
- HTTP API via aiohttp – for direct REST calls to a web server on the microcontroller.
- Hardware Bridge via COM port – if the Ethernet module is attached to an Arduino that communicates over serial.
The AI agent uses the industrial_command tool or writes a Python script in execute_python (sandbox environment) to handle the connection. You simply describe your setup in the chat—e.g., “Connect to ESP32 with W5500 at 192.168.1.100, MQTT topic sensors/temperature”—and the AI generates the code.
Real-World Use Case: ESP32 + W5500 + DHT22 → Telegram Alerts
Hardware Setup
- ESP32 (or any board with SPI)
- W5500 Ethernet module (SPI: CS=5, SCK=18, MOSI=23, MISO=19)
- DHT22 temperature/humidity sensor (data pin 4)
- Power supply (5V)
Wiring simplified:
| W5500 Pin | ESP32 Pin |
|---|---|
| SCK | GPIO 18 |
| MISO | GPIO 19 |
| MOSI | GPIO 23 |
| CS | GPIO 5 |
| GND | GND |
| VCC | 3.3V |
Microcontroller Code (Arduino IDE)
#include <Ethernet2.h>
#include <PubSubClient.h>
#include <DHT.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress server(192, 168, 1, 50); // ASI Biont MQTT broker
EthernetClient ethClient;
PubSubClient client(ethClient);
DHT dht(4, DHT22);
void setup() {
Serial.begin(115200);
Ethernet.begin(mac);
client.setServer(server, 1883);
dht.begin();
}
void loop() {
if (!client.connected()) {
client.connect("ESP32_W5500");
}
client.loop();
float t = dht.readTemperature();
float h = dht.readHumidity();
if (!isnan(t) && !isnan(h)) {
String payload = "{\"temp\":" + String(t) + ",\"hum\":" + String(h) + "}";
client.publish("sensors/data", payload.c_str());
}
delay(10000);
}
AI Agent Integration (ASI Biont Chat)
In the ASI Biont chat, you type:
"Subscribe to MQTT topic sensors/data from broker at 192.168.1.50:1883. If temperature > 30°C, send a Telegram alert to my chat ID 123456789 using bot token bot123:ABC."
The AI writes a Python script using paho-mqtt and requests:
import paho.mqtt.client as mqtt
import requests
TELEGRAM_BOT_TOKEN = "bot123:ABC"
CHAT_ID = "123456789"
def on_message(client, userdata, msg):
import json
data = json.loads(msg.payload)
if data["temp"] > 30:
text = f"⚠️ High temperature: {data['temp']}°C"
requests.post(f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage",
json={"chat_id": CHAT_ID, "text": text})
client = mqtt.Client()
client.on_message = on_message
client.connect("192.168.1.50", 1883, 60)
client.subscribe("sensors/data")
client.loop_forever()
This script runs in the ASI Biont sandbox (execute_python) and monitors data in real time. No manual dashboard setup—everything happens through the chat.
Alternative: Direct HTTP API with ENC28J60
If your device runs a simple HTTP server (e.g., using the UIPEthernet library for ENC28J60), ASI Biont can poll it via HTTP:
import aiohttp
import asyncio
async def get_sensor():
async with aiohttp.ClientSession() as session:
async with session.get("http://192.168.1.101/sensor") as resp:
data = await resp.json()
print(f"Temp: {data['temp']}°C, Humidity: {data['hum']}%")
asyncio.run(get_sensor())
Just describe the endpoint in the chat, and the AI builds the polling logic.
Why This Matters: No-Code IoT Automation
With ASI Biont, you don’t need to write glue code for every new Ethernet device. The AI agent handles protocol selection (MQTT, HTTP, Modbus), data parsing, alerting, and logging. You focus on the hardware; the AI does the integration. Try it today at asibiont.com.
Comments