# Plug 'n play arduino controller, Arduino Green WEB Controller



## mistergreen (Dec 9, 2006)

So I've been working on this wifi arduino based controller for a while. My goal was to make a web based controller where you don't need to touch the code for the code challenged and for the lazy like me. And it's darn convenient to not recompile and upload every time you add a new device.

And here's a video update on the project.
https://www.youtube.com/watch?v=P9wCcPO0gYg


There's more info of this over here
http://aquatictechtank.net/viewtopic.php?f=11&t=143


----------



## O2surplus (Jan 31, 2010)

Sweeeeet! 

I couldn't code my way out of a wet paper bag, so I'm liking this!


----------



## mistergreen (Dec 9, 2006)

You're the hardware guy, I'm the software guy 

It should be pretty awesome and unique when done.


----------



## O2surplus (Jan 31, 2010)

mistergreen said:


> You're the hardware guy, I'm the software guy
> 
> It should be pretty awesome and unique when done.



LOL- Speaking of hardware, I'm going to need your software expertise to explore the control possibilities with this.......






















It's 5 channel LED driver with an integrated Atmega328 chip & DS1307RTC. The board features PWM control for all 5 channels. PWM control of two cooling fans, (2) I2C connections (with 5V and pull up resistors already installed), and (2) Dallas ONEWIRE connections with supporting circuitry for temperature sensing.

The drivers feature user programmable current settings of 300,700,1000,&1400ma per channel. Lot's of Led driving horsepower, but I'm at a loss to what creative software could be employed to control 1 or a group of them together. Any Ideas?


----------



## mistergreen (Dec 9, 2006)

I would play with lights mimicking the sun traveling across the sky, like more intense on the right in the morning and more intense on the left in the evening, even color shift if rgb. Normal aquarium lighting is boring because it's even. It's more dramatic with spot lighting. This maybe even be a good cure for algae.

You can play with light intensity for moon phases at night too. 

If the board can connect to a weather service, it can even mimic outdoor conditions.


Sent from my iPad using Tapatalk HD


----------



## skanderson (Jul 25, 2010)

love that board. the flexibility would be very useful.


----------



## mistergreen (Dec 9, 2006)

Tip of the day:
How to create a secure ardunio web server login by using a session variable.

https://www.youtube.com/watch?v=3UcKvr8Idpo


----------



## mistergreen (Dec 9, 2006)

An update on my Ardunio web controller.

https://www.youtube.com/watch?v=KciaE8RNQMg


----------



## jochocki (Feb 22, 2011)

That looks awesome. Are you going to be releasing the source code to use at some point?


----------



## mistergreen (Dec 9, 2006)

jochocki said:


> That looks awesome. Are you going to be releasing the source code to use at some point?


Yes, I'm still ironing out bugs and add more device types and finally, run it for a while to see how it functions.


----------



## robsworld78 (Aug 14, 2014)

Looks like your really know what you're doing, I wish I had those skills. 

So do I have it right?

The arduino would be loaded with a sketch. I would wire up whatever I want to use to the arduino and then go to the website to add them? So for example one day I decide I want another temperature probe, I wire it to the arduino and add it from the website? Then another day I decide I want to redo my lights and add 2 more channels, do I just add them on the website and wire it up and it works?


----------



## mistergreen (Dec 9, 2006)

yup, It's hardware "agnostic". You can use whatever device and plug them in where ever.
The only required devices are the arduino ethernet shield, an arduino mega, and an RTC.

In some cases you will have to write code though like for an I2C device. The bit wise data is so different on each device that it's not possible to write generic code for it.

But for any digital or pwm or analog pins, it should be plug and play.


----------



## robsworld78 (Aug 14, 2014)

That's pretty sweet. This site is going to have it's share of controllers. lol


----------



## mistergreen (Dec 9, 2006)

A little update and explanation on device dependency feature.





































**************** Video! **********************
*
*
http://youtu.be/7eUSTeTrmgo?list=UUgOKxcfD8xpWYpV6aUZiufQ
*
*
*


----------



## jamblor (Jan 2, 2015)

This is a really cool project and I look forward to your progress. I was thinking of trying to do something similar. Being away for work a lot I'd like to be able to login to a website and check how my aquariums are doing. Maybe even have a video feed or pictures that update every couple hours or at specific events.

My arduino experience is pretty limited to simple tasks like turning things on and off via buttons. I have no idea where to begin on getting it hooked up to the internets. But your project is inspiring me to learn.

Thanks!


----------



## mistergreen (Dec 9, 2006)

jamblor said:


> This is a really cool project and I look forward to your progress. I was thinking of trying to do something similar. Being away for work a lot I'd like to be able to login to a website and check how my aquariums are doing. Maybe even have a video feed or pictures that update every couple hours or at specific events.
> 
> My arduino experience is pretty limited to simple tasks like turning things on and off via buttons. I have no idea where to begin on getting it hooked up to the internets. But your project is inspiring me to learn.
> 
> Thanks!


Thanks for the interest. Video & picture feed is more appropriate for a proper computer like your desktop or a Rasberri Pi. The Arduino is just a little micro-controller so it's more adept at controlling the servo of your webcam or something. It has only so many sram and can't handle large images. Actually as I write this it, I'm thinking it might be possible to stream a large image straight to the client browser rather than storing it so,hmm it could be possible but video would be too much.

I can definite add email alerts for events.


----------



## mistergreen (Dec 9, 2006)

Update,
I added 4 channel PWM 8-bit, and gave sensors a new parameter where you can choose different condition types.

https://www.youtube.com/watch?v=F9o_FwqNd5E


----------



## robsworld78 (Aug 14, 2014)

So what did you do with the temperature probes? Can a person hook many up to the same pin or does it have to be one per pin?

For a video couldn't you have a spot on the website showing the video feed from a USB type camera plugged directly into the computer?


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> So what did you do with the temperature probes? Can a person hook many up to the same pin or does it have to be one per pin?


The mega has so many digital pins and it'll make the logistics & coding easier if people just plug it in another pin.



robsworld78 said:


> For a video couldn't you have a spot on the website showing the video feed from a USB type camera plugged directly into the computer?


I'll have to figure this out. The feed has to go through something so yeah, you can go straight to your computer and see the video through some app like Skype, google etc... The arduino wouldn't be involved.

You can also buy a little cmos camera for your arduino and you can aim it at your aquarium. The arduino would be responsible for displaying the image.

Bump: My next device to add is a generic analog IN device. They're usually sensors.
This web controller will allow you to grab the reading and you can enter in some math formula into the web interface and the formula will transform the reading like Fahrenheit to Celsius. 

It's a neat algorithm called shunting yard. Coding it would take me years to figure out but thank goodness I found an example already made.


----------



## robsworld78 (Aug 14, 2014)

On the video feed instead of using skype or whatever can't it be viewed from the website used with the controller, then it looks more integrated? 

On the screen after login there would also be a window which would show you the feed from your USB camera which can be turned on or off, something like that.

This all looks very interesting, how long do you think till your done?


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> On the video feed instead of using skype or whatever can't it be viewed from the website used with the controller, then it looks more integrated?
> 
> On the screen after login there would also be a window which would show you the feed from your USB camera which can be turned on or off, something like that.
> 
> This all looks very interesting, how long do you think till your done?


The video has to go though the arduino for it to show up on the website. The arduino is the web server. I don't think video is possible on the arduino, the Raspberry PI definitely is doable.

hmmm, or you can sign up for some streaming service like twitch or youtube streaming and then have a simple iframe on the arduino web page. The video would stream on the arduino web controller page. That should work. I think I'll implement that! That's the easiest.

I have no idea when this will be done. I'll have to thoroughly test it. I might commercialize it too but it shouldn't be much. It can be used for anything really.

Oh, I just ordered adafruit's 12bit pwm. That should be fun.


----------



## robsworld78 (Aug 14, 2014)

Yes that's what I was thinking, just like embedding a video, except it would be a video feed. Didn't think you need a service to do that though.


----------



## mistergreen (Dec 9, 2006)

Yup, it's like embedding a YouTube video. There's nothing to embed if you just have a web cam. You need to go through a video server service like youtube.


Sent from my iPad using Tapatalk HD


----------



## kman (Dec 11, 2013)

Tagged to see things progress.


----------



## mistergreen (Dec 9, 2006)

I just made a live stream on YouTube. Can't wait to work this into the controller over the weekend!


Sent from my iPad using Tapatalk HD


----------



## robsworld78 (Aug 14, 2014)

Looking forward to seeing it. Hopefully you can share how you do it, I would like to add that feature, if I ever get to the internet that is.

EDIT: One thing I forgot to mention. Some of the label names are hard to understand what they do, I realize you're just getting it working right now but how about having a page so people can set custom label names? That would make it more friendly for other applications. Have a page showing most labels with a text box for a custom name. When someone hovers over the default label name it would have an example, just an idea.


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Looking forward to seeing it. Hopefully you can share how you do it, I would like to add that feature, if I ever get to the internet that is.
> 
> EDIT: One thing I forgot to mention. Some of the label names are hard to understand what they do, I realize you're just getting it working right now but how about having a page so people can set custom label names? That would make it more friendly for other applications. Have a page showing most labels with a text box for a custom name. When someone hovers over the default label name it would have an example, just an idea.


What do you mean by label names? Any suggestions are helpful at this point.

Here's the guide on setting up a YouTube live feed.
https://support.google.com/youtube/answer/2474026?hl=en&ref_topic=6136989&rd=1

To embed the video onto an html page, find the video in your video list, click share and grab the embed code to put in your html.


Sent from my iPad using Tapatalk HD


----------



## robsworld78 (Aug 14, 2014)

duplicate


----------



## robsworld78 (Aug 14, 2014)

That's easy enough, I thought maybe you had to add some special code because of the arduino. 

On label names, for example in your last video you have the 4 ramp schedules called one, two, three, four which doesn't really tell me much. If I'm using this for an aquarium I want it to say ramp one or maybe low sun and if I'm not using this for an aquarium I may want to tag it something different. I didn't think it would be hard to add custom names so thought it might be worth it. Only labels like that would need to be custom. Technically this can control the aquarium and whatever else you want so it would be nice to change those according to what it is.

