Spark & Spark Relay controlled Peristaltic Dosing Pumps

So here are couple pictures of my current project. I want to thank @bko for the help with the current code I’m using. I’m still looking to evolve the code so I can change the timing and duration via a webpage to make adjustments a bit easier, but that will come with time.

I still have a few additions I want to add, a reset button and a manual on/off for each pump. It would also be nice to have some sort of a status light that shows the current status of the spark core, but I’m really unsure of how to do that.

Anyways, thats my project, if you want to give me any input of thoughts I’m certainly open.

The pumps come from a company called APT Instruments. These are high quality pumps that dose at exactly 1.6ml/min. You can find pumps on eBay but with these sort of pumps you get what you pay for.

Thank you!


To get the status led on the front panel you could use this

I have one of these on one of my cores… works really well. i had to remove some plastic from the mounting base and hot glue it in place (the HP1192 is for SMD)

Wow looks sleeeeeeeeeek!

How much are the pumps going for?

I have a :spark: barista robot on my list but the pump price is the key factor for it to become a reality :smiley:

1 Like

@kennethlimcp at the time the pumps were $67/ea. Not sure if that is a current price or not. I have three 12v less expensive pumps that didn’t work for me as they pumped too fast. The minimum they pump is about 12ml/min with a good PWM controller. The motors are 5000rpm motors so you could definitely get a lot more out of it. I also have two of these - They say they are food safe. I never actually used them once I realized how much water they actually pumped, they are intense.

The other dosing pumps are these:

Where are you located? I’d be willing to trade with you any of these products if you could help me out with my web page / program dilemma.

And the apt instrument pumps:

1 Like

How does the wifi connection go with the lid on?

1 Like

That looks awesome! Where did you get that case?!

1 Like

So far the connection seems good. The case came from here, it was dirt cheap!

Any recommendations on a small, panel mount, reset switch?


I think the lid shouldn’t cause much issues with connection since it’s plastic but you can consider a u.fl core if you want to have a more powerful antenna :slight_smile:

The whole enclosure is metal actually. I’ll probably order another core soon just so I can get the external antennae.

That looks soooo slick. Awesome work!

I’m quite happy with it. I’ll be even happier when I get the final code done. Time is the price I pay for being patient with others though…I can’t thank everyone enough.

1 Like

So I’m hoping someone can help me out with the final aspects of my project. I’m hoping to be able to make adjustments to the programming via a webpage. I’ve drawn up how I’d like things to look. Here is my dilemma, I literally have no clue what I’m doing when it comes to programming. I’ve gone through countless tutorials on this site as well as several on trying to learn basic arduino programming. So I’ve come to the conclusion that I simply need help with this and I’m looking to the people of this forum for help. I’m willing to barter it necessary to make it worth your while.

Here is some info on my web design thoughts. This is how I see it looking, or some what close to this.

And here is the current code I’m using…its very basic at the moment, but it works.

// This #include statement was automatically added by the Spark IDE.
#include "SparkTime.h"

UDP UDPClient;
SparkTime rtc;

int RELAY1 = D0;
int RELAY2 = D1;
int RELAY3 = D2;
int RELAY4 = D3;

void setup()
   //Initilize the relay control pins as output
   pinMode(RELAY1, OUTPUT);
   pinMode(RELAY2, OUTPUT);
   pinMode(RELAY3, OUTPUT);
   pinMode(RELAY4, OUTPUT);
   // Initialize all relays to an OFF state
   digitalWrite(RELAY1, LOW);
   digitalWrite(RELAY2, LOW);
   digitalWrite(RELAY3, LOW);
   digitalWrite(RELAY4, LOW);

rtc.begin(&UDPClient, "");
rtc.setTimeZone(-5); // gmt offset


