Page 1 of 2

Cloud Wifi Attachment

Posted: Mon Jan 02, 2017 4:40 pm
by rimai
Hey guys,

I just released the cloud wifi attachment in the webstore.
This new wifi attachment has the ability to connect to our new cloud server and provide live feed of your parameters without the need to refresh to grab parameters or relay changes.
Use the web based Uapp to connect to the cloud server.
No more hassle of setting up port forwarding to get control of your Reef Angel Controller.
With the new cloud wifi attachment, you can be always connected to your controller wherever you are.
I have temporarily setup a controller for you to get a taste of what it can do:
1. Go to web based Uapp: http://forum.reefangel.com/uapp
2. Click "Settings" on the bottom bar
3. Click "Add controller" button
4. Enter the following:
Name: CloudWifi
IP Address: Leave blank
Port: Leave blank
Username: cloudwifi
Password: 123456
5. Click "Save" button.
6.Click "Relay" on the bottom bar. You should start seeing the relay changing status from red to green and vice-versa. It should update every 5 seconds as I setup to turn on/off every 5 seconds.
7. Click "Status" on the bottom bar. You should start seeing the parameters changing. This one may take a few seconds to update as temperature and humidity don't change that often and there is no pH probe, so it is just floating readings.
Let me know what you think :)

Re: Cloud Wifi Attachment

Posted: Mon Jan 02, 2017 5:12 pm
by jhoop
I like it !

Re: Cloud Wifi Attachment

Posted: Tue Feb 28, 2017 3:55 am
by slm222
curious what makes the cloud wifi attachment better than the wifi attachment

Re: Cloud Wifi Attachment

Posted: Wed Mar 01, 2017 5:40 pm
by lnevo
The APP will be realtime and not require Refresh-ing

Re: Cloud Wifi Attachment

Posted: Thu Mar 02, 2017 4:46 am
by cosmith71
Roberto, did you ever get the app working with this?

Re: Cloud Wifi Attachment

Posted: Thu Mar 02, 2017 9:27 am
by rimai
Yes, the web based uapp should be fully functional.
Can you try it out and confirm?

Re: Cloud Wifi Attachment

Posted: Thu Mar 02, 2017 12:11 pm
by cosmith71
Yep, it's working. I tried it on a generic Android 5 tablet, my Samsung 6.0.1 tablet, and my Pixel XL Android 7.1.1. All working fine using Chrome. Awesome!

How about the ability to set memory locations? That's really the only thing missing now.

--Colin

Re: Cloud Wifi Attachment

Posted: Thu Mar 02, 2017 12:12 pm
by rimai
That should be working too.

Re: Cloud Wifi Attachment

Posted: Thu Mar 02, 2017 12:15 pm
by cosmith71
Sorry, I meant custom memory locations.

Re: Cloud Wifi Attachment

Posted: Thu Mar 02, 2017 12:27 pm
by rimai
I still have to work on that

Re: Cloud Wifi Attachment

Posted: Thu Mar 02, 2017 5:10 pm
by benjy1234
Any idea when it will be back in stock Roberto?

Re: Cloud Wifi Attachment

Posted: Fri Mar 10, 2017 8:29 pm
by slm222
I just ordered mine!

is the controller moving away from the desktop app for uploading code and going to the web based app from now on?

Re: Cloud Wifi Attachment

Posted: Fri Mar 10, 2017 9:41 pm
by rimai
That's the plan.
It's much easier to get updates to the wizard.

Re: Cloud Wifi Attachment

Posted: Tue Mar 14, 2017 2:19 pm
by slm222
I got it in and working. I am running into two issues after switching it out and using the iphone app

1. I changed my labels, below, and now they are not showing up on my reef angel screen and on the uapp when i click download from portal it is pulling the old labels.

Code: Select all

    ReefAngel.CustomLabels[0]="OPEN"; //1
    ReefAngel.CustomLabels[1]="Skimmer"; //2
    ReefAngel.CustomLabels[2]="FugeLight"; //3
    ReefAngel.CustomLabels[3]="Heater"; //4
    ReefAngel.CustomLabels[4]="OPEN"; //5
    ReefAngel.CustomLabels[5]="OPEN"; //6
    ReefAngel.CustomLabels[6]="ATO"; //7
    ReefAngel.CustomLabels[7]="OPEN"; //8
2. i changed my settings on the iphone app to the cloud server with correct password and username and it just keeps saying connecting

Re: Cloud Wifi Attachment

