Guide: Arduino based LED controller for Current Satellite LED+ - Page 13
Planted Tank Forums
Your Tanks Image Hosting *Tank Tracker * Plant Profiles Fish Profiles Planted Tank Guide Photo Gallery Articles

Go Back   The Planted Tank Forum > Specific Aspects of a Planted Tank > DIY


Reply
 
Thread Tools Display Modes
Old 08-09-2013, 08:06 PM   #181
jeffkrol
Wannabe Guru
 
PTrader: (0/0%)
Join Date: Jun 2013
Location: WI
Posts: 1,931
Default

[QUOTE=Dahammer;4022497
It would be cool if we could connect to the UART wirelessly, so that we could send in commands and/or reload the Uno without connecting it to USB. I poked around last night and all the options I could come up with were in the $100 range, a bit too much for my purposes.[/QUOTE]

OR you could build one..
http://www.ti.com/lit/an/swra039/swra039.pdf

or..
433M Arduino Wireless Serial Data Communication Kit RF Module UART RS232 AVR PIC
$36.59........................including shipping


Last edited by jeffkrol; 08-09-2013 at 08:59 PM.. Reason: see fleabay
jeffkrol is online now   Reply With Quote
Sponsored Links
Advertisement
 
Old 08-09-2013, 10:24 PM   #182
Dahammer
Algae Grower
 
PTrader: (0/0%)
Join Date: Oct 2010
Location: Mississippi
Posts: 118
Default

Quote:
Originally Posted by somewhatshocked View Post
I avoided the RTC because I don't want to solder but I am using a 9v battery and I get the sense that it's going to last much longer than I expected.
If you are not going to install an RTC, the clock will be off if it gets reset and you don't re-upload the code. The below code will reset the clock to the time the code was compiled and uploaded every time the Uno is reset, unless you have an RTC installed and running.
Code:
  if (! RTC.isrunning()) { 
    Serial.println("RTC is NOT running!");
    RTC.adjust(DateTime(__DATE__, __TIME__));  //Adjust to compile time
    }
If you don't want to solder, I think the one IndyChus has came pre-assembled. You could also get one of these:
http://www.adafruit.com/products/255#Description
Dahammer is offline   Reply With Quote
Old 08-09-2013, 10:25 PM   #183
Dahammer
Algae Grower
 
PTrader: (0/0%)
Join Date: Oct 2010
Location: Mississippi
Posts: 118
Default

Quote:
Originally Posted by jeffkrol View Post
OR you could build one..
http://www.ti.com/lit/an/swra039/swra039.pdf

or..
433M Arduino Wireless Serial Data Communication Kit RF Module UART RS232 AVR PIC
$36.59........................including shipping
Haha! I'm not up to rolling my own but I will take a peek at the other one, thanks.
Dahammer is offline   Reply With Quote
Old 08-09-2013, 10:25 PM   #184
Indychus
Planted Tank Enthusiast
 
Indychus's Avatar
 
PTrader: (8/100%)
Join Date: Feb 2013
Location: Irmo, SC
Posts: 645
Default

Mine was pre-assembled, but I still had to solder the jumper wires to it. There are several available with headers already installed though.

Sent from my HTC One X
__________________
The Fraternity of Dirt
Check out my open-source Arduino-Powered Light Controller Guide for Current LED+ and other IR switchable lights.
Indychus is offline   Reply With Quote
Old 08-09-2013, 10:53 PM   #185
somewhatshocked
Obsessed? Maybe
 
somewhatshocked's Avatar
 
PTrader: (428/100%)
Join Date: Aug 2011
Location: Louisville, KY
Posts: 11,366
Default

Right now, I'll only have to re-upload the code when I swap out the 9v battery. Which isn't a big deal. Plus it'll give me the chance to tweak things, change times, upload new code as this thread evolves.

Or I can just plug it into a UPS and never have to worry about it.

Just trying to keep things as simple and cheap as possible while still enjoying the benefits.

Quote:
Originally Posted by Dahammer View Post
If you are not going to install an RTC, the clock will be off if it gets reset and you don't re-upload the code. The below code will reset the clock to the time the code was compiled and uploaded every time the Uno is reset, unless you have an RTC installed and running.
Code:
  if (! RTC.isrunning()) { 
    Serial.println("RTC is NOT running!");
    RTC.adjust(DateTime(__DATE__, __TIME__));  //Adjust to compile time
    }
If you don't want to solder, I think the one IndyChus has came pre-assembled. You could also get one of these:
http://www.adafruit.com/products/255#Description

Last edited by somewhatshocked; 08-10-2013 at 02:25 AM.. Reason: UPS, not UPC
somewhatshocked is online now   Reply With Quote
Old 08-09-2013, 11:09 PM   #186
Dahammer
Algae Grower
 
PTrader: (0/0%)
Join Date: Oct 2010
Location: Mississippi
Posts: 118
Default

I've noticed another minor bug, if you want to call it that, in the SerialReadInt() function. The function only reads 2 bytes off of the serial buffer, so if you sent something like 123, it would process the code for "12" (WhiteUp) and then it would also turn around and process the code for "3" (Rose). What happens is that it only takes the 12 off the buffer and leaves the 3. Then when it gets back to loop() it sees the 3 is there, so off it goes back to SerialReadInt() to process it. It could be fixed with something like this:
Code:
int SerialReadInt()
{
  int i, numAva;
  char inBytes[3];                  // Array to hold the bytes
  char * inBytesPtr = &inBytes[0];  // Pointer to the first element of the array
      
    numAva = Serial.available();    // Read number of input bytes
    if (numAva > 2)
      numAva = 2;                   // Only allow 2 characters to prevent overflow
      
    for (i=0; i<numAva; i++)        // Load input bytes into array
      inBytes[i] = Serial.read();
    inBytes[i] =  '\0';             // Put NULL character at the end
    while (Serial.read() >= 0)
      ; // do nothing
    return atoi(inBytesPtr);        // Call atoi function and return result
}
Might also have to add a delay to make sure all the data has time to transmit. But I'm going to leave mine running for a few days before I fiddle with it, since it is really of no consequence.
Dahammer is offline   Reply With Quote
Old 08-10-2013, 02:03 AM   #187
Indychus
Planted Tank Enthusiast
 
Indychus's Avatar
 
PTrader: (8/100%)
Join Date: Feb 2013
Location: Irmo, SC
Posts: 645
Default

Looks like I'm still on the job until maybe monday... I love what I do, but I hate when it interferes with my other projects. Dahammer's gonna be on version 5 before I even get to try out version 3 if this keeps up haha.
__________________
The Fraternity of Dirt
Check out my open-source Arduino-Powered Light Controller Guide for Current LED+ and other IR switchable lights.
Indychus is offline   Reply With Quote
Old 08-10-2013, 02:09 AM   #188
Dahammer
Algae Grower
 
PTrader: (0/0%)
Join Date: Oct 2010
Location: Mississippi
Posts: 118
Default

Quote:
Originally Posted by somewhatshocked View Post
Right now, I'll only have to re-upload the code when I swap out the 9v battery. Which isn't a big deal. Plus it'll give me the chance to tweak things, change times, upload new code as this thread evolves.

Or I can just plug it into a UPC and never have to worry about it.

Just trying to keep things as simple and cheap as possible while still enjoying the benefits.
I'm thinking those 9 volt batteries are going to get expensive. From what I've read, the Uno draws around 42mA constantly. That's without the pulsing IR LED, which is only on for microseconds. A standard 9v battery is only rated at around 600mAh, so that's not going to last long. Standard AAs are around 2000mAh, but even those will be gone before you know it. It will be interesting to see how long it takes to drain them though. Update us when you have to change them.
Dahammer is offline   Reply With Quote
Old 08-10-2013, 02:20 AM   #189
somewhatshocked
Obsessed? Maybe
 
somewhatshocked's Avatar
 
PTrader: (428/100%)
Join Date: Aug 2011
Location: Louisville, KY
Posts: 11,366
Default

They're rechargeable, so I'll actually swap them out. Right now, they're lasting almost two days - longer than I thought.

Only plan to do this until I can move the UPS near enough to connect the Arduino.

Quote:
Originally Posted by Dahammer View Post
I'm thinking those 9 volt batteries are going to get expensive. From what I've read, the Uno draws around 42mA constantly. That's without the pulsing IR LED, which is only on for microseconds. A standard 9v battery is only rated at around 600mAh, so that's not going to last long. Standard AAs are around 2000mAh, but even those will be gone before you know it. It will be interesting to see how long it takes to drain them though. Update us when you have to change them.
somewhatshocked is online now   Reply With Quote
Old 08-10-2013, 01:14 PM   #190
somewhatshocked
Obsessed? Maybe
 
somewhatshocked's Avatar
 
PTrader: (428/100%)
Join Date: Aug 2011
Location: Louisville, KY
Posts: 11,366
Default

Just under two days it is but I finally moved the UPS! Now the Arduino and an air pump will never, ever run out of juice.

On a related note: In playing around with things, I've run into issues using more than 6 with 'dtNBR_ALARMS' - it'll occasionally just stop firing after that. Anyone else hit that issue?
somewhatshocked is online now   Reply With Quote
Old 08-10-2013, 03:37 PM   #191
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 13,987
Default

Quote:
Originally Posted by Dahammer View Post
Code:
int SerialReadInt()
{
  int i, numAva;
  char inBytes[3];                  // Array to hold the bytes
  char * inBytesPtr = &inBytes[0];  // Pointer to the first element of the array
      
    numAva = Serial.available();    // Read number of input bytes
    if (numAva > 2)
      numAva = 2;                   // Only allow 2 characters to prevent overflow
      
    for (i=0; i= 0)
      ; // do nothing
    return atoi(inBytesPtr);        // Call atoi function and return result
}
What calls this function? I don't see it in the code.
Usually you can do something simpler like

Code:
buffer=0;
//in some loop
if(Serial.available) {
//look for the end of stream; could be \0
    if(Serial.read() != '\0') {
         inByte[buffer++]= Serial.read();
     } else {
         return atoi(inByte);
    }
}
This way it can be any bytes, 1,2,3,4 etc.. You'll just look for a terminating byte.

Last edited by mistergreen; 08-10-2013 at 09:02 PM..
mistergreen is online now   Reply With Quote
Old 08-10-2013, 08:48 PM   #192
Caver
Algae Grower
 
PTrader: (0/0%)
Join Date: Jun 2013
Location: Austin TX
Posts: 56
Default

Quote:
Originally Posted by somewhatshocked View Post
On a related note: In playing around with things, I've run into issues using more than 6 with 'dtNBR_ALARMS' - it'll occasionally just stop firing after that. Anyone else hit that issue?
I haven't noticed any freezes or stoppages, but my unit has been getting a power reset every day or so, by me pulling it to update the software, change an alarm or play with the LED transistor circuit. I'm about to the point where I want it (until one of you guys makes another software update), so I'm just letting it run.

I'm sure you noticed it, but I'll mention it anyway...I edited the 'dtNBR_ALARMS' value in my library file to 24 from the 6 that is their default. I have almost a dozen alarms set, cycling from moonlight in the morning, through several cloud modes...fullspec midday...back through clouds to moon at night. I'm really liking how it looks!

Been playing with an LCD display and some RGB LED's on my spare Arduino. Still waiting for my waterproof temperature sensors (DS18b20's) to get here, so I can build up the 2 channel thermometer for the tanks.

