Page 1 of 3
Expansion module
Posted: Tue Jan 31, 2012 2:42 pm
by maxxdog21
I just hooked up the expansion hub and and plugged in the second relay box(which was already connected and running) and I plugged in the salinity module. I plugged the both relay boxes in and when the system came on, it would run for a second or two and shut off and come back on - over and over. Can anyone advise me on what to do?
Re: Expansion module
Posted: Tue Jan 31, 2012 2:59 pm
by rimai
Did you use the +5VDC power supply that came with it?
It's required to get the HUB powered up.
Re: Expansion module
Posted: Tue Jan 31, 2012 3:17 pm
by maxxdog21
Yep, both modules are plugged in and the red light is on.
Re: Expansion module
Posted: Tue Jan 31, 2012 3:21 pm
by rimai
Let's try this:
1. Connect just the hub into the relay box. Does it work?
2. Connect the relay expansion module into the hub, but leave the salinity out. Does it work?
3. Connect the salinity module into the hub. Does it work?
Re: Expansion module
Posted: Tue Jan 31, 2012 3:59 pm
by maxxdog21
1. The hub worked
2. The relay expansion worked and the 2nd relay box seems to work fine.
3. Plugged in the salinity box and as soon as power is applied, the main relay box starts kicking in and out. I looked at the RA display while this is going on and the salt display is going wild.
Re: Expansion module
Posted: Tue Jan 31, 2012 4:02 pm
by rimai
Ah!!
We need to initialize the memory to accept the salinity module.
Can't remember if you have wifi. Do you?
Re: Expansion module
Posted: Tue Jan 31, 2012 4:31 pm
by maxxdog21
I have the module but it is not hooked up yet...?
Re: Expansion module
Posted: Tue Jan 31, 2012 4:39 pm
by rimai
ok. so, let's do this.
1. Connect the usb cable to RA
2. Open Arduino
3. Open Serial Monitor on menu Tools->Serial Monitor
4. Make sure you have baud rate 57600
5. Type "GET \mi847,2550 " without the quote marks and make sure there is a space after 847
6. Does the controller respond with OK?
Re: Expansion module
Posted: Tue Jan 31, 2012 4:47 pm
by maxxdog21
nope, it does not respond at all
Re: Expansion module
Posted: Tue Jan 31, 2012 4:52 pm
by rimai
Let's go another route then.
Load this code
Code: Select all
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <Phillips6610LCDInv.h>
#include <avr/pgmspace.h>
#include <ReefAngel_EEPROM.h>
Phillips6610LCDInv e;
void setup()
{
e.lcd_init();
e.lcd_clear(COLOR_WHITE,0,0,132,132);
e.lcd_BacklightOn();
InternalMemory.SalMax_write(2550);
}
void loop()
{
e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW, "Done");
}
This should initialize the salinity calibration memory setting.
Re: Expansion module
Posted: Tue Jan 31, 2012 5:00 pm
by maxxdog21
it says color white was not declared in this scope. remember I have the custom screen running.
Re: Expansion module
Posted: Tue Jan 31, 2012 5:08 pm
by rimai
Ok, so try this instead then:
Code: Select all
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <Phillips6610LCDInv.h>
#include <avr/pgmspace.h>
#include <ReefAngel_EEPROM.h>
Phillips6610LCDInv e;
void setup()
{
e.lcd_init();
e.lcd_clear(255,0,0,132,132);
e.lcd_BacklightOn();
InternalMemory.SalMax_write(2550);
}
void loop()
{
e.lcd_draw_text(0, 255, 10, 10, "Done");
}
Re: Expansion module
Posted: Tue Jan 31, 2012 5:26 pm
by maxxdog21
That seemed to work. I had to disable my custom menu and then load your code. I then reloaded my pde. I hooked up the salinity module and the system is still running and not kicking in and out.
Now...what about calibration of the module and probe? Right now it says 51.2. I assume that is PPT?
Re: Expansion module
Posted: Tue Jan 31, 2012 5:50 pm
by rimai
Cool

Yes, ppt.
The calibration on the libraries you are running is broken