Posted: Tue Mar 14, 2017 6:50 pm
by rimai
RA cannot download labels.
You need to change them in the code.
You can only download labels in the iphone app that you have setup on the portal.
So, the portal and the uapp share the same labels, but the ones in the screen need to be setup on your code.
The problem is that I think I screwed it up.
I changed the custom lables on the new libraries to be pulled from flash instead of using up RAM memory to avoid RAM memory usage, which was causing undesirable results.
When I created the web wizard, which uses the new libraries, I didn't give you the ability to change them :(
The iphone uapp also needs to be updated to be able to connect to the cloud server. We have not released the update yet.
The only way to get the cloud server connection is to use the web based uapp: http://forum.reefangel.com/uapp
I wanted to make sure the framework was good before I release a new update for iphone.

Re: Cloud Wifi Attachment

Posted: Tue Mar 14, 2017 8:18 pm
by slm222
Thanks for the quick reply. And a big 10/4 on the future app release. That code above is from my sketch loaded with the web-based loader. With that it's not showing up in the display. Do I need to do something different?

Re: Cloud Wifi Attachment

Posted: Tue Mar 14, 2017 11:41 pm
by dapg8gt
Add me to the list of wanting to order one as soon as they are available.

I have my raceway in my garage on an RA without any means to add it to an app or control it, it's more of a monitoring thing due to my all in one xfinity gateway not allowing me to change internal port forwarding channels so I can only control one RA remotely. Was just thinking of bridging my router and buying a new better one just for the RA's but this is so much easier =) .. So I can use this big time for the second tank..

Guessing it won't be an issue having two of these on the same app.. Or will there be an issue? Most likely gonna just keep the main tank going with the standard wifi for now but curious if it is possible with the u app..

Shoot me a Pm or whatever with an Eta for the next shipment I'll grab one ASAP..

Re: Cloud Wifi Attachment

Posted: Wed Mar 22, 2017 9:39 am
by GugsJr
With this attachment can I upload code with out having to tether a cable to the reef angel from my laptop?

If so can you let me know when they are in, I'd like to order this with the salinity expansion

Re: Cloud Wifi Attachment

Posted: Wed Mar 22, 2017 10:33 am
by rimai
No, you need the bluetooth attachment to do that.
http://forum.reefangel.com/viewtopic.php?f=3&t=3372

Re: Cloud Wifi Attachment

Posted: Mon May 08, 2017 9:35 am
by Kungpaoshizi
Can we expect code uploads via the device someday?
I think that's one thing I would really like... Though I have gotten to the point where my reef tank setup is simple enough I don't need to change anything... lol

Re: Cloud Wifi Attachment

Posted: Mon May 08, 2017 9:59 am
by rimai
I could happen. I don't think there is anything out there yet to leverage so we would need to replicate the STK500v2 protocol on the cloud wifi attachment to be able to upload remotely.

Re: Cloud Wifi Attachment

Posted: Fri May 19, 2017 7:02 pm
by slm222
I'm not sure what is going on, but I've had the cloud wifi app for a couple months now and it has started going to a solid green light from the blue connected light. Nothing has changed in setup or placement of it or the wifi router. I check the pins and everything is fine. It's on the side of the tank, so no moisture to speak of. I've been having to unplug it and re plug it back in. Sometime I have to do that a couple times before it reconnects. It is 12-15' away from the router

Re: Cloud Wifi Attachment

Posted: Fri May 19, 2017 8:03 pm
by rimai
Do you have a computer that you can connect to the module and leave it logging to see what happens?
If so, connect the usb cable to the cloud wifi module and open Arduino. Then go to Tools->Serial monitor.
You should start seeing the log.

Re: Cloud Wifi Attachment

Posted: Fri May 19, 2017 8:46 pm
by slm222
I will do that and post back. What I noticed is interesting is when it is connected after a while I go and check via the U-App and then it goes to green and eventually reconnects

Re: Cloud Wifi Attachment

Posted: Fri May 26, 2017 11:08 am
by slm222

Code: Select all