Is it limited to 4 schedules? What if I was going to use the one channel PWM pin for a pump and wanted it to turn on and off 10 times in a day how would I do that? Is it possible for it to ask how many schedules that pin should have?

There's also other labels that aren't so clear. Like on the temp settings you have "Parameter Slider" when it should say something like Temperature On/Off Range. Then when someone clicks the slider type to something else it would change to whatever they selected. 

Also the dependent devices is a little hard to understand. When you selected a device you had to clear out the schedule as its not dependent on that anymore, what happens if I didn't clear that out? Maybe a window should pop up telling me that and asking me if I want to clear the schedule and it does it for me. Ultimately it would be nice if when I selected a dependent device it somehow flashed me the settings for that device so I visually saw the connection.

Just little things like that. I think what you're doing is amazing and could be used by so many for a lot of applications as programming is a big issue. But most people who have problems with programming also have trouble understanding these kinds of programs so it needs to be made as simple as possible (which you have) just needs better clarity IMO. Just trying to give you some constructive criticism.


----------



## mistergreen (Dec 9, 2006)

Ah, thanks for the feedback. Custom labels would take up precious memory from the arduino and more coding so I don't think that's feasible. Yeah, I can add more slots for the pwm sliders. But I'm keeping a limit to 4 generally to reserve memory. Every time I add a device it takes up 200-300 bytes of memory. The biggest one so far is the onewire thermometer because it includes the onewire library.


Sent from my iPad using Tapatalk HD


----------



## robsworld78 (Aug 14, 2014)

It's not a big deal on the custom labels, there isn't many anyways but I thought they could be php variables or whatever you're using stored in a database or something, didn't realize memory still relied on the arduino. I was going to have custom labels on my controller but yeah memory. Will this work on the due without to much work?


----------



## mistergreen (Dec 9, 2006)

Actually, you can customize it. You'd have to change the html code on the sd card but if people's programming skills aren't up to it, they don't have to touch anything. But no, the labels couldn't be variables.

Because of the memory requirements, it'll only work on a mega.

Another device you can add is the IR to control those fancy Sat lights. I can grab the code already developed so it's no big deal to incorporate.


----------



## robsworld78 (Aug 14, 2014)

But the due has more memory?


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> But the due has more memory?


Oh! it does. It has plenty at 96K vs 8K of the mega. I was thinking of something else. 
I'm not 100% sure on the compatibility though.


----------



## robsworld78 (Aug 14, 2014)

Yeah and its much much faster to, also has 12-bit PWM onboard. The difference is its 3.3v vs 5v and some libraries are different.


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Yeah and its much much faster to, also has 12-bit PWM onboard. The difference is its 3.3v vs 5v and some libraries are different.


Oh, the 12bit pwm is nice. I'll make 2 versions if necessary. It's a easy as swapping out libraries. Working on the mega is keeping me disciplined on memory management.


----------



## mistergreen (Dec 9, 2006)

hey, I forget who but they tested this flow sensor and said they cut the pump's flow by half.
http://www.seeedstudio.com/depot/g114-water-flow-sensor-p-1082.html?cPath=144_151

I just had this idea where you don't put it inline but at the end of the spray bar. The flow won't be obstructed and all you really care about the the percent of flow not the actual flow rate. Say, It's at 50% from last month. That's all you need.


----------



## kman (Dec 11, 2013)

mistergreen said:


> hey, I forget who but they tested this flow sensor and said they cut the pump's flow by half.
> http://www.seeedstudio.com/depot/g114-water-flow-sensor-p-1082.html?cPath=144_151
> 
> I just had this idea where you don't put it inline but at the end of the spray bar. The flow won't be obstructed and all you really care about the the percent of flow not the actual flow rate. Say, It's at 50% from last month. That's all you need.


OOOHH, that's slick. It'd be tough to do with lily pipes, though.

Still, I've really wished, on more than one occasion, for a way to monitor flow from my canister, just so I could know when flow rate is down, etc. You're right, precise values aren't important, just relative ones. But I can't afford a 50% hit to my flow rate, that's for sure.


----------



## mistergreen (Dec 9, 2006)

I got a 1% flow rate the other day. That's what got me thinking. I need an alert!
They do make flow sensors that don't obstruct but they're hundred of dollars.

I have 2 filters in my 75G. That's why I didn't notice.


----------



## kman (Dec 11, 2013)

mistergreen said:


> I got a 1% flow rate the other day. That's what got me thinking. I need an alert!
> They do make flow sensors that don't obstruct but they're hundred of dollars.
> 
> I have 2 filters in my 75G. That's why I didn't notice.


My Eheim Ecco 60 impeller died.. but the motor still sounded like it running normally. Fortunately I had a spare head (I had a cracked canister a month ago, so I had purchased a whole replacement filter). I could tell something was off, but not what... until I did a water change, I didn't notice that the outflow had reduced to barely a trickle! Much relief when I hooked up the new head and flow resumed at normal levels.


----------



## mistergreen (Dec 9, 2006)

Live Stream is enabled!

https://www.youtube.com/watch?v=JAgaJNq0ZWg

You can definitely have a better webcam than mine. I'm using my crappy laptop to stream. If you're streaming 24/7, I'd recommend the few lowest bit rate streaming options. You don't want to hog your network. Oh, and don't let the computer go to sleep or the stream will stop


----------



## robsworld78 (Aug 14, 2014)

Looks good till it freezes up at the end, lol. That's exactly what I was talking about. I like how you set it up so you can watch any video through it, now you can advertise my controller.


----------



## jamblor (Jan 2, 2015)

Amazing progress! Glad you got the video working.


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Looks good till it freezes up at the end, lol. That's exactly what I was talking about. I like how you set it up so you can watch any video through it, now you can advertise my controller.


Streaming vids tend to freeze for a second once in a while. Home internet tends to be good at downloading but slow at uploading so streaming video quality won't be too good. Hey, at least you can see light, water level and any float dead fish, it does its job.

If you're lucky to have fiberoptics, you can set up multiple cameras.


----------



## robsworld78 (Aug 14, 2014)

Here's the code for lunar cycle.

Create a file called moon_phases.h and included the following.

```
int GetPhase(int nYear, int nMonth, int nDay);
const char* getMoonPhaseName(int phase);
```
Then create a file called moon_phases.cpp and include the following.

```
#include <math.h>
/* // This was original code for showing text, I didn't care to show any so I didn't edit
 // this section but left it for reference if I decide to.
const char* moonPhasesText[] = {
                   "New            \0", //  XXXXXXXX\0",
                   "Waxing crescent\0", //  XXXXXX__\0",
                   "First quarter  \0", //  XXXX____\0",
                   "Waxing gibbous \0", //  XX______\0",
                   "Full           \0", //  ________\0",
                   "Waning gibbous \0", //  ______XX\0",
                   "Last quarter   \0", //  ____XXXX\0",
                   "Waning crescent\0", //  __XXXXXX\0"
                 };
*/
const char* getMoonPhaseName(int phase){
  return moonPhasesText[phase];
}

double MyNormalize(double v)
{
  v = v - floor(v);
  if (v < 0)
    v = v + 1;
  return v;
} 

int GetPhase(int nYear, int nMonth, int nDay) // calculate the current phase of the moon
{
  int phase;
  double AG, IP;
  long YY, MM, K1, K2, K3, JD;
  YY = nYear - floor((12 - nMonth) / 10);
  MM = nMonth + 9;
  if (MM >= 12)
  {
    MM = MM - 12;
  }
  K1 = floor(365.25 * (YY + 4712));
  K2 = floor(30.6 * MM + 0.5);
  K3 = floor(floor((YY / 100) + 49) * 0.75) - 38;
  JD = K1 + K2 + nDay + 59;
  if (JD > 2299160)
  {
    JD = JD - K3;
  }
  IP = MyNormalize((JD - 2451550.1) / 29.530588853);
  AG = IP*29.53;
  if (AG <= .98435) phase = 0; // 0%
  else if (AG <= 1.96870) phase = 1; // 1%
  else if (AG <= 2.95305) phase = 2; // 4%
  else if (AG <= 3.93741) phase = 3; // 10%
  else if (AG <= 4.92176) phase = 4; // 18%
  else if (AG <= 5.90611) phase = 5; // 27%
  else if (AG <= 6.89047) phase = 6; // 36%
  else if (AG <= 7.87482) phase = 7; // 45%
  else if (AG <= 8.85917) phase = 8; // 54%
  else if (AG <= 9.84352) phase = 9; // 63%
  else if (AG <= 10.82788) phase = 10; // 72%
  else if (AG <= 11.81223) phase = 11; // 81%
  else if (AG <= 12.79658) phase = 12; // 90%
  else if (AG <= 13.78094) phase = 13; // 96%
  else if (AG <= 14.76529) phase = 14; // 100%
  else if (AG <= 15.74964) phase = 15; // 100%
  else if (AG <= 16.73400) phase = 16; // 96%
  else if (AG <= 17.71835) phase = 17; // 91%
  else if (AG <= 18.70270) phase = 18; // 84%
  else if (AG <= 19.68705) phase = 19; // 77%
  else if (AG <= 20.67141) phase = 20; // 69%
  else if (AG <= 21.65576) phase = 21; // 61%
  else if (AG <= 22.64011) phase = 22; // 52%
  else if (AG <= 23.62447) phase = 23; // 43%
  else if (AG <= 24.60882) phase = 24; // 35%
  else if (AG <= 25.59317) phase = 25; // 27%
  else if (AG <= 26.57752) phase = 26; // 18%
  else if (AG <= 27.56188) phase = 27; // 10%
  else if (AG <= 28.54623) phase = 28; // 4%
  else if (AG <= 29.530588853) phase = 29; // 1%
  return phase;
}
```
Then in your main sketch add reference to moon_phases.h with the following.

```
#include "moon_phases.h"
```
And to show images I have the following function in the main sketch.

