This is my first post here, I have had my RA up and running for about a week now, but have been reading on here for a while before I purchased.
I decided to forgo the wifi attachment when I bought my RA for 3 reasons, wifi strength where the tank is located is flakey, I already had a couple spare uno's lying round and the extra cost would've thrown my total over the customs tax threshold (NZ).
I have a switch 3m from the tank next to the computer so Ethernet seemed like the perfect choice.... perhaps not.
Ethernet seems to work for the most part, I can use the portal from home or away (Static Wan IP), likewise with the android app. Problem is I seem to get alot of errors using the portal, android app or xxx.xxx.xxx.xxx:2000/wifi. Sometimes loads fast, other times incredibly slow.
Also, my web chart and relay activity have never shown anything, they always remain blank.
Below is the Ethernet Code I'm using on my Uno:
Code: Select all
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x08, 0xCE, 0x4C, 0xC4, 0x11, 0xC8 };
IPAddress ip(192,168,1,113);
IPAddress remoteserver(198,171,134,6);
EthernetClient clientout;
unsigned long lastmillisout=millis();
unsigned long lastmillisin=millis();
boolean sending=false;
char strout[600];
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(2000);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection and the server:
Ethernet.begin(mac);
server.begin();
// Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
while (client.available()) {
char c = client.read();
if (sending==false) Serial.write(c);
lastmillisin=millis();
}
while (Serial.available()){
memset(strout,0,sizeof(strout));
int b=Serial.readBytesUntil('>',strout,sizeof(strout));
// Serial.flush();
client.print(strout);
client.print(">");
// char c = Serial.read();
// client.print(c);
if (millis()-lastmillisin>2000)
{
// Serial.println("Timeout incoming");
Serial.flush();
lastmillisin=millis();
client.stop();
}
}
if (millis()-lastmillisin>2000)
{
// Serial.println("Timeout incoming");
Serial.flush();
lastmillisin=millis();
client.stop();
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
// Serial.println("client disonnected");
}
else
{
if (Serial.available())
{
memset(strout,0,sizeof(strout)-1);
int b=Serial.readBytesUntil('\n',strout,sizeof(strout)-1);
Serial.flush();
// Serial.println(b);
// Serial.println("Connecting");
if (b>10)
{
sending=true;
// Serial.println(strout);
// Serial.println(" HTTP/1.0");
// Serial.println();
if (clientout.connect(remoteserver, 80))
{
// Serial.println("Connected");
// while (Serial.available()){
// char c = Serial.read();
// clientout.print(c);
// }
clientout.println(strout);
// clientout.println(" HTTP/1.0");
clientout.println();
lastmillisout=millis();
}
}
}
while (clientout.available()) {
char c = clientout.read();
Serial.print(c);
if (millis()-lastmillisout>8000)
{
// Serial.println("Timeout connected");
lastmillisout=millis();
clientout.stop();
sending=false;
}
}
if (!clientout.connected())
{
clientout.stop();
sending=false;
}
}
if (millis()-lastmillisout>8000)
{
// Serial.println("Timeout global");
lastmillisout=millis();
clientout.stop();
sending=false;
}
}
And my RA Sketch:
Code: Select all
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <ReefAngel.h>
////// Place global variable code below here
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.SetTemperatureUnit( Celsius ); // set to Celsius Temperature
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port3Bit | Port5Bit | Port6Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T2_PROBE;
// Ports that are always on
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.ActinicLights( Port2 );
ReefAngel.ActinicLights( Port4 );
ReefAngel.SingleATO( true,Port5,10,1 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.PWM.Channel0PWMParabola();
ReefAngel.PWM.Channel1PWMParabola();
ReefAngel.PWM.Channel2PWMParabola();
ReefAngel.PWM.Channel3PWMParabola();
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "tanked_kiwi" );
ReefAngel.ShowInterface();
}
Any help would be much appreciated.
Evan