PH:809
PH:808
PWMD:0
PWMA:38
PWMD:38
PWMA:0
PWMD:0
PWMA:38
PWMD:38
PWMA:0
PWMD:0
PWMA:38
PH:809
PH:808
PWMD:38
PWMA:0
PWMD:0
PWMA:38
PWMD:38
PWMA:0
PWMD:0
PWMA:38
PH:809
PH:808
PWMD:38
PWMA:0
PWMD:0
PH:809
PH:808
Connecting to Portal Server
Connected
Disconnecting from Portal Server
PWMD:38
PH:809
PH:808
T1:786
T1:784
T1:786
T1:784
all:0
ATOLOW:0
ATOHIGH:0
EM:0
EM1:2
REM:0
BID:1
AF:0
SF:0
PWMD:38
PWMA:0
PWMDO:255
PWMAO:255
R1:0
ROFF1:0
RON1:0
R2:0
ROFF2:0
RON2:0
R3:0
ROFF3:0
RON3:0
R4:0
ROFF4:0
RON4:0
R5:0
ROFF5:0
RON5:0
R6:0
ROFF6:0
RON6:0
R7:0
ROFF7:0
RON7:0
R8:0
ROFF8:0
RON8:0
ALARM:0
PWMD2:0
PWMA2:0
PWMD2O:0
PWMA2O:0
WL:0
WL1:0
WL2:0
WL3:0
WL4:0
HUM:0
DCM:5
DCS:38
DCD:50
DCT:20
PWME0:0
PWME1:0
PWME2:0
PWME3:0
PWME4:0
PWME5:0
PWME0O:0
PWME1O:0
PWME2O:0
PWME3O:0
PWME4O:0
PWME5O:0
AIW:0
AIB:0
AIRB:0
RFM:0
RFS:0
RFD:0
RFW:0
RFRB:0
RFR:0
RFG:0
RFB:0
RFI:0
RFWO:0
RFRBO:0
RFRO:0
RFGO:0
RFBO:0
RFIO:0
IO:0
LEAK:0
C0:0
C1:0
C2:0
C3:0
C4:0
C5:0
C6:0
C7:0
R:183
ROFF:66
RON:0
T1:784
T2:0
T3:0
PH:808
ORP:0
SAL:0
PHE:0
PAR:0
CEXP0:0
CEXP1:0
CEXP2:0
CEXP3:0
CEXP4:0
CEXP5:0
CEXP6:0
CEXP7:0
Connecting to Portal Server
Connected
Disconnecting from Portal Server
T1:786
T1:784
PWMA:20
Connecting to Portal Server
Connected
Disconnecting from Portal Server
T1:786
T1:784
T1:786
T1:784
PWMA:21
PWMA:22
PWMA:23
PWMA:24
PWMA:25
PWMA:26
PWMA:27
PWMA:28
PWMA:29
Connecting to Portal Server
Connected
PWMA:30
Disconnecting from Portal Server
PWMA:31
T1:786
T1:784
PWMA:32
PWMA:33
PWMA:34
T1:786
T1:784
PWMA:35
T1:786
T1:784
PWMA:36
T1:786
T1:784
PWMA:37
T1:786
T1:784
T1:786
T1:784
PWMA:38
PWMA:37
Connecting to Portal Server
Connected
T1:786
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
MQTT Connecting...
MQTT failed
Connecting to Portal Server
Failed to connect
Disconnecting from Portal Server
MQTT Connecting... 

Re: Cloud Wifi Attachment

Posted: Mon May 29, 2017 10:04 am
by rimai
It does seem that it is loosing the connection and can't reconnect again for some reason.
Let me see if I can find anything with the firmware.

Re: Cloud Wifi Attachment

Posted: Mon May 29, 2017 6:19 pm
by slm222
Thank you Rimai. Most of today it has not been connected, just blinking green. If it makes any difference I had used the webwizard to program the reef angel plus.

Re: Cloud Wifi Attachment

Posted: Tue May 30, 2017 11:12 am
by LucianoB
slm222 wrote:Thank you Rimai. Most of today it has not been connected, just blinking green. If it makes any difference I had used the webwizard to program the reef angel plus.
Hi. What Router are you using?
I has a lot of the problems with one mikrotik Router. I changed that so everything are working fine.. if you can only test with another Router.

Regards from Argentina.
Cheers

Enviado desde mi Nexus 5 mediante Tapatalk

Re: Cloud Wifi Attachment

Posted: Tue May 30, 2017 8:37 pm
by rimai
See if this code makes any difference.

Code: Select all

#include <SPI.h>
#include <WiFi101.h>
#include <PubSubClient.h>
#include <RA_CustomSettings.h>

//char ssid[32];
//char pass[32];
//char username[16];
//char password[16];

unsigned long client_timeout = millis();
unsigned long wifi_connection = millis();
unsigned long serial_timeout = millis();
unsigned long led_blink = millis();
unsigned long MQTTReconnectmillis = millis();

boolean LED_status = false;
boolean PortalConnection = false;
boolean power_status = true;
boolean data_ready = false;
int status = WL_IDLE_STATUS;
int connection_counter=0;
WiFiServer server(2000);
WiFiClient client;
WiFiClient portalclient;
WiFiClient mqttclient;

void mqttcallback(char* topic, byte* payload, unsigned int length);