```
void showMoonPhase(){
  phase = GetPhase(year(), month(), day(now()));
  int xMoon=298;
  if (fadeInProgress==true && fadeFromMode==3 && dispScreen==1) {
    xMoon=231; 
    myFiles.loadBitmap(240, 138, 36, 11, "homeL2.raw");
  }
  else if (fadeInProgress==true && fadeToMode==3 && dispScreen==1) {
    xMoon=365; 
    myFiles.loadBitmap(374, 138, 36, 11, "homeL2.raw");
  }
  else if (dispScreen==1) {
    xMoon=298; 
    myFiles.loadBitmap(307, 138, 36, 11, "homeL2.raw");
  }

  if (phase==0) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon1.raw"); // 0%
  else if (phase<=1) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon2.raw"); // 2%
  else if (phase<=3) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon3.raw"); // 10%
  else if (phase<=4) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon4.raw"); // 18%
  else if (phase<=5) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon5.raw"); // 25% right
  else if (phase<=6) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon6.raw"); // 38%
  else if (phase<=7) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon7.raw"); // 50% right
  else if (phase<=8) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon8.raw"); // 59%
  else if (phase<=10) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon9.raw"); // 67%
  else if (phase<=11) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon10.raw"); // 75% right
  else if (phase<=13) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon11.raw"); // 84%
  else if (phase<=14) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon12.raw"); // 92%
  else if (phase<=15) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon13.raw"); // 100%
  else if (phase<=16) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon14.raw"); // 92%
  else if (phase<=17) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon15.raw"); // 84%
  else if (phase<=19) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon16.raw"); // 75% left
  else if (phase<=20) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon17.raw"); // 67%
  else if (phase<=22) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon18.raw"); // 59%
  else if (phase<=23) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon19.raw"); // 50% left
  else if (phase<=24) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon20.raw"); // 38%
  else if (phase<=25) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon21.raw"); // 25% left
  else if (phase<=26) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon22.raw"); // 18%
  else if (phase<=28) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon23.raw"); // 10%
  else if (phase<=29) myFiles.loadBitmap(xMoon, 80, 55, 55, "moon24.raw"); // 2%
}
```
And finally in my alarm for moonlight mode I have the following. To use this you need to have moonlight value set to at least 30 as there are 30 phases. For 8-bit PWM you need really low power leds or 30 (full moon) is way to bright.

```
moonLum=1;
  
  if (lunarOnOff==0)
  {
    showMoonPhase();    
    if (phase==0) moonLum=0; // 0%
    else if (phase==1) moonLum=.01; // 1%
    else if (phase==2) moonLum=.04; // 4%
    else if (phase==3) moonLum=.1; // 10%
    else if (phase==4) moonLum=.18; // 18%
    else if (phase==5) moonLum=.27; // 27%
    else if (phase==6) moonLum=.36; // 36%
    else if (phase==7) moonLum=.45; // 45%
    else if (phase==8) moonLum=.54; // 54%
    else if (phase==9) moonLum=.63; // 63%
    else if (phase==10) moonLum=.72; // 72%
    else if (phase==11) moonLum=.81; // 81%
    else if (phase==12) moonLum=.90; // 90%
    else if (phase==13) moonLum=.96; // 96%
    else if (phase==14) moonLum=1; // 100%
    else if (phase==15) moonLum=1; // 100%
    else if (phase==16) moonLum=.96; // 96%
    else if (phase==17) moonLum=.91; // 91%
    else if (phase==18) moonLum=.84; // 84%
    else if (phase==19) moonLum=.77; // 77%
    else if (phase==20) moonLum=.69; // 69%
    else if (phase==21) moonLum=.61; // 61%
    else if (phase==22) moonLum=.52; // 52%
    else if (phase==23) moonLum=.43; // 43%
    else if (phase==24) moonLum=.35; // 35%
    else if (phase==25) moonLum=.27; // 27%
    else if (phase==26) moonLum=.18; // 18%
    else if (phase==27) moonLum=.10; // 10%
    else if (phase==28) moonLum=.04; // 4%
    else if (phase==29) moonLum=.01; // 1%
  }
  
  // target color is moonlight
  targetColor.Red = (lightMoon.Red*moonLum);
  targetColor.Green = (lightMoon.Green*moonLum);
  targetColor.Green2 = (lightMoon.Green2*moonLum);
  targetColor.Blue = (lightMoon.Blue*moonLum);
  targetColor.Blue2 = (lightMoon.Blue2*moonLum);
  targetColor.White = (lightMoon.White*moonLum);
  targetColor.Violet = (lightMoon.Violet*moonLum);
  targetColor.Moon = (lightMoon.Moon*moonLum);
```
I only added 24 images because I did this before I went to fat32 SD card and I was reaching my limit. Technically you can have any mix of phases or images as you want. Originally I tried 200 phases but it took to much flash memory, what a waste of time that was. :hihi: I trimmed it as much as I could without losing too much effect.

And here's a link to 360 high quality images of the moon, more than you'll ever need. 

http://commons.wikimedia.org/wiki/User:JayTanner/lunar-near-side-phase-set


----------



## mistergreen (Dec 9, 2006)

Thanks for the code. In your getPhase() function, no need for the long if else table. Just do 
return floor(AG)

Floor will round down decimal to the nearest int.

You can probably get rid of all of the other if else too but will take a little coding trickery.


Sent from my iPad using Tapatalk HD


----------



## robsworld78 (Aug 14, 2014)

Yeah I'm sure it all can be written better but hey it works. Hopefully some of its useful to you.


----------



## Notorious93 (Jun 3, 2013)

Why not use a raspberry pi as the brains and an arduino as the workhorse?? Make the two communicate in one system for twice the capabilities. I know people have already done it before


----------



## mistergreen (Dec 9, 2006)

Notorious93 said:


> Why not use a raspberry pi as the brains and an arduino as the workhorse?? Make the two communicate in one system for twice the capabilities. I know people have already done it before


True. It was an option but I can do it with the arduino alone so I don't see an advantage at this point.

I did play with the PI. Installation of all of the software was such a pain like mysql, apache etc... It took 8 hours to install one piece of software. It takes a minute to compile and upload on the arduino. I'm also more adept at C.

So it was just a matter of weighing the pros and cons. I do wish I have mysql to play with though. I'll have to do it the hard way to read & write what I need on the sd card.


----------



## mistergreen (Dec 9, 2006)

Good news, I found a way to have the arduino email. It calls a php script on my web server. This is the only reliable way to email since mail servers usually block suspicious servers (arduino) because of security and spam issues.

You can even sms any message too. Many carriers have email-sms gateways like for verizon, phone#@vtext.com or t-mobile is phone#@tmomail.net.

I'm working to integrate this into my controller framework.


----------



## robsworld78 (Aug 14, 2014)

Weekend's almost over in case you forgot. :hihi:


----------



## mistergreen (Dec 9, 2006)

Finished editing the video and getting distracted by the Super Bowl, darn super bowl.


----------



## mistergreen (Dec 9, 2006)

Alright, as promised

http://youtu.be/FLL23LHrr3Y


----------



## robsworld78 (Aug 14, 2014)

looks good!


----------



## mistergreen (Dec 9, 2006)

I think I'll do your moonlight code next. Instead of adding it to an existing pwm logic it'll be it's own logic like all of the device objects. You can tell it to affect another component by using the 'dependent device' frame work I've set up. So instead of reading another component, it'll 'write' to another component.


----------



## robsworld78 (Aug 14, 2014)

Not sure what you mean, sounds complicated but sure it will work nicely. I'm an if else guy, so all this is over my head. :hihi:


----------



## rottison (Aug 28, 2014)

wow that looks really cool 

bow ties are cool I prefer a fezz


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Not sure what you mean, sounds complicated but sure it will work nicely. I'm an if else guy, so all this is over my head. :hihi:


Think of it as a tool box. You get to choose which tools to use and which tools can work together.

The coding is a bit insane but it's darn organized. Each component is basically it's own file/ class. My actually arduino sketch is quite small.

Sent from my iPad using Tapatalk HD


----------



## mistergreen (Dec 9, 2006)

rottison said:


> wow that looks really cool
> 
> bow ties are cool I prefer a fezz


Nice. To be honest, I've worn neither.


Sent from my iPad using Tapatalk HD


----------



## rottison (Aug 28, 2014)

it a Dr.Who thing I'm a long time scifi geek


----------



## mistergreen (Dec 9, 2006)

rottison said:


> it a Dr.Who thing I'm a long time scifi geek


Me too 😃


Sent from my iPad using Tapatalk HD


----------



## kman (Dec 11, 2013)

mistergreen said:


> Me too 😃


Me three.


----------



## kman (Dec 11, 2013)

Btw, want Windows on your Pi?

http://www.infoworld.com/article/28...a-35-raspberry-pi-yes-but-theres-a-catch.html


----------



## mistergreen (Dec 9, 2006)

kman said:


> Btw, want Windows on your Pi?
> 
> http://www.infoworld.com/article/28...a-35-raspberry-pi-yes-but-theres-a-catch.html


huh... windows 10 can fit on a PI? We'll see how Window 10 is. I absolutely hate 8.x.


----------



## kman (Dec 11, 2013)

mistergreen said:


> huh... windows 10 can fit on a PI? We'll see how Window 10 is. I absolutely hate 8.x.


Well, based on everything I've read about 10, I'll be sticking to Windows 7 for a long, long time.

Could be interesting for an embedded device like this, though.


----------



## robsworld78 (Aug 14, 2014)

On your temperature probes are you calling the following line for each probe attached?

```
sensors.requestTemperatures();
```
Bump:


kman said:


> Well, based on everything I've read about 10, I'll be sticking to Windows 7 for a long, long time.
> 
> Could be interesting for an embedded device like this, though.


But there's a button so you can see all your open apps.  And unfortunately you will only stick to Windows 7 as long as they say. :hihi:


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> On your temperature probes are you calling the following line for each probe attached?
> 
> ```
> sensors.requestTemperatures();
> ```


No I don't. It depends what library you use. I'm using OneWire.h directly and polling to the device's address. It's smaller than the Dallas library. I'm planning to use 1 sensor per pin.


