Case counter on an Uno web server keeps hanging; our ERP needs the shift totals
Plant manager, so I’ll describe this the way it was explained to me. Packing line 3 has an Arduino Uno with an Ethernet shield (W5100) and a photo-eye counting cases. A contractor set it up as a little web server, and our ERP’s import job calls http://10.20.3.41/count at the end of each shift to book production.
Twice this month the Uno stopped answering and we lost a shift’s figure, people had to count pallets. Also the ops team wants the count live on our Hermetry board with the line’s temperatures, which right now it isn’t.
My question is whether to fix the web server or do this differently. I’d rather have one place the number lives.
The W5100 has only 4 sockets and the usual web server sketches don’t always close them. A scanner or two browsers hitting it and it runs out. Fixable, but it’ll stay fragile.
What does the ERP need exactly, one total per shift or a running count?
One total per shift, shifts change at 06:00, 14:00 and 22:00. The ERP is on a server inside our network and IT won’t open it to the internet, that was already a fight.
Then flip it around so nobody calls the Uno at all. The Uno posts its counter to Hermetry, and the ERP pulls the shift total from Hermetry. Inbound to your network stays closed.
Uno: send the running total (never reset it on the Uno) every minute to the device HTTP API with its token. A W5100 can’t do TLS, so either put a small TLS-capable board in front or, simplest, swap the Uno for an ESP32 with Ethernet and post over HTTPS. The body is just {"cases_total": 184233}.
ERP side: an API key with the Read only preset for telemetry, allowlisted to the ERP server’s address. At 06:05, 14:05 and 22:05 the import job asks for the increase over the shift:
GET /tenant/{tenantId}/api/telemetry/series?kind=iot_device&entityId={line3}
&keys=cases_total&from={shift_start_ms}&to={shift_end_ms}&bucket=1h&agg=increase
Add up the 8 hourly values. increase handles the counter properly and you don’t care if the device was offline for 10 minutes in between, the total catches up. On the board, the same key on a chart with increase gives ops the live cases per hour.
I’d avoid pushing from a flow to the ERP in your case: the HTTP request block refuses private addresses, so it can’t reach 10.x anyway. The pull keeps IT happy. Reference: The history API.
Contractor swapped the Uno for an ESP32-ETH board last week, same photo-eye. The ERP job now pulls the hourly increases, and the first full week matched the hand count within 2 cases. One snag: they first sent the count as text in quotes, so it showed as a latest value but nothing charted. Sending a number fixed it.
Nice. Watch the 22:00 shift around the clock change in spring and autumn, our timestamps are UTC and we got a 7 hour shift once.
- Vous devez être connecté pour répondre à ce sujet.
Rejoignez la discussion
Connectez-vous pour poser et répondre à des questions, aimer les messages utiles et marquer la réponse qui a résolu votre problème. Chaque contribution rapporte des points et des niveaux.