void loop() {

unsigned long currentTime =;
static unsigned long stopTime = 0;

if (rtc.hour(currentTime)==12 && rtc.minute(currentTime)==17 && rtc.second(currentTime)==00) {
    stopTime = currentTime + (100);  //one minute and ten seconds

if (currentTime >= stopTime) {
if (rtc.hour(currentTime)==18 && rtc.minute(currentTime)==49 && rtc.second(currentTime)==00) {
    stopTime = currentTime + (10);  //one minute and ten seconds

if (currentTime >= stopTime) {



The sparktime library is interesting… maybe not needed now… i started playing with the built in time library yesterday and it seems a little easier… and automagicly updates the time when the spark connects to the cloud

Im using it to log times in a database… i leave it stored everywhere as unix time… and do the arithmetic in unix (saves all the &&) … then when i print the unix time i just put it in a Serial.print(Time.timeStr(Unixtime)) where Unixtime is the time and date i want printed and it magicly comes out as a human readable date and time.

because Unix time is in essentially in seconds, if you want the pump to run for 100 seconds… you can add 100 to Unix to get the time to switch off

It may be worth having a look at the open sprinkler project too… it shares a lot in common with your project… all be it alot more advanced with years of development. I would love to port it to the spark one day


There’s actually a single word for that – albeit. I was actually surprised it existed when I found it. :smile:

1 Like

@Hootie81 thank you for sharing that…its quite interesting and would probably work perfectly. For now I’m going to be patient and hopefully I’ll get the help I need. I know I’m asking a lot.

1 Like

what do you use the dosing pumps for? could you measure a sample and have them dose accordingly?

The dosing pump is for dosing a two part solution, one is an alkalinity solution, the other is a calcium solution. Both are for maintaining proper levels in my coral reef aquarium. As corals grow, or I add additional corals, the amount dosed needs to be adjusted accordingly. The pumps are very accurate, they pump 1.6ml/min. It is quite easy to adjust the programming via the Web IDE, but I’d like for it to be easier as my goal is to offer this as a DIY project for others who enjoy the reef hobby. Most of the dosing systems with quality parts and ease of use start at over $300. So by offering this DIY project with a web interface I think it would appeal to a lot more people.

I can also say that I really like the spark core and I’d love to be able to spread the word among other hobbyists. Currently there are a lot of reef projects / controllers that are arduino based, but I think the wifi / cloud capabilities of the spark core offer a lot more functionality and I’d love to be able to spread that word.

And lastly, on a plus side, there is a lot less sarcasm in this community of people. I’ve been very impressed by how willing people are to help and offer suggestions.

1 Like

@james211, you are with the right community for sure :smiley:

There’s tons of web experts (i’m definitely off the chart) to help you do it :wink:

Years and years and years ago i worked for a company and helped design a automated machine that sampled dirt, it had EC, pH, ORP, calcium and a few other things. it would move to a sample slot and inject water and take a reading then pump some other chemical in and take another reading then inject some more chemicals and analyze some more, i didnt understand the chemistry at all, but developing the system was a great first job. (and gave me the opportunity to design and build (and get paid) a 4 axis stepper driver for my cnc before they became a dime a dozen on ebay)

One thing the spark would be great for is taking measurements… if you could hook up a pH probe and a calcuim probe you could have an auto-dosing system that you only have to set the desired level and it would maintain it. if for some reason it was using alot of chemicals to maintain it could send you an email, or if things were changing to rapidly it could alert you!

there are some probe interface shields for arduinos… you could make it better with a spark

1 Like

It’s interesting that you bring that up, for a couple reasons. FIrst off, I’m using an aquarium controller from a company called neptune systems, it works great! I’m curious why they haven’t offered the option of adding a calcium and nitrate probe - both would be VERY handy!

Second, I do have the option of controlling the doser via the controller with an add-on VDM module, but that module costs an additional $100. I’m trying to keep the cost low.

I love your idea of being able to measure the calcium level and adjust appropriately, but that is soooo far beyond my capabilities at the moment. All these suggestions are amazing. Thank you.

1 Like