Anyone Done It?

Topics about the Software of Revolution Pi
Post Reply
finral
Posts: 2
Joined: 03 Dec 2025, 11:54

Anyone Done It?

Post by finral »

Hey everyone,
First time poster, long time lurker. I’m setting up a RevPi Connect POC at work to grab some data from an older production line. We’re using Modbus over RS485 and I’m successfully pumping everything into Node-RED. Works like a charm. The next hurdle is inventory management specifically tracking a small, critical stock of spare parts that aren’t changed often but have a definite shelf life (think batteries, certain unique filters). I want to link this to the RevPi so it throws up a visual warning on a local dashboard. It's almost like tracking a cache of long-term survival rations stuff that sits around for years and absolutely cannot be missed when it expires. So, here’s my question: Has anyone here tried using a simple local database or a basic Python script (maybe with RevPiModIO?) on the RevPi to handle this specific expiration/validity date tracking? I’m looking for a super lean system that just flags red when a date is coming up. No need for a full ERP solution. Could the Process Image be cleverly used for this, or is that pushing it too far into custom territory? I appreciate any feedback, even if it’s just telling me to use a third-party software like CODESYS. I'd love to keep this as open-source as possible, though.
Cheers!
finral
Posts: 2
Joined: 03 Dec 2025, 11:54

Re: Anyone Done It?

Post by finral »

Hey again,
Just to add a bit more context, I’ve been thinking about how to model this “long-term stock” in a lightweight way. One mental model I keep coming back to is like how people manage actual survival rations: minimal handling, clear expiry tracking, and visible alerts when something is getting close. For example, sites like freezedriedandco.com have really clear expiration labeling for their long-term food supplies, which is exactly the kind of simplicity I’d love to emulate digitally for these critical spare parts.
Basically, I’m imagining something where the RevPi only needs a tiny database or even a JSON file, and Python just checks dates against the current day to trigger a red alert in Node-RED. It feels like it could be surprisingly robust without overengineering.
Curious if anyone has tried something similarly minimal but effective, especially keeping it local and open-source.

Cheers,
User avatar
Amar
KUNBUS
Posts: 193
Joined: 15 Jul 2019, 12:58

Re: Anyone Done It?

Post by Amar »

Hi,
Interesting project - tracking spare parts with expiry dates is a good fit for RevPi, and you're on the right track keeping it lean and local.

Suggested approach:
Use SQLite + Python with RevPiModIO. SQLite is file-based (no server overhead), built into Python, and perfect for this use case. Your Python script checks expiry dates, writes alert flags to the Process Image via virtual I/O variables in PiCtory, and Node-RED picks them up for your dashboard.
Implementation:
1. PiCtory Configuration:
Set up a Virtual Device (you likely already have one) and rename the variables for clarity:

InBit_1 → InventoryAlert (general alert flag)
InWord_1 → ExpiredCount (number of expired items)
InWord_2 → WarningCount (items expiring soon)
InWord_3 → TotalPartsTracked (optional: total inventory)

2. Python Script template:

Code: Select all

import sqlite3
from datetime import datetime, timedelta
import RevPiModIO

# Initialize RevPi
rpi = RevPiModIO.RevPiModIO(autorefresh=True)

# SQLite setup
conn = sqlite3.connect('/home/pi/inventory.db')
c = conn.cursor()

# Create table if not exists
c.execute('''CREATE TABLE IF NOT EXISTS spare_parts
             (part_id TEXT PRIMARY KEY,
              part_name TEXT,
              expiry_date TEXT,
              warning_days INTEGER,
              location TEXT)''')

# Check for upcoming expirations
def check_expirations():
    today = datetime.now()
    c.execute("SELECT * FROM spare_parts")
    
    expired_count = 0
    warning_count = 0
    
    for row in c.fetchall():
        expiry = datetime.strptime(row[2], '%Y-%m-%d')
        days_until = (expiry - today).days
        
        if days_until < 0:
            expired_count += 1
        elif days_until <= row[3]:  # Within warning period
            warning_count += 1
    
    return expired_count, warning_count

# Update Process Image
expired, warning = check_expirations()

rpi.io.InventoryAlert.value = 1 if (expired > 0 or warning > 0) else 0
rpi.io.ExpiredCount.value = expired
rpi.io.WarningCount.value = warning

conn.close()
3. Schedule with Cron:
Run daily or as frequently as needed

Use inject node to poll Process Image every 30-60 seconds:
[Inject: repeat every 30s] → [RevPi Read: InventoryAlert] → [Switch] → [Dashboard Alert]
→ [RevPi Read: ExpiredCount] → [Dashboard Gauge]
→ [RevPi Read: WarningCount] → [Dashboard Text]
Color-code based on values could be added.

CODESYS is overkill for this use case since you already have modbus part handling in python. Also local databases with CODESYS would add additional complexity.

You also have possibility of adding Grafana later only if you want historical analysis or multi-system dashboards.

Key Resources:
RevPiModIO docs: https://revpimodio.org/en/homepage/
Python sqlite3: https://docs.python.org/3/library/sqlite3.html
RevPi tutorials: https://revolutionpi.com/tutorials/
Node-RED dashboard: https://flows.nodered.org/node/node-red-dashboardl

Regards,
Amar
KUNBUS
Post Reply