Simple Program, Possible Memory Leak?

I am using an Atlas Scientific peristaltic pump to deliver about 2L of a basic solution to a tank per day. I’ve wired the pump to the Arduino as shown in this diagram. My code is as follows:

#include <Wire.h> //enable I2C.
#define address 103 //default I2C ID number for EZO-PMP Embedded Dosing Pump.

void setup() //runs once, at startup
{
delay(2000); //wait 2 seconds
Serial.begin(9600); //enable serial port.
Wire.begin(); //enable I2C port.
Wire.beginTransmission(address);
Wire.write(“Plock,1”); //lock protocol to I2C. Seeing issue where protocol is switching between UART and I2C. This will stop pump from pumping
Wire.endTransmission();
delay(2000);
Wire.beginTransmission(address);
Wire.write(“DC,1.39,*”); //Tell the pump to pump continuously at 1.39ml/min indefintitely, which is roughly 2L per day
Wire.endTransmission();
}

void loop()
{
// required, doesn’t do anything tho
}

This seems to work while testing, but I came in this morning (about 16 hours later) and the pump was no longer pumping. I unplugged the pump and the chip and replugged both back in. This didn’t fix the issue. I tried doing this a few more times, and eventually the pump began to rotate again.

Are there any obvious errors with my code?

Thank you!

Not a problem with the code, the code is dead simple and does nothing after it starts the pump. Either the command you are sending it doesnt rin indefinitely like you think it does, or there was some glitch on the power supply that reset the pump controller, but not the arduino.

That unplugging and replugging power didnt instantly fix it makes me suspect the latter, and that something was keeping the arduino powered when you unplugged it at first, but then you unplugged more stuff (including whatever was keeping arduino powered) or left it unplugged for longer (long enough for caps to discharge). When it happens again, I'd wager the reset button on the arduino would revive it, by forcing the arduino ti reset, run setup() again and hence resend that command.

Inductive loads like motors are really good at putting glitches into the power supply that confuse digital electronics powered by same supply. Could also have been some computer power save crap if it was connected to usb port of a computer.

I believe it is your I2C causing the problem. The protocol is a simple state machine that when gets a glitch can lock up or do something other then what it should. Typically the arduino locks up waiting for a response from the I2C device. Be sure your power supply is clean and well regulated. Keep all of your wires less then 2" and keep everything as far away from the motors as you can. If this helps you are on the right track! There is no code running so you are not leaking memory.
Good Luck & Have Fun!
Gil