```
byte data[12];
    byte addr[8];
    
    if ( !this->ds->search(addr)) {
        //no more sensors on chain, reset search
        this->ds->reset_search();
        return -1000;
    }
    
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.println("CRC is not valid!");
        return -1000;
    }
    
    if ( addr[0] != 0x10 && addr[0] != 0x28) {
        Serial.print("Device is not recognized");
        return -1000;
    }
    
    this->ds->reset();
    this->ds->select(addr);
    this->ds->write(0x44,1); // start conversion, with parasite power on at the end
    
    byte present = this->ds->reset();
    this->ds->select(addr);
    this->ds->write(0xBE); // Read Scratchpad
    
    
    for (int i = 0; i < 9; i++) { // we need 9 bytes
        data[i] = this->ds->read();
    }
    
    this->ds->reset_search();
    
    byte MSB = data[1];
    byte LSB = data[0];
    
    float tempRead = ((MSB << 8) | LSB); //using two's compliment
    float TemperatureSum = tempRead / 16;
```


----------



## kman (Dec 11, 2013)

robsworld78 said:


> On your temperature probes are you calling the following line for each probe attached?
> 
> ```
> sensors.requestTemperatures();
> ...


We have a Windows 2000 machine still alive and kicking around here somewhere. They don't get a vote.  (at least, not with versions of Windows pre-10 :confused1


----------



## robsworld78 (Aug 14, 2014)

Hmm, ok, this looks better.

Do you still get a delay of .75 seconds when it polls for the temp?

With that line of code I asked about it gets stuck there for a while, I googled it and it is normal. It sounded like it was the probe and not the library causing the delay. I think I need to run that line for every pin I'm using which is no good. I don't want to use 1 pin for all probes as addresses need to be assigned.

So does that piece of code loop for each probe attached?

Where would I add that code you posted, do I add it where I have my requestTemperatures? And I'm guessing the final temperature is held in "TemperatureSum"?

EDIT: I add that code to a new sketch in setup() with onewire library and it won't compile?


----------



## mistergreen (Dec 9, 2006)

Oh, my code is altered to work with my framework.
Here's the source.
http://bildr.org/2011/07/ds18b20-arduino/


----------



## robsworld78 (Aug 14, 2014)

Oh that's wonderful, thanks! Its nice when it works in 10 seconds. :hihi: And no more delay. roud:


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Oh that's wonderful, thanks! Its nice when it works in 10 seconds. :hihi: And no more delay. roud:


What library were you using before? The Dallas library?


----------



## robsworld78 (Aug 14, 2014)

Yeah the DallasTemperature library, thought that was the only way. It'll be interesting to see how much flash I save, I'm at 97% full. I'm squeezing every little bit out of this mega.  I really hated that delay because when the lights were fading and getting at the low values you could notice the skip intervals because it was reading temperature. I added some code so the last 5 minutes of the fade it wouldn't read temps. :hihi:


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> flash I save, I'm at 97% full. I'm squeezing every little bit out of this mega.




I'm not even close to 40%. Mine is potentially a memory hog though. I might have to give the 'due' a good look.


----------



## robsworld78 (Aug 14, 2014)

Yes its a never ending battle, I also wish I stuck with the due, I started with it but it quit taking uploads early on so I thought I would use the mega as I had it on hand and had no clue what I was doing. Live and learn I guess. Your lucky you're not loading images with the UTFT library, that really sucks up the memory. I'm lucky I was pointed towards the F() macro, if you wrap that around serial strings it uses no memory. My communication between arduinos wouldn't be possible without that. If you're not aware of it it goes like this.


```
Serial.println(F("As long of a string as you wish and it won't use vital memory. :))  "));
```


----------



## robsworld78 (Aug 14, 2014)

Just finished making the official changes, I'm a happy camper.  That delay I put a caption on in my video is gone. roud:

I tried using the same function for each probe but that didn't work out so I'm using the function 3 times and doing this I still saved 916 bytes, imagine if I knew what I was doing.


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Just finished making the official changes, I'm a happy camper.  That delay I put a caption on in my video is gone. roud:
> 
> I tried using the same function for each probe but that didn't work out so I'm using the function 3 times and doing this I still saved 916 bytes, imagine if I knew what I was doing.


Are you using the same pin or different? If the same pin, you'll have to find the address of each sensor and plug it manually into the variable addr[] each time and get rid of that search part.

If different pins, make sure to change the pin definition.

Oh! Maybe that's why man is having glitches. You guys are running of of flash memory. Check on you sram too. 


Sent from my iPad using Tapatalk HD


----------



## robsworld78 (Aug 14, 2014)

I was using the same pin but didn't like that because of the address issue. Could see a lot of questions comng about that one.  That's why I was wondering how you were doing it because the dallas library would have taken forever to poll each probe if on different pins. If there was nothing else I was going to add that scan sketch so addressing could be done in the GUI. Of course this is much better. So now I'm running on 3 pins, 47, 48, 49 because they are easy to access. 

For memory as I understand it, the flash is only for storage unless you specially use it for SRAM. So it doesn't matter how full flash gets. With SRAM I start running into trouble after I get over 75%, small glitches appear. Anything under 75% is stable for me. I purposely made lots of variables global so that memory can always be allocated to it and not cause the cheese block, I read about that and was worried. If the variable was only for that function I went local. Not sure if that's the correct way or if I'll do it that way again but made sense to me at the time. You obviously know more about this stuff, what do you think is the best way?

I'm using IDE 1.6.0 which is superior to 1.0.6 when it comes to compiling. Just the switch I saved something like 20,000 bytes of flash and quite a bit of SRAM. But some sketches won't work with it, I just tried to compile iAqua and it hangs on IRSend, so I guess that's why 1.6.0 is beta, it was the nightly build about a month ago. You can have both versions running at the same time though. 

iAqua uses about 40% of flash and probably 60% SRAM so I don't think that's the problem with kman, but I guess its possible. I would think others would have had issues as well by now. I don't know his issue is odd.


----------



## mistergreen (Dec 9, 2006)

Ah, good to know oneWire on multiple pins run well.


----------



## mistergreen (Dec 9, 2006)

Give this oneWire function a try.


```
#include <OneWire.h> 

void setup() {
  Serial.begin(9600);
}

void loop() {
 //different pins
 float temp1 = pollOneWire(3);
 Serial.println(temp1);
 
 float temp2 = pollOneWire(47);
 Serial.println(temp2);
 
 float temp3 = pollOneWire(48);
 Serial.println(temp3);
 
 float temp4 = pollOneWire(48);
 Serial.println(temp4);
 
 
 delay(100); //just here to slow down the output so it is easier to read
 
}


float pollOneWire(uint8_t pin) {
 
 OneWire ds(pin); 
 byte data[12];
 byte addr[8];

 if ( !ds.search(addr)) {
   //no more sensors on chain, reset search
   ds.reset_search();
   return -1000;
 }

 if ( OneWire::crc8( addr, 7) != addr[7]) {
   Serial.println("CRC is not valid!");
   return -1000;
 }

 if ( addr[0] != 0x10 && addr[0] != 0x28) {
   Serial.print("Device is not recognized");
   return -1000;
 }

 ds.reset();
 ds.select(addr);
 ds.write(0x44,1); // start conversion, with parasite power on at the end

 byte present = ds.reset();
 ds.select(addr);  
 ds.write(0xBE); // Read Scratchpad

 
 for (int i = 0; i < 9; i++) { // we need 9 bytes
  data[i] = ds.read();
 }
 
 ds.reset_search();
 
 byte MSB = data[1];
 byte LSB = data[0];

 float tempRead = ((MSB << 8) | LSB); //using two's compliment
 float TemperatureSum = tempRead / 16;
 
 return TemperatureSum; 
 
}
```


----------



## robsworld78 (Aug 14, 2014)

Thanks, that's what I was trying to do, damm I was so close. I left the OneWire ds(pin); as global and had the ds switching.


----------



## mistergreen (Dec 9, 2006)

Also if you want to use one pin, find the device's address and do this


```
#include <OneWire.h> 
//find their addresses
byte address1[] = {1,2,3,4,5,6,7,8};
byte address2[] = {1,2,3,4,5,6,7,8};
byte address3[] = {1,2,3,4,5,6,7,8};
byte address4[] = {1,2,3,4,5,6,7,8};

void setup() {
  Serial.begin(9600);
  OneWire ds(2); 
}

void loop() {
 //different pins
 float temp1 = pollOneWire(address1);
 Serial.println(temp1);
 
 float temp2 = pollOneWire(address2);
 Serial.println(temp2);
 
 float temp3 = pollOneWire(address3);
 Serial.println(temp3);
 
 float temp4 = pollOneWire(address4);
 Serial.println(temp4);
 
 
 delay(100); //just here to slow down the output so it is easier to read
 
}


