Arduino Uno + enc28j60 + Modbus Connection Issues
I've got a project where I am monitoring the voltage on two pins and reporting it to another controller via modbus. I've tweaked an example to meet my needs and it is working pretty well. I did have to modify one of the libraries to leave the connection open after each message to work with the master. The arduino is being powered by a 7v wallwart and all grounds are tied together.
There are two annoying issues, the connection will drop out periodically, and sometimes the connection will go offline completely. Sometimes the connection will drop after 20 minutes and other times it will be two hours. When the connection drops I get a read error on the master and it will reconnect almost instantly.
When the connection goes offline a power cycle brings it back with out any other changes. Are there any changes in my code that could help improve uptime? I'd like to get a solid day out of it, am I expecting too much out of a $30 solution?
/* Modbus-Arduino Example - TempSensor (Modbus IP ENC28J60) Copyright by André Sarmento Barbosa http://github.com/andresarmento/modbus-arduino */
#include <EtherCard.h>
#include <Modbus.h>
#include <ModbusIP_ENC28J60.h>
//Modbus Registers Offsets (0-9999)
const int SL_IREG = 100;
const int SR_IREG = 101;
//Used Pins
const int slPin = A0;
const int srPin = A1;
//ModbusIP object
ModbusIP mb;
void setup() {
// The media access control (ethernet hardware) address for the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// The IP address for the shield
byte ip[] = { 192, 168, 69, 69 };
//Config Modbus IP
mb.config(mac, ip);
// Add SENSOR_IREG register - Use addIreg() for analog Inputs
mb.addIreg(SL_IREG);
mb.addIreg(SR_IREG);
}
void loop() {
//Call once inside loop() - all magic here
mb.task();
mb.Ireg(SL_IREG, analogRead(slPin));
mb.Ireg(SR_IREG, analogRead(srPin));
}
Posted Feb 21, 2022, 8:15 PM UTC
Posting for anyone else who is running into this problem. The Uno can only supply 50 mA of current on the 3.3v output pin. The Enc28j60 looks like it can draw closer to 160 mA of current.
Operating Current Transmitting Ethernet Packets — 160 180 mA VDD = 3.30V, FSCK = 10 MHz, SO = Open, LEDA and LEDB Open, ECON2<PWRSV> = 0 Active, not Transmitting Ethernet Packets — 120 — mA VDD = 3.30V, LEDA and LEDB Open, ECON2<PWRSV> = 0
I'm retooling the project to run on a pro mini and havinga DC to DC convertor kick a 5V PSU down to 3.3 for the Enc28j60 board. I think that will solve the issue.