PubSubClient CloudClient(MQTTServer, MQTTPORT, mqttcallback, mqttclient);

String currentLine = "";                // make a String to hold incoming data from the client

void setup() {
  Serial.begin(57600);      // initialize serial communication
  Serial1.begin(57600);      // initialize serial communication
  pinMode(5, OUTPUT);      // set the LED pin mode
  pinMode(6, OUTPUT);      // set the LED pin mode
  pinMode(7, OUTPUT);      // set the LED pin mode
  wdt_initialize();
  wdt_enable();
}

void loop() {
  wdt_reset();
  status = WiFi.status();
  while ( status != WL_CONNECTED) {
    digitalWrite(5, false);
    digitalWrite(6, true);
    digitalWrite(7, false);
    if (millis() - wifi_connection > 1000)
    {
      wifi_connection = millis();
      Serial.print("Attempting to connect to Network named: ");
      Serial.println(WIFI_SSID);                   // print the network name (SSID);
      if (WiFi.begin(WIFI_SSID, WIFI_PASS) == WL_CONNECTED)
      {
        status = WiFi.status();
        server.begin();                           // start the web server on port 2000
        printWifiStatus();                        // you're connected now, so print out the status
        digitalWrite(6, false);
        digitalWrite(7, true);
      }
      Serial.println("Not connected...");
    }
    wdt_reset();
  }

  client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println(F("new incoming client"));           // print a message out the serial port
    client_timeout = millis();
    while (client.connected()) {            // loop while the client's connected
      if (millis() - client_timeout > 2000) client.stop();
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        Serial1.write(c);                   // send to Reef Angel
      }
      if (Serial1.available())
      {
        char c = Serial1.read();
        //Serial.write(c);
        currentLine += c;
        serial_timeout = millis();
        if (currentLine.length() == 255) {
          SendData();
        }
      }
      if (millis() - serial_timeout > 400)
      {
        if (currentLine.length() > 0) {
          SendData();
          Serial.println();
          client.println();
        }
      }
      if (millis() - led_blink > 50)
      {
        led_blink = millis();
        LED_status = !LED_status;
        digitalWrite(6, LED_status);
      }
    }
    // close the connection:
    client.stop();
    Serial.println(F("incoming client disconnected"));
    digitalWrite(6, false);
  }
  else
  {
    while (Serial1.available())
    {
      char c = Serial1.read();
      currentLine += c;
      if(c==10) data_ready=true;
      serial_timeout = millis();
      digitalWrite(6, true);
      if (millis() - serial_timeout > 200 || data_ready)
      {
        if (currentLine.length() > 0) 
        {
          data_ready=false;
          serial_timeout = millis();
          //        Serial.print(currentLine);
          if (currentLine.startsWith("GET"))
          {
            PortalConnection = true;
            Serial.println(F("Connecting to Portal Server"));
            if (portalclient.connect(PortalServer, 80)) {
              Serial.println(F("Connected"));
              // Make a HTTP request:
              portalclient.print(currentLine);
              portalclient.println(F(" HTTP/1.1"));
              portalclient.println(F("Host: forum.reefangel.com"));
              portalclient.println(F("Connection: close"));
              portalclient.println();
            }
            else
            {
              Serial.println(F("Failed to connect"));
            }
          }
          if (currentLine.startsWith("CLOUD:"))
          {
            //Serial.print(currentLine);
            if (currentLine.length() < 32)
            {
              if (CloudClient.connected())
              {
                //Serial.println(F("Publishing "));
                currentLine.replace("CLOUD:", "");
                Serial.print(currentLine);
                char pub_buffer[sizeof(CLOUD_USERNAME) + 5];
                sprintf(pub_buffer, "%s/out", CLOUD_USERNAME);
                char pub_msg[currentLine.length() + 1];
                currentLine.toCharArray(pub_msg, currentLine.length() + 1);
                CloudClient.publish(pub_buffer, pub_msg);
              }
            }
            else
            {
              Serial.print(F("Error on incoming data: "));
              Serial.println(currentLine.length());
            }
          }
          currentLine = "";
          digitalWrite(6, false);
        }
      }
    }
    digitalWrite(6, false);    
    while (portalclient.available()) {
      char c = portalclient.read();
      //      Serial.write(c);
    }
    if (PortalConnection && !portalclient.connected()) {
      PortalConnection = false;
      //      Serial.println();
      Serial.println(F("Disconnecting from Portal Server"));
      digitalWrite(6, false);
      portalclient.stop();
    }
  }

  CloudClient.loop();
  if (millis() - MQTTReconnectmillis > 5000)
  {
    if (!CloudClient.connected())
    {
      char sub_buffer[sizeof(CLOUD_USERNAME) + 6];
      MQTTReconnectmillis = millis();
      digitalWrite(6, true);
      Serial.println(F("MQTT Connecting..."));
      Serial.print(F("Attemp: "));
      Serial.println(++connection_counter);
      if (connection_counter>5)
      {
        Serial.println(F("Unable to connect. Rebooting..."));
        digitalWrite(5, true);
        digitalWrite(6, false);
        digitalWrite(7, false);        
        while(1);
      }
      sprintf(sub_buffer, "RA-%s", CLOUD_USERNAME);
      if (CloudClient.connect(sub_buffer, CLOUD_USERNAME, CLOUD_PASSWORD))
      {
        sprintf(sub_buffer, "%s/in/#", CLOUD_USERNAME);
        Serial.println(F("MQTT succeeded"));
        CloudClient.subscribe(sub_buffer);
      }
      else
      {
        MQTTReconnectmillis = millis();
        Serial.println(F("MQTT failed"));
        CloudClient.disconnect();
      }
      digitalWrite(6, false);
    }
  }
  if (analogRead(0) < 600 && power_status)
  {
    power_status = false;
  }
  if (analogRead(0) > 600 && !power_status)
  {
    power_status = true;
  }
}