float pollOneWire(byte *addr) {
 
 byte data[12];
 
 if ( OneWire::crc8( addr, 7) != addr[7]) {
   Serial.println("CRC is not valid!");
   return -1000;
 }

 if ( addr[0] != 0x10 && addr[0] != 0x28) {
   Serial.print("Device is not recognized");
   return -1000;
 }

 ds.reset();
 ds.select(addr);
 ds.write(0x44,1); // start conversion, with parasite power on at the end

 byte present = ds.reset();
 ds.select(addr);  
 ds.write(0xBE); // Read Scratchpad

 
 for (int i = 0; i < 9; i++) { // we need 9 bytes
  data[i] = ds.read();
 }

 
 byte MSB = data[1];
 byte LSB = data[0];

 float tempRead = ((MSB << 8) | LSB); //using two's compliment
 float TemperatureSum = tempRead / 16;
 
 return TemperatureSum; 
 
}
```
Hope that compiles.


----------



## robsworld78 (Aug 14, 2014)

I'm going to stick with the 3 pins, I've already changed the hardware and have more than enough pins. Can't image it would be any faster with one pin so no point.


----------



## mistergreen (Dec 9, 2006)

I'm going with to the Arduino due. I'm seeing that sram number getting smaller with my new analog component. It took up 1000bytes. I wanted to use a formula algorithm and I guess it's taking up a butt load of memory.

I hope going from 5v to 3.3V isn't a problem with the hardware.


----------



## robsworld78 (Aug 14, 2014)

Nice, that will speed things up too if you need that. I think you need different temp probes and RTC, plus other things you have might not work. I was going to switch a while ago but I have to much 5v hardware.


----------



## mistergreen (Dec 9, 2006)

Is there some sort of 3.3V to 5V converter component?


----------



## renesis (Dec 4, 2014)

mistergreen said:


> Is there some sort of 3.3V to 5V converter component?


Yes, there are logic level converters, lots of them out there, here's one from adafruit on a breakout.

http://www.adafruit.com/products/395

I'm using a DUE for my aquarium project, and so far I've been okay running off 3.3V for most items. Need to work around some things, but there is a 5V output on the board too. Just can't ever input more than 3.3 into any pin or you will fry the SAM3X really quickly.


----------



## mistergreen (Dec 9, 2006)

renesis said:


> Yes, there are logic level converters, lots of them out there, here's one from adafruit on a breakout.
> 
> http://www.adafruit.com/products/395
> 
> I'm using a DUE for my aquarium project, and so far I've been okay running off 3.3V for most items. Need to work around some things, but there is a 5V output on the board too. Just can't ever input more than 3.3 into any pin or you will fry the SAM3X really quickly.


cool, thanks. I was just on adafruit ready to buy a due. The 8 channel is out of stock but the 4 channel is available.


----------



## renesis (Dec 4, 2014)

Keep in mind there is no on-board eeprom on the DUE, so if you need that - you will need to add that on.


----------



## mistergreen (Dec 9, 2006)

renesis said:


> Keep in mind there is no on-board eeprom on the DUE, so if you need that - you will need to add that on.


Ok, I was going to write backup onto the sd card or maybe even send it online to a mysql database whichever is easier.


----------



## zerodameaon (Dec 2, 2014)

I am considering trying this on my MangoCube WiFi, its more or less a Leo with a built in wifi shield so it could work.


I forgot to add something, take a look at this. Have your arduino microcontroller running all the sensors and such and but have the workhorse of the PI2 connected to run stuff like streaming.
https://www.kickstarter.com/projects/raspitv/raspio-duino-affordable-arduino-programming-on-ras


----------



## mistergreen (Dec 9, 2006)

That is a pretty nifty shield for the PI.


----------



## mistergreen (Dec 9, 2006)

I've successfully converted over to the Due and added a new component.
Check it out.

http://youtu.be/EAeEhsXXi_Y


----------



## robsworld78 (Aug 14, 2014)

So how does installation work?

Is there much to putting it online for a new user. Would someone simply plug into the internet and go to a specific website? Does everyone go to the same address or does a user have to go though setting up a local network on there own machine? Is it a process or a couple clicks?


----------



## mistergreen (Dec 9, 2006)

The arduino IS the web server. All you need is internet connection (ethernet) at your house.
So then in your browser from any machine in your network, you go to that local IP address, 192.168.1.177 as defined by the arduino.

If you want to browse the website from the WWW (anywhere), you'll need to port forward that local IP on your router, port 80. Your IP network, arduino website, will then be public IP to the world. To find that out that public IP, go here: 
http://www.iplocation.net
This is what your ISP gives you. It could change from time to time unless you got the static IP plan from your ISP. You can also buy a domain and point that domain to your public IP.


----------



## jeffkrol (Jun 5, 2013)

mistergreen said:


> The arduino IS the web server. All you need is internet connection (ethernet) at your house.
> So then in your browser from any machine in your network, you go to that local IP address, 192.168.1.177 as defined by the arduino.
> 
> If you want to browse the website from the WWW (anywhere), you'll need to port forward that local IP on your router, port 80. Your IP network, arduino website, will then be public IP to the world. To find that out that public IP, go here:
> ...


It sounds soo easy.. 
Not to mention opening up a hole in your firewall.. 

(Forgive the somewhat naive comments)...


----------



## mistergreen (Dec 9, 2006)

Port forwarding technically isn't a hole in the firewall. The hole if there is one, is the machine at the end of the IP of the port forward. I dare anyone to hack ardunio binary of my design! There's very little risk of intrusions.
If it was a Windows machine, yes it's definitely a hole 

I can make the arduino a little harder to find by using another port if you're not going to use a domain name; like port 6789.


----------



## robsworld78 (Aug 14, 2014)

So the arduino address is 192.168.1.177?

Everyone forwards the same 192.168.1.177 on there router?

Then if I'm at a computer not on my network I still type 192.168.1.177 in the browser and it will work or would I type my IP address?

I just ordered an ethernet shield and trying to figure out how this all works. Do you know of any good tutorials? What I've found are only so so.


----------



## mistergreen (Dec 9, 2006)

Yes, in my code, I told the Arduino to use the IP 192.168.1.177.
Only use that IP in your network. 
Everyone outside your network will have to use the IP provided by your ISP but you'll have to port forward 192.168.1.177 and use port 80. I'm think of changing the port to some random number so it's harder for people to find like 192.168.1.177:6789 (local), or 82.123.2.123:6789 (public). The colon and 4 digits are the port. You don't need to type :80 because that's the standard web port.

Port forwarding is really easy if you set up your network's password. It's a link in the router's web page. I can make a video of it and you say, "oh, that was easy."


This tutorial is good to get started on connecting your arduino to the web.
http://startingelectronics.com/tutorials/arduino/ethernet-shield-web-server-tutorial/


----------



## robsworld78 (Aug 14, 2014)

So if shaw changed my IP I wouldn't have access till I knew my new IP address? If true than a permanent IP would fix it or is there a free solution?

Right now when I type my IP in chrome it says page unavailable but if I had the arduino forwarded to that IP I would get whatever was on there? 

I need to get a router, right now I just plug into the modem. I can probably figure out the port forwarding if its on the router page.


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> So if shaw changed my IP I wouldn't have access till I knew my new IP address? If true than a permanent IP would fix it or is there a free solution?


yup, some ISP don't change the IP at all so it depends on the ISP.
A static/permanent IP would fix this. There used to be a free solution by signing up for a domain name that looks at your dynamic IP but they're not free anymore so it's not worth it.



robsworld78 said:


> Right now when I type my IP in chrome it says page unavailable but if I had the arduino forwarded to that IP I would get whatever was on there?


Yes, There's nothing there so you get an unavailable page.


If you don't need all that coding, you can use the Arduino Yun. It's a web server and internet connection built in so you can return the ethernet shield. It doesn't have a lot of memory or that many pins but might fit your needs. It has serial pins


----------



## robsworld78 (Aug 14, 2014)

Ok that part seems straightforward.

Ah the yun, you mentioned that board earlier to me and I thought that was what I ordered. :hihi: I just looked them up and $117 complete or $40 as a shield for a uno, that's to much. I can build one for $30 with the ethernet shield.

To start I need to keep this really simple so all I want is a single page with a bunch of on/off switches for each relay and the ability to see all the info on the home screen.

EDIT: I do see some cheaper ones now but still pretty expensive.


----------



## kman (Dec 11, 2013)

There are still free dynamic IP services, but they definitely make it more annoying to use the free service all the time. 

I use noip.com to access my home devices from the road.


----------



## mistergreen (Dec 9, 2006)

kman said:


> There are still free dynamic IP services, but they definitely make it more annoying to use the free service all the time.
> 
> I use noip.com to access my home devices from the road.


$20/year is not bad. You don't have to deal with ads and such. Cheaper than a static ip & domain name.


Sent from my iPad using Tapatalk HD


----------



## kman (Dec 11, 2013)

mistergreen said:


> $20/year is not bad. You don't have to deal with ads and such. Cheaper than a static ip & domain name.


I have many domain names, it's the static IP I don't want to pay for, just so I can remote into my home systems for a file on occasion.

I wish LogMeIn Free was still around. 

But noip.com is totally free. You just have to "confirm" that you still want the account, every freaking month. They send an email to confirm that you have to respond to within 5 days or they dump your account. But it seriously takes about 30 seconds once per month, and all is well. (click the link, fulfill the captcha, and done) 

I miss DynDns though.


----------



## mistergreen (Dec 9, 2006)

Yeah dyndns was cool. I read on no ip, the free account redirects you to ads? Maybe you don't notice it.

I'll give the free account a run for the arduino and see.


Sent from my iPad using Tapatalk HD


----------



## robsworld78 (Aug 14, 2014)

Could a script run on the computer once a day checking if the IP changed and if it did email the new address? Then if you went to log into your IP and it changed you could get the new one without being at the computer.


----------



## kman (Dec 11, 2013)

mistergreen said:


> Yeah dyndns was cool. I read on no ip, the free account redirects you to ads? Maybe you don't notice it.
> 
> I'll give the free account a run for the arduino and see.


Not that I've heard of, but then, I'm not running a web server (and if I was it wouldn't be on port 80 or any common variant). I use software with proprietary tunneling protocols directly to my home machines, so I don't see how ads could become involved in any way.

Bump:


robsworld78 said:


> Could a script run on the computer once a day checking if the IP changed and if it did email the new address? Then if you went to log into your IP and it changed you could get the new one without being at the computer.


Yes, that would work, although it's not going to help you if you're only checking once per day and the IP changed 5 minutes after the script run, if you need access ASAP.


----------



## mistergreen (Dec 9, 2006)

I noticed my ISP changes the ip every 3 months or so. 5 minutes sound pretty fast. I start a minecraft server for my nephew and I to play and I go through the process of port forwarding for that.

That's pretty smart to have a computer notify you of the ip. That's what the noip site does. It has an app on your computer and updates you ip to their server every so often.

Hmm. I wonder if the arduino can do this also. I'll look into it.


Sent from my iPad using Tapatalk HD


----------



## sehekuwe (Feb 17, 2015)

mistergreen said:


> That's pretty smart to have a computer notify you of the ip. That's what the noip site does. It has an app on your computer and updates you ip to their server every so often.
> 
> Hmm. I wonder if the arduino can do this also. I'll look into it.


In doing a quick search of the internet here is a possible starting point for an arduino to check its external IP address...just a thought.

http://hackaday.io/project/2495-external-ip-address-tracker


----------



## mistergreen (Dec 9, 2006)

sehekuwe said:


> In doing a quick search of the internet here is a possible starting point for an arduino to check its external IP address...just a thought.
> 
> http://hackaday.io/project/2495-external-ip-address-tracker


Thanks for the link! I found something similar.

It looks like I will have to change the web server port to something besides 80. Some ISP will block this because they want you to buy a static IP and business account with them.

Ok, so emailing you your IP when it changes is the simplest solution and no need for a third party like noip. It's all done through the arduino.


----------



## kman (Dec 11, 2013)

mistergreen said:


> Thanks for the link! I found something similar.
> 
> It looks like I will have to change the web server port to something besides 80. Some ISP will block this because they want you to buy a static IP and business account with them.
> 
> Ok, so emailing you your IP when it changes is the simplest solution and no need for a third party like noip. It's all done through the arduino.


Sending email through the Arduino is non-trivial these days, since most ISPs require secure connections and authentication to avoid spammers who have taken over residential PCs.

I have seen ISPs that change the IP every 5-15 minutes, but the concern I originally described was more of what happens is the IP changes daily but at a non-fixed time? Then you don't know whether you'll emailing the new IP or the old IP and can easily be trapped many hours on the wrong side of a change.


----------



## mistergreen (Dec 9, 2006)

kman said:


> Sending email through the Arduino is non-trivial these days, since most ISPs require secure connections and authentication to avoid spammers who have taken over residential PCs.


Yup, I figured this out. I can send email via a php script on my server. I can have this publicly available for this app. Also I just noticed a base64 encryption for smtp user&pass. I'll have to test that out for the arduino. I'll have options on what they want to use.

I'll have the arduino check people's IP every 5 hours. Maybe I'll let them have options to use DDNS & static IP too. NoIP has an API where the arduino can be the Dynamic DNS Update Client (DUC).


----------



## robsworld78 (Aug 14, 2014)

If you get it going send me the script. :hihi: :hihi:


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> If you get it going send me the script. :hihi: :hihi:


Will do. I got the arduino to email via smtp, just like how you would set up outgoing mail on outlook or mail.


----------



## robsworld78 (Aug 14, 2014)

Nice, I wish I had your skills. :hihi: Its the server stuff that scares me, I've done very little networking so most is foreign to me. :confused1:


----------



## robsworld78 (Aug 14, 2014)

What are you doing about an eeprom for the DUE?


----------



## mistergreen (Dec 9, 2006)

My setup is too complicated and large so I never planned on using eeprom. I was going to write down setting on the sd card. I read EEPROM is volatile if you rewrite over it too much which I can see it happening when changing settings.

I'm sure you can use an eeprom breakout pretty easily. Oh, don't forget you can use a bi-directional logic converter if you need to use 5V devices on the Due and no need to change libraries.


----------



## robsworld78 (Aug 14, 2014)

Yeah apparently the eeprom is good for 100,000 writes and unlimited reads. It would take a very long time to get to 100,000, I'm not worried about it. I've changed settings on mine worth more than a lifetime and its still working. :hihi:

I found this tutorial, I think I'm going to give it a try, looks like it works like the eeprom library. The eeprom is $1.25

http://www.instructables.com/id/Adding-an-24LC256-EEPROM-to-the-Arduino-Due/?ALLSTEPS

I think I'm going to give it a try, the mega can still run the sensors and equipment.


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Yeah apparently the eeprom is good for 100,000 writes and unlimited reads. It would take a very long time to get to 100,000, I'm not worried about it. I've changed settings on mine worth more than a lifetime and its still working. :hihi:
> 
> I found this tutorial, I think I'm going to give it a try, looks like it works like the eeprom library. The eeprom is $1.25
> 
> ...


100,000 writes? Nice. The guys over at arduino forum are too paranoid. I guess they're thinking long term application, although our controllers can run for years.

I saw that i2c eeprom last night. 256K, all the storage you'll need!


----------



## robsworld78 (Aug 14, 2014)

Yeah I'm not worried, something better will come along before the eeprom dies. :hihi:


----------



## saiko (Mar 30, 2007)

so, are you trying something like this?
http://forum.arduino.cc/index.php?topic=142033.msg1075637#msg1075637


This next one, is still simpler though(not sure you want to use something external), but when I used and queried for IP multiple times in a day, it dint load page well, may be they limit the number of hits from an IP-IDK
http://forum.arduino.cc/index.php?topic=142033.msg1070763#msg1070763

Let us know how you crack it...


----------



## renesis (Dec 4, 2014)

100k write cycles on the atmega eeproms is extremely conservative too.

This experiment: http://tronixstuff.com/2011/05/11/discovering-arduinos-internal-eeprom-lifespan/

1,230,163 complete (10101010 to 01010101) write cycles before its first error.


----------



## mistergreen (Dec 9, 2006)

saiko said:


> so, are you trying something like this?
> http://forum.arduino.cc/index.php?topic=142033.msg1075637#msg1075637
> 
> 
> ...


Yeah, I'm getting my IP from checkip.dyndns.com. It does time out if you load it too soon but a few minutes apart works fine for me. I'm still working to send the ip to no-ip. BTW, if you have your own web serve (php), you can get your own IP with $_SERVER['REMOTE_ADDR']. No limitations except your bandwidth. I'm not using my web server because I can see multiple controllers killing my server unless I upgrade to something beefier. In my controller, I do give an option for people to change checkip.dyndns.com to something else though.

**** update ****
I'm getting timed out on checkip.dyndns.com once in a while too. I'm creating my own checkip for testing purposes.



renesis said:


> 100k write cycles on the atmega eeproms is extremely conservative too.
> 
> This experiment: http://tronixstuff.com/2011/05/11/discovering-arduinos-internal-eeprom-lifespan/
> 
> 1,230,163 complete (10101010 to 01010101) write cycles before its first error.


Hmm, I might use eeprom if this sd card is too complicated.


----------



## mistergreen (Dec 9, 2006)

If you guys want to do a simple HTTP Authorization login, I just made a tutorial for it.

http://youtu.be/FOyQWgwXccA


----------



## saiko (Mar 30, 2007)

mistergreen said:


> I do give an option for people to change checkip.dyndns.com to something else though.
> 
> **** update ****
> I'm getting timed out on checkip.dyndns.com once in a while too. I'm creating my own checkip for testing purposes.


yep thats the problem.:confused1:
I am hoping there is one another site that doesnt block on regular use- 'google'. I tried parsing the IP from it, but am quite a noob when it comes to web stuff. May be you can take a jab at it?

Secondly, may be you can use a different service to find your IP when ever your IP changes. Something like
1st change- use checkip.dyndns.com 
2nd change- use np-ip
3rd change- use someother. etc
Thats something that comes to mind.


----------



## robsworld78 (Aug 14, 2014)

Right on, thanks!

EDIT: I thought you were making a script that goes on the arduino to check the IP? I thought you wouldn't need no-ip or a service like that?


----------



## mistergreen (Dec 9, 2006)

saiko said:


> yep thats the problem.:confused1:
> I am hoping there is one another site that doesnt block on regular use- 'google'. I tried parsing the IP from it, but am quite a noob when it comes to web stuff. May be you can take a jab at it?
> 
> Secondly, may be you can use a different service to find your IP when ever your IP changes. Something like
> ...


I checked, checkip.dynds.com doesn't block people. It loads really slow,I guess because so many people are using it. I think that's the cause of the the timeouts.

We need a site that gives us a line of text format 'Address: 123.123.4.123'. I think Google gives us a whole webpage for the ip. Too much memory for the arduino.

Sent from my iPad using Tapatalk HD


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Right on, thanks!
> 
> EDIT: I thought you were making a script that goes on the arduino to check the IP? I thought you wouldn't need no-ip or a service like that?


To check the ip the arduino need to call an external script but I've made options for people to either get that ip emailed to them or have the arduino send that ip to no-ip.


Sent from my iPad using Tapatalk HD


----------



## mistergreen (Dec 9, 2006)

saiko said:


> yep thats the problem.:confused1:
> I am hoping there is one another site that doesnt block on regular use- 'google'. I tried parsing the IP from it, but am quite a noob when it comes to web stuff. May be you can take a jab at it?
> 
> Secondly, may be you can use a different service to find your IP when ever your IP changes. Something like
> ...


Hey, I just found out that if you use noip you don't need to have an extra script to check your IP. Noip does it for you when you connect to their update server.
Something like this.

```
if (client.connect("dynupdate.no-ip.com", 80)) {
    Serial.println("connected");
    client.println("GET /nic/update?hostname=hostname HTTP/1.0");
    client.println("Host: dynupdate.no-ip.com");
    client.println("Authorization: Basic userpassbase64"); 
    client.println("User-Agent: Arduino Sketch/1.0 email");

    client.println();
  } 
  else 
  {
    Serial.println(client.connect("dynupdate.no-ip.com", 80));
    Serial.println("failed");
  }