Would be cool if we could incorporate the thermometer code into this one...then one unit could do both jobs...
__________________
--
Tom
Caver is offline   Reply With Quote
Old 08-11-2013, 12:58 AM   #193
somewhatshocked
Obsessed? Maybe
 
somewhatshocked's Avatar
 
PTrader: (428/100%)
Join Date: Aug 2011
Location: Louisville, KY
Posts: 11,366
Default

Weird: When I try using 8 alarms, no dice. When I up it to 24 (as suggested above), it works like a charm.
somewhatshocked is online now   Reply With Quote
Old 08-11-2013, 12:59 AM   #194
Dahammer
Algae Grower
 
PTrader: (0/0%)
Join Date: Oct 2010
Location: Mississippi
Posts: 118
Default

Quote:
Originally Posted by mistergreen View Post
What calls this function? I don't see it in the code.
Usually you can do something simpler like

Code:
buffer=0;
//in some loop
if(Serial.available) {
//look for the end of stream; could be \0
    if(Serial.read() != '\0') {
         inByte[buffer++]= Serial.read();
     } else {
         return atoi(inByte);
    }
}
This way it can be any bytes, 1,2,3,4 etc.. You'll just look for a terminating byte.

It's called in the loop() function:
Code:
void loop()
{
#ifdef DEBUG_IR 
  if (Serial.available() > 0) {
    delay(5); //Wait for transmission to finish
    CurrentCMDs(SerialReadInt());
  }
#endif
  Alarm.delay(100);               // Service alarms & wait (msec)
}
Are you sure the serial stream is automatically terminated with a NULL? I didn't think it was from what I had read but didn't try it to see. The reason I did it the way I did, was because I was only interested in the first 2 bytes that were sent and just inserted the NULL behind them and threw anything else away.
Dahammer is offline   Reply With Quote
Old 08-11-2013, 01:08 AM   #195
Dahammer
Algae Grower
 
PTrader: (0/0%)
Join Date: Oct 2010
Location: Mississippi
Posts: 118
Default

Quote:
Originally Posted by somewhatshocked View Post
Weird: When I try using 8 alarms, no dice. When I up it to 24 (as suggested above), it works like a charm.
Are you changing dtNBR_ALARMS in TimeAlarms.h?

Code:
#define dtNBR_ALARMS 24   // max is 255
Currently, the source code requires a minimum of 10 alarms, if you use storms. The comments in the code say 12, but it's actually 10. Without storms enabled, it needs a minimum of 7. If you have dtNBR_ALARMS below that, behavior will be erratic. If you've added additional alarms to it, then you'll need to account for those as well. I think you added some to toggle the power on/off, if I recall correctly, so don't forget those.
Dahammer is offline   Reply With Quote
Reply

Tags
arduino, automation, current led+, diy, light controller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright Planted Tank LLC 2012