void SendData()
{
  serial_timeout = millis();
  //  Serial.print(currentLine);
  client.print(currentLine);
  currentLine = "";
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

void mqttcallback(char* topic, byte* payload, unsigned int length)
{
  Serial1.print("cloud:");
  for (int a=0;a<length;a++)
  {
    Serial1.write(payload[a]);
    Serial.write(payload[a]);
  }
  Serial1.print(" ");
  Serial.println();
}

void wdt_initialize()
{
  GCLK->GENDIV.reg = GCLK_GENDIV_ID(2) | GCLK_GENDIV_DIV(4);
  GCLK->GENCTRL.reg = GCLK_GENCTRL_ID(2) |
                      GCLK_GENCTRL_GENEN |
                      GCLK_GENCTRL_SRC_OSCULP32K |
                      GCLK_GENCTRL_DIVSEL;
  while (GCLK->STATUS.bit.SYNCBUSY);  // Syncronize write to GENCTRL reg.
  GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID_WDT |
                      GCLK_CLKCTRL_CLKEN |
                      GCLK_CLKCTRL_GEN_GCLK2;
}

void wdt_enable()
{
  WDT->CTRL.reg &= ~WDT_CTRL_ENABLE;
  while (WDT->STATUS.bit.SYNCBUSY);  // Syncronize write to CTRL reg.
  WDT->CONFIG.reg = WDT_CONFIG_PER(0xA);  // 0xA = 8192 ms
  while (WDT->STATUS.bit.SYNCBUSY);  // Syncronize write to CONFIG reg.
  WDT->INTENCLR.reg |= WDT_INTENCLR_EW;
  WDT->CTRL.reg |= WDT_CTRL_ENABLE;
  while (WDT->STATUS.bit.SYNCBUSY);  // Syncronize write to CTRL reg.
}

void wdt_disable()
{
  WDT->CTRL.reg &= ~WDT_CTRL_ENABLE;
  while (WDT->STATUS.bit.SYNCBUSY);  // Syncronize write to CTRL reg.
}

void wdt_reset()
{
  WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY;
  while (WDT->STATUS.bit.SYNCBUSY);  // Syncronize write to CLEAR reg.
}

// RA_STRING1=U2FsdGVkX19hO6KSSw/SEWReqPKC34stYAL4B8vahEY=
// RA_STRING2=U2FsdGVkX1+BPena6vAB/qszbCcvez8FgwKcXXxBbYg=
// RA_STRING3=test
Be aware that you will need to copy and paste the last 3 lines of the code to match whatever you have from your own code that you generated from the webwizard.

Re: Cloud Wifi Attachment

Posted: Wed May 31, 2017 1:39 pm
by slm222
LucianoB wrote:
slm222 wrote:Thank you Rimai. Most of today it has not been connected, just blinking green. If it makes any difference I had used the webwizard to program the reef angel plus.
Hi. What Router are you using?
I has a lot of the problems with one mikrotik Router. I changed that so everything are working fine.. if you can only test with another Router.

Regards from Argentina.
Cheers

Enviado desde mi Nexus 5 mediante Tapatalk
I am using an ASUS router, but no changes have been made and the intermittent issues started out of now where. I have a Linksys AC2400 coming in to try that as well.