Wiznet makers

irina

Published August 27, 2025 ©

108 UCC

5 WCC

88 VAR

0 Contests

0 Followers

0 Following

Original Link

IRIV IO Controller to ThingSpeak: Modbus RTU via WIZnet W5x00

Read RS-485 Modbus temperature/humidity on IRIV IO Controller and send to ThingSpeak (field1/field2) over Ethernet using WIZnet W5x00 in CircuitPython.

COMPONENTS
PROJECT DESCRIPTION

This tutorial shows how to use an IRIV IO Controller to read temperature and humidity from an RS-485 (Modbus RTU) sensor and upload both values to ThingSpeak over Ethernet using a WIZnet W5x00 driver in CircuitPython. You’ll create a ThingSpeak channel, grab the Write API Key, and push data to field1 and field2 via the HTTP update endpoint—exactly as demonstrated in the original Cytron guide. 


🔧 Project Overview

Project Name: IRIV IO Controller IoT Gateway : ThingSpeak
Author (Tutorial): Hussien Jawhar Sathik (Cytron)
Platform: IRIV IO Controller (CircuitPython)
Networking: WIZnet W5x00 (CircuitPython adafruit_wiznet5k)
Field Bus: RS-485 (Modbus RTU)
Cloud/App: ThingSpeak (Channel with Write API Key, updates to field1/field2)
What You’ll See: Console prints (temperature/humidity and server response) that match values plotted on your ThingSpeak channel. 

The tutorial walks through creating a ThingSpeak channel, retrieving Write/Read API Keys, and posting data to api.thingspeak.com/update.


⚡ How the Project Works

1) Hardware Setup

IRIV IO Controller

RS-485 (Modbus RTU) temperature/humidity sensor (e.g., slave address 1; registers 1 and 0 used in the example)

Ethernet connection (DHCP recommended)

Initialize the W5x00 via SPI with adafruit_wiznet5k, then create an HTTP session using adafruit_connection_manager + adafruit_requests

2) Protocols & Control

Modbus RTU: Read holding registers—example maps reg 1 → temperature, reg 0 → humidity and scales by 10

ThingSpeak: Send a GET request to

http://api.thingspeak.com/update?api_key=<WRITE_KEY>&field1=<temp>&field2=<humi>

to update your channel fields. 

3) Development Process

Create a ThingSpeak channel and copy the Write API Key.

Insert the key into the code and set your Modbus parameters.

Run on IRIV → confirm console output and ThingSpeak updates/graphs.


💡 Key Features & Benefits

Features

IRIV + W5x00 Ethernet: Reliable wired uplink for cloud logging.

Modbus RTU integration: Periodically polls RS-485 registers for T/RH.

ThingSpeak channel logging: Simple HTTP update calls to field1/field2 with your Write API Key. 

CircuitPython stack: adafruit_wiznet5k, adafruit_requests, uModbus—compact, readable code. 

Applications

Building/Facility: Environmental monitoring (temperature/humidity)

Industrial Edge: RS-485 sensors bridged to cloud analytics

Smart Home/Office: Robust IP backhaul for sensor data

Code Highlights (Essentials)

Below is the distilled flow from the tutorial—replace the key with your ThingSpeak Write API Key.
THINGSPEAK_WRITE_API_KEY = "YOUR_WRITE_KEY"
THINGSPEAK_UPDATE_URL    = "http://api.thingspeak.com/update"

# Read Modbus holding registers (example: addr 1→temp, addr 0→humidity)
temperature = host.read_holding_registers(1, 1, 1)[0] / 10.0
humidity    = host.read_holding_registers(1, 0, 1)[0] / 10.0

# Push to ThingSpeak fields
resp = requests.get(
    f"{THINGSPEAK_UPDATE_URL}?api_key={THINGSPEAK_WRITE_API_KEY}"
    f"&field1={temperature}&field2={humidity}"
)
print("Response:", resp.text); resp.close()

The original page shows the same endpoint, field mapping, and the W5x00 + requests session setup. 


Troubleshooting Tips

No updates? Check the Write API Key, URL spelling, and that api.thingspeak.com is reachable (firewall/proxy).

Bad readings? Verify Modbus slave address, register indices (1 and 0 in the example), baud/parity/stop bits, and any scaling factors. 

DHCP issues: Test with a static IP on the W5x00 to rule out network conflicts.

 

 

 

Documents
Comments Write