I fixed it for the new update.
So, we will need to load another code to calibrate the probe too.
Try this one:
Code: Select all
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <Wire.h>
#include <Phillips6610LCDInv.h>
#include <avr/pgmspace.h>
#include <ReefAngel_EEPROM.h>
Phillips6610LCDInv e;
unsigned long avgSal=0;
void setup()
{
e.lcd_init();
e.lcd_clear(255,0,0,132,132);
e.lcd_BacklightOn();
for (int a=0;a<6;a++)
avgSal+=SalRead();
avgSal/=5;
InternalMemory.SalMax_write(avgSal);
}
void loop()
{
e.lcd_draw_text(0, 255, 10, 10, "Done");
}
int SalRead()
{
int iSal=0;
Wire.requestFrom(I2CSalinity, 2);
if (Wire.available())
{
iSal = Wire.receive();
iSal = iSal<<8;
iSal += Wire.receive();
}
return iSal;
}
Re: Expansion module
Posted: Tue Jan 31, 2012 6:00 pm
by maxxdog21
Just so I know what to expect..... what will this do? How will it work?
Re: Expansion module
Posted: Tue Jan 31, 2012 6:08 pm
by binder
Looks like it will start up and then read the salinity and average the values and store in Internal Memory. Once it's finished, it will show "Done". Then you can reload your PDE and be all set for your salinity.
Re: Expansion module
Posted: Tue Jan 31, 2012 6:38 pm
by maxxdog21
Well, it ran fast and said done before I could blink. I reloaded my pde and now it says - 5.9. That seems like an odd number. Does it seem right to you?
Re: Expansion module
Posted: Tue Jan 31, 2012 6:42 pm
by rimai
No doesn't seem right.
Let's see what the module is actually reporting.
We can manually set it later.
Code: Select all
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <Wire.h>
#include <Phillips6610LCDInv.h>
#include <avr/pgmspace.h>
#include <ReefAngel_EEPROM.h>
Phillips6610LCDInv e;
unsigned long avgSal=0;
void setup()
{
e.lcd_init();
e.lcd_clear(255,0,0,132,132);
e.lcd_BacklightOn();
}
void loop()
{
e.lcd_draw_text(0, 255, 10, 10, SalRead());
}
int SalRead()
{
int iSal=0;
Wire.requestFrom(I2CSalinity, 2);
if (Wire.available())
{
iSal = Wire.receive();
iSal = iSal<<8;
iSal += Wire.receive();
}
return iSal;
}
Re: Expansion module
Posted: Tue Jan 31, 2012 6:44 pm
by rimai
Still wrong. Hold on
Re: Expansion module
Posted: Tue Jan 31, 2012 6:49 pm
by maxxdog21
it does not like this line:
e.lcd_draw_text(0, 255, 10, 10, SalRead());
it flagged it yellow and gave an error that said:
invalid conversion int to char
Re: Expansion module
Posted: Tue Jan 31, 2012 6:49 pm
by rimai
Let's see if I got it right this time:
Code: Select all
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <Wire.h>
#include <Phillips6610LCDInv.h>
#include <avr/pgmspace.h>
#include <ReefAngel_EEPROM.h>
Phillips6610LCDInv e;
unsigned long avgSal=0;
void setup()
{
e.lcd_init();
e.lcd_clear(255,0,0,132,132);
e.lcd_BacklightOn();
}
void loop()
{
char buff[10];
itoa(SalRead(),buff,10);
e.lcd_draw_text(0, 255, 10, 10, buff);
}
int SalRead()
{
int iSal=0;
Wire.requestFrom(I2CSalinity, 2);
if (Wire.available())
{
iSal = Wire.receive();
iSal = iSal<<8;
iSal += Wire.receive();
}
return iSal;
}
Re: Expansion module
Posted: Tue Jan 31, 2012 7:02 pm
by maxxdog21
I uploaded it and on the RA screen it says 0(zero)
Re: Expansion module
Posted: Tue Jan 31, 2012 7:03 pm
by rimai
Do you have the probe in the tank?
Re: Expansion module
Posted: Tue Jan 31, 2012 7:05 pm
by maxxdog21
LOL....yeah I do...thats funny. And I checked it to make sure it it hooked up - it is. and the power is on to the module as well.
Re: Expansion module
Posted: Tue Jan 31, 2012 7:06 pm
by maxxdog21
on the module itself, there is a green light and a yellow light on
Re: Expansion module
Posted: Tue Jan 31, 2012 7:15 pm
by rimai
Ok, I hope I get this right this time....
Code: Select all
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel_Salinity.h>
#include <ReefAngel.h>
void setup()
{
ReefAngel.Init();
SetupCalibrateSalinity();
ReefAngel.ClearScreen(DefaultBGColor);
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW*5, "Done");
}
void loop()
{
#if defined WDT || defined WDT_FORCE
wdt_reset();
#endif // defined WDT || defined WDT_FORCE
}
void SetupCalibrateSalinity()
{
bool bOKSel = false;
bool bSave = false;
bool bDone = false;
bool bDrawButtons = true;
unsigned int iS = 0;
byte offset = 65;
// draw labels
ReefAngel.ClearScreen(DefaultBGColor);
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW, "Calibrate Salinity");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW*5, "35 PPT");
do
{
#if defined WDT || defined WDT_FORCE
wdt_reset();
#endif // defined WDT || defined WDT_FORCE
iS=0;
for (int a=0;a<15;a++)
{
iS += ReefAngel.Salinity.Read();
}
iS/=15;
ReefAngel.LCD.DrawCalibrate(iS, MENU_START_COL + offset, MENU_START_ROW*5);
if ( bDrawButtons )
{
if ( bOKSel )
{
ReefAngel.LCD.DrawOK(true);
ReefAngel.LCD.DrawCancel(false);
}
else
{
ReefAngel.LCD.DrawOK(false);
ReefAngel.LCD.DrawCancel(true);
}
bDrawButtons = false;
}
if ( ReefAngel.Joystick.IsUp() || ReefAngel.Joystick.IsDown() || ReefAngel.Joystick.IsRight() || ReefAngel.Joystick.IsLeft() )
{
// toggle the selection
bOKSel = !bOKSel;
bDrawButtons = true;
}
if ( ReefAngel.Joystick.IsButtonPressed() )
{
bDone = true;
if ( bOKSel )
{
bSave = true;
}
}
}
while ( ! bDone );
if ( bSave )
{
// save PHMin & PHMax to memory
InternalMemory.SalMax_write(iS);
ReefAngel.SalMax = iS;
}
}
Re: Expansion module
Posted: Tue Jan 31, 2012 7:21 pm
by maxxdog21
now I have a calibration screen. What is the correct way to use it ?
Re: Expansion module
Posted: Tue Jan 31, 2012 7:22 pm
by rimai
Does it show something other than 0?
Just place the probe in 35ppt or your tank, assuming it is correct and press OK
Re: Expansion module
Posted: Tue Jan 31, 2012 7:22 pm
by maxxdog21
and it say on the screen:
35 ppt 3957
Re: Expansion module
Posted: Tue Jan 31, 2012 7:23 pm
by rimai
Good.
Press Ok and load your code again.