```
It seems like you can only call this every 1-2 hours. If you call too often, you'll timeout.


----------



## saiko (Mar 30, 2007)

Yep! I had used a similar one,if you dont want the email way, just ping the domain you registered with the api. I am unable to get that thread that I used.

But thats like limited to 5 changes per day, or has it changed?


----------



## saiko (Mar 30, 2007)

And yes thats same issue with being unable to ping again in short span(I was calling this as blocking in my prev post, not good with web terms my bad)

So, there are few other ways too.
http://www.ferduino.com/forum/viewforum.php?f=26
http://forum.reefangel.com/viewtopic.php?f=20&t=4753

Is there a way you could put your php code somewhere on web and call it to get the IP?


----------



## mistergreen (Dec 9, 2006)

I don't know about the change limit but there seems to be a time limit.

I was thinking, if your ip is switching every 30 minutes, you should find another method, like running their DUC app on your computer. Leave it on 24/7. Pinging external server from the arduino does take a toll in processing other things. There are while loops that may interfere with timed events.

Sent from my iPad using Tapatalk HD


----------



## saiko (Mar 30, 2007)

hey, this one looks promising, I think you should crack it now
http://www.ipify.org/


----------



## mistergreen (Dec 9, 2006)

saiko said:


> hey, this one looks promising, I think you should crack it now
> http://www.ipify.org/


Good find!


Sent from my iPad using Tapatalk HD


----------



## mistergreen (Dec 9, 2006)

saiko said:


> hey, this one looks promising, I think you should crack it now
> http://www.ipify.org/


How often does your ip change btw? Read my added comments 2 posts back.


Sent from my iPad using Tapatalk HD


----------



## saiko (Mar 30, 2007)

yes I missed reading that, as I was posting without a refresh.

Well, I havent checked how many times the internet service changes my IP in a day, I really dint do this check. But from many untimely powercuts might just mean changes more.
I cant try run a computer with this state, a second uno on ethernet might be better, as I havent yet started my build. So uno does the net stuff, mega does controlling and timing-IDK, just my thoughts yet.

And sorry, ignore the 5time limit thing on IP change, I recollect thats not related to the case here, it was the 20mail per day limit from smtp2go.


----------



## mistergreen (Dec 9, 2006)

yeah, I thought about 2 arduino as well.
But I'll try running it all on the Due to see. I can grab the IP on api.ipify.org and it's pretty reliable with no timeouts. I'm having trouble with my email function at the moment. It freezes all the code for some reason.


----------



## saiko (Mar 30, 2007)

is it the smtp2go that you are using? if you can show the code. Becase when I tried it a year back, I dont remember to have faced any issue.

I havent used due, but I guess its much powerful than my mega. So you might want to have some timer-interrupt routine and do the check and nested timer-routine to exit out of the function to avoid getting stuck.

Bump: BTW I must tell you, I really like the UI you have!

Bump: I have another idea for you, you could use google.sites to show your ip on the home page and you can access the page easily as you d remember the name, something like https://sites.google.com/site/mistergreen. Instead of sending an email, you could update a google spreadsheet with form and embedd the latest updated IP on your page


----------



## mistergreen (Dec 9, 2006)

I decided to get rid of SMTP all together. It only works with some mail servers but not most because of authentication. I'm calling a php script on my commercial web server that uses sendmail. That is 100% working. I'm building the html interface now and decide to add some features.


Sent from my iPad using Tapatalk HD


----------



## saiko (Mar 30, 2007)

So , need some opinion here.
Did your shift from mega to due have any benefits on speed of web page loading? Not functionality, but anything else that's more quick now post due migration?


----------



## mistergreen (Dec 9, 2006)

saiko said:


> So , need some opinion here.
> Did your shift from mega to due have any benefits on speed of web page loading? Not functionality, but anything else that's more quick now post due migration?


Speed and lots more sram but mainly more memory was my reason. Yeah, webpage loads faster.

Also some cool sensors are 3.3v now so that makes it easier.


Sent from my iPad using Tapatalk HD


----------



## saiko (Mar 30, 2007)

Thanks a lot for the assurance. I ll try replace mine too then.

BTW is yours the regular ethernet shield or something due specific? Sorry if you already posted it some where along. 

....and what are those new cool sensors?


----------



## mistergreen (Dec 9, 2006)

Same ethernet shield will work on the due. There is a 5V pin on the due. It's dangerous if you don't know what you're doing but it will power 5V devices. Just don't let any 5V go back into the due in any way or you'll fry the chip.

I have a 3.3v analog thermometer that's .1°F accuracy, pretty darn good for $2. pH sensor, humidity, etc... If it's not 3.3v you can always use a logic converter. It's pretty easy.


----------



## mistergreen (Dec 9, 2006)

Dynamic IP completed!

http://youtu.be/g4JLciDRdLA


----------



## rottison (Aug 28, 2014)

cool video mistergreen


----------



## mistergreen (Dec 9, 2006)

rottison said:


> cool video mistergreen


Thanks.


Sent from my iPad using Tapatalk HD


----------



## saiko (Mar 30, 2007)

Cool stuff as usual!!

So whats pending on it now?


----------



## mistergreen (Dec 9, 2006)

saiko said:


> Cool stuff as usual!!
> 
> So whats pending on it now?


I have a few more widgets I'd like to make. I decided to use the term widgets for the components like alerts, video, etc... I'd like to do a ph widget, and a simple digital input.

And finally testing it. Running it full time. Oh, I need to work out how to backup settings too.



Sent from my iPad using Tapatalk HD


----------



## jeffkrol (Jun 5, 2013)

mistergreen said:


> I have a few more widgets I'd like to make. I decided to use the term widgets for the components like alerts, video, etc... I'd like to do a ph widget, and a simple digital input.
> 
> And finally testing it. Running it full time.
> 
> ...



how about a PAR widget..


----------



## mistergreen (Dec 9, 2006)

jeffkrol said:


> how about a PAR widget..


That should work with the analog input widget I created a few weeks back. You enter in the formula to transform analog signal and you'd get PAR data. I'm thinking ahead


----------



## mistergreen (Dec 9, 2006)

I found 2 low resistance flow sensors for you guys to play with.

http://www.seeedstudio.com/depot/G12-Water-Flow-Sensor-Enclosure-p-1915.html
USD
$9.50
There should be little resistance with this as it has a rotor that spins with the flow of the water freely and the rate of the rotor is measured with a Hall Effect sensor (electromagnetic field).


http://www.swissflow.com/sf800.html
$60 USD
3/8” hose barb; 3/8”BSP Male
This uses a rotor as well and uses an infrared to sense the rotor's rotation so it should have little resistance.


----------



## mistergreen (Dec 9, 2006)

The flow sensors above gave me an idea. I was going to do a simple digital input widget that reads high or low for buttons & switches but those sensors send out digital pulses so my simple digital widget will need to read pulses / frequencies too. It will then transform that to a meaningful value like liters/minute.

The arduino has a pulseIn() function that I can use.


Sent from my iPad using Tapatalk HD


----------



## mistergreen (Dec 9, 2006)

The cheap $10 chinese flow sensor arrived. There's very little resistance. I can blow air into it and it'll spin. I can see it getting clogged with a stray piece of moss though so make them accessible for cleaning.

Now to code this. There very little documentation so it'll be interesting.


----------



## robsworld78 (Aug 14, 2014)

Nice, I'm going to get myself one of those soon. Didn't like the idea of the $60 one.  Doesn't this go after the filter? Wouldn't the filter catch that stray piece of moss?


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Nice, I'm going to get myself one of those soon. Didn't like the idea of the $60 one.  Doesn't this go after the filter? Wouldn't the filter catch that stray piece of moss?


The $60 one is really accurate . 

You can get the Chinese one for $5 straight from China but shipping and time is an issue.

You never know what goes past the filter. I turned on my filter last night and mulm comes shooting out. Time for a cleaning


----------



## robsworld78 (Aug 14, 2014)

I was thinking about this one.

http://www.banggood.com/Hall-Water-Flow-Sensor-Flowmeter-Water-Control-1-30L-or-min-2_0MPa-p-80747.html

Sounds like you've been to busy working on your controller. :hihi:


----------



## mistergreen (Dec 9, 2006)

That might work. It's by the same company. My sensor's rotor configuration is more compact and different from that one just by looking at the shape of that sensor.

Oh, and mine's clear so I can just see if it's clogged.


----------



## robsworld78 (Aug 14, 2014)

Yeah I'll probably just get the one you have. This way its been verified it works. Looking forward to seeing it in action. This is something I really want, I love that kind of data.


----------



## mistergreen (Dec 9, 2006)

I got the sensor to output by blowing into it although I'm not sure I'm getting L/minute or L/hour. Wish I could test it somehow. I guess I won't know until I hook it up to a filter since I know what generally the output of a filter is.


----------



## kman (Dec 11, 2013)

mistergreen said:


> I got the sensor to output by blowing into it although I'm not sure I'm getting L/minute or L/hour. Wish I could test it somehow. I guess I won't know until I hook it up to a filter since I know what generally the output of a filter is.


Unless you have some serious testing equipment, I doubt you _actually_ know the true output of a filter, since every manufacturer lies in different ways! Although I guess you could test it into a bucket (do you have a calibrated bucket? I hear the average Home Depot 5 gal bucket is actually something like 5.7 gals so that's not a reliable measure) and do the math to determine output.

But what might be handier is a relative scale: Someone could clean their filter and run it full bore, and set that to 100%. If they later see their filter output dropping over time towards 50% as it gets dirty (or something goes wrong), they know it's time to clean or service it. And of course an alarm could be set at any given threshold (80%, etc).

Just spitballing a few ideas.


----------



## mistergreen (Dec 9, 2006)

Oh, testing the filter into a bucket is a good idea. Will do that. 
I'm going to attach an LCD onto a spare mega and do some testing. I'll run it with and without the sensor to see it there is a reduction in flow if any.


----------



## mistergreen (Dec 9, 2006)

code if you're interested.

```
unsigned long duration;

void setup() {
  Serial.begin(9600);
  pinMode(7, INPUT);
}

void loop() {
  duration = pulseIn(7, HIGH);
  Serial.print(1000000UL/duration*60/5.0);
  Serial.println(" L/min");
  
}
```


----------



## robsworld78 (Aug 14, 2014)

That must have taken you a while to write. :hihi:


----------



## mistergreen (Dec 9, 2006)

A more accurate/correct one is using interrupts. On an atmega, you can only run one interrupt at a time. Does anybody know if you can run multiples at the same time on Due?


```
volatile int count = 0;                       // measuring the rising edges of the signal, volatile
int Calc;
int hallsensor = 7;                           // The pin location of the sensor
unsigned long lastRead = 0;
 
void rpm ()                                   // This is the function that the interupt calls
{
    count++;                              // This function measures the rising and falling edge of the hall effect sensors signal
}
 
 
void setup()
{
    pinMode(hallsensor, INPUT);               // initializes digital pin 2 as an input
    Serial.begin(9600);                       // This is the setup function where the serial port is initialised,
    attachInterrupt(hallsensor, rpm, RISING);          // and the interrupt is attached to pin (Due only)
}
 
 
void loop ()
{

  
   if (millis() - lastRead >=1000) //read interrupt count every second
    {
      lastRead = millis();
      
      noInterrupts(); // disable interrupts for correct calculation
      Calc = (count / 5.0);  //counts per second = Hz; divide by 5 for Flow rate l/min     
      //Serial.println(count);
      Serial.print (Calc, DEC);                 
      Serial.print (" L/minute\r\n");             
      count = 0; // reset for next calc
      interrupts(); //start interrupt back up

    }
 
   
}
```


----------



## saiko (Mar 30, 2007)

By same time do you mean the functions running concurrently? I dont think so.
But you can declare an interrupt for each pin on your due, so thats quite many.



> If your sketch uses multiple ISRs, only one can run at a time, other interrupts will be ignored (turned off) until the current one is finished.


So it more of sequential execution.
http://arduino.cc/en/Reference/AttachInterrupt


----------



## mistergreen (Dec 9, 2006)

Yeah, that's what I'm seeing in my research. These aren't full computers where they can use threading. One instruction at a time really fast.


Sent from my iPad using Tapatalk HD


----------



## mattinmd (Aug 16, 2014)

The Arm family is capable of doing multiprocessing, but not the small members like the Cortex M3 used on the Due. 
That's more along the lines of the bigger arm members used in Android tablets, etc. ie: the Galaxy Tab S with its 4+4 core 

The main differences between the cortex and the AVR lies in being a 32-bit CPU, vs an 8-bit one... It's a big step up in power, but not concurrent.

Your best bet is to try to keep all your interrupts as short and simple as possible, allowing them all to be serviced quickly.

Also in your earlier code, I'd consider computing Calc, reseting count and re-enabling interrupts before doing the serial printing. The less time you keep interrupts disabled, generally the better...


----------



## mistergreen (Dec 9, 2006)

Thanks for the tip.


Sent from my iPad using Tapatalk HD


----------



## mistergreen (Dec 9, 2006)

I've hooked up an LCD and the flow sensor to my spare mega. I'm ready for field testing except I'll need to buy hose barb fittings for the sensor. I stopped by Home Depot and Lowes and they don't carry any. They used to...

So I measure the ID of the sensor, it's 3/4" not 1/2" like in the link. So I'll check use usplastics for 3/4" female NPT to 3/4" hose barb.. They have some cheap PVC fittings.


----------



## renesis (Dec 4, 2014)

mistergreen said:


> So I measure the ID of the sensor, it's 3/4" not 1/2" like in the link. So I'll check use usplastics for 3/4" female NPT to 3/4" hose barb.. They have some cheap PVC fittings.


Keep in mind 1/2" NPT refers to the inner diameter. 1/2" NPT OD with the threads will be closer to 3/4", and a 3/4" NPT would be closer to 1" OD with threads.


----------



## mistergreen (Dec 9, 2006)

renesis said:


> Keep in mind 1/2" NPT refers to the inner diameter. 1/2" NPT OD with the threads will be closer to 3/4", and a 3/4" NPT would be closer to 1" OD with threads.


Just double checked, you're right. Good thing I did before wasting money.

[strike]So should I get 3/4" female NPT to 3/4" hose barb or
1/2" female NPT to 3/4" hose barb
adapter?[/strike]

This is where a physical hardware store is convenient.

oh, never mind. They have specs drawings of the parts. I'm getting 1/2" female NPT to 3/4" hose barb.


----------



## mistergreen (Dec 9, 2006)

Ready for field testing tomorrow. USplastics is only a few hundred miles away from me so I got the fittings the next day


----------



## robsworld78 (Aug 14, 2014)

Don't get that board wet. :hihi:


----------



## mistergreen (Dec 9, 2006)

robsworld78 said:


> Don't get that board wet. :hihi:


heh, I know! The connecting sensor wire is at least 4 feet. I'll cover it with saran wrap just in case. I'll be doing this outside or in the tub.


----------



## mistergreen (Dec 9, 2006)

Ok, so I took 2 readings on a small canister filter with no medium.

The sensor does limit output but only by 5-11%. While the filter was running, the arduino read anywhere from 9-12L/minute. It varies I'm not sure why; maybe that's how filters run but I'd have to account for margin of error on the sensor and my errors. It might be better if I took multiple readings and average them out instead of take a calculation ever second.

It's fairly accurate with actual numbers being 11.13 l/m, and 10.97 l/m. I used my iPhone as the stop watch.


----------



## saiko (Mar 30, 2007)

so, how did you measure the 5-11% fall in flow, just by two readings? fill the bucket method?


----------



## mistergreen (Dec 9, 2006)

Yes, I used 2 buckets. I measured the gallons with a one gallon milk jug. I measured for 5 gallons and 4 gallons and marked the levels with a marker.


Sent from my iPad using Tapatalk HD


----------



## saiko (Mar 30, 2007)

nice, so you ll do some more measurements before caliberating it?

So what next... an e-tape?


----------



## saiko (Mar 30, 2007)

hey! it just crossed my mind today...

why not connect it to a water tap and do the caliberations in your kitchen sink(unless home minister is fine with it) by taking multiple readings with multiple flow rate, then later directly add on to the filter with your extrapolated function.


----------



## mistergreen (Dec 9, 2006)

Hey, hooking it up to the faucet is a good idea. I made changes to the code to get the average over 10 seconds. I've been told that's for accurate results.


Sent from my iPad using Tapatalk HD


----------



## saiko (Mar 30, 2007)

knock! knock!
How about an update...


----------



## mistergreen (Dec 9, 2006)

Just waiting for the weather to get good to do more testing on the flow sensor. It looks like I can't do interupts with my Class framework. I'd have to use a STATIC method of the ISR which won't work for multiple instances. I'll have to use pulseIn().


----------



## mistergreen (Dec 9, 2006)

Do I dare dream of water change using a controller? 😃
http://www.adafruit.com/products/996

I saw this solenoid got me thinking. I've been soldering some pipes and thought it was easy enough. In coming water would go through a couple of house carbon filters at a slow rate to remove chlorine and temperature shock wouldn't be too bad.

Sent from my iPad using Tapatalk HD


----------



## kman (Dec 11, 2013)

^^ I know a guy who did it, so it's definitely possible.


----------



## saiko (Mar 30, 2007)

I think I know what will be your next fun gadget.

Tadaaaa...
http://www.adafruit.com/products/464


----------



## mistergreen (Dec 9, 2006)

saiko said:


> I think I know what will be your next fun gadget.
> 
> Tadaaaa...
> http://www.adafruit.com/products/464


Yeah, I've seen this and was planning on it 😃
I was wondering if there was a small etape for fertilizer containers.

Sent from my iPad using Tapatalk HD


----------



## saiko (Mar 30, 2007)

any progress here? : )


----------



## mistergreen (Dec 9, 2006)

sorry, no. Been busy with work. I've been finding new fun sensors though.

*
Also, I'm planning to add a logging and graphing function to whatever device you want. the data will to a mysql database.


----------



## Zaki (Jan 27, 2015)

Hello.. Anybody there.. ? .. 

This thread was a nice Read.. Any hope for Updates..

MisterGreen.. Guess you have a fully working project there.. 

Right.. ? I'm curious to look at things.. Cheers..


----------



## mistergreen (Dec 9, 2006)

Zaki said:


> Hello.. Anybody there.. ? ..
> 
> This thread was a nice Read.. Any hope for Updates..
> 
> ...


Yup, I want to redesign the interface but it works. I have several projects in the pipeline but unsure where this project will stand.


Sent from my iPad using Tapatalk HD


----------



## mistergreen (Dec 9, 2006)

I've posted the files onto github if you want to play with it.

https://github.com/mistergreen/WAAC


----------



## ugn (Mar 26, 2012)

Cool thread!

I'm doing a little project of my own, trying to control and measure some parameters with micro-controller.
Do you have any suggestions for measuring PH?

My current research tells me that the cheapest 'ok' solution is to buy one of these: https://www.sparkyswidgets.com/product/miniph/ and go with a cheap ebay probe.
Any suggestions? Will need to buy some calibration liquid and change out the probe from time to time.


----------



## mistergreen (Dec 9, 2006)

Yup, a pH sensor would be good. It could be used to control CO2.
Something like this https://www.sparkfun.com/products/12872

Yes, you need to calibrate all sensors once in a while since they tend to drift. You'll need to build/program some sort of interface for calibration as well.

Be aware that i2c interface only has a foot limit in how far the device can be away from the micro-controller. The data will degrade if farther.


----------



## ugn (Mar 26, 2012)

What wacky forum. Will not remember what you typed if you are not logged in OR have logged in after you started typing(?). Such wow.

Anyways, wrote a longer reply but that is gone. Thank you for input, will go for a cheaper route as this more for fun than something usefull


----------



## mistergreen (Dec 9, 2006)

So I got rid of the RTC for this server! It's updating its time using NTP, Network Time servers. I'm surprised how accurate the arduino keeps time. I set it to sync every 2AM never the less. No more adjusting for day time savings!

Also I'm making a 8 PWM channel object for the ADAFRUIT 16-CHANNEL 12-BIT PWM/SERVO DRIVER - I2C INTERFACE (PCA9685) in anticipation for O2Surplus' 8 channel LED pendent.
It forced me to rewrite my code so it's modular. Without adding any code, I can scale 1 to 16 channels.


----------



## O2surplus (Jan 31, 2010)

That's awesome news! I can't wait to try it out.


----------



## mistergreen (Dec 9, 2006)

Ok, I think I'm done with the 8 channels. SOOooo, many software and hardware bugs.

https://youtu.be/bW-i0wLjk3I


----------



## mistergreen (Dec 9, 2006)

Ok, almost there.
I have lots of bugs to work out and then I can get this out of alpha and commit as a version 1.0

In the meantime, a nifty working video

https://youtu.be/zFxFtmP9ils


----------



## mistergreen (Dec 9, 2006)

Ok, a release build is out

https://github.com/mistergreen/WAAC

You can download the zip file from the 'release' link.


----------

