I can't find the WifiSendAlert() function in the libraries.

Requests for new functions or software apps
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

30 seconds. It should only send after 30 seconds.
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

Lee,
I am curious if you have been receiving frequent false alarms from WifiAlert. I have been using it for a few days now and I receive several SMS alerts each day when I know that it should not be triggered that frequently. I am monitoring the status of both the ATO Low and ATO High float switches and sending the SMS text based upon the status. The ATO low float has been physically flipped so that the indicated display status on the portal displays green. The float switch is fully submerged in my ATO container and is triggered when the container is empty. I was receiving SMS text alerts every few minutes so I had to disable the code. The ATO High float switch is mounted at the top of the sump to monitor the water level and to prevent a sump overflow. It should not be triggered but I am receiving SMS alerts every few hours (but I don't see a pattern). I realize that you are not monitoring float switches but was curious if you are receiving false alerts too.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

I do have an alert on my float switches and haven't had any false alerts at all. Quite the opposite...a few alerts i should have received i have not. I don't know if roberto put any time delay on the alert page or if our strings are using up too much of the serial buffer or not. It has been working well, but i wouldn't say 100% at this point.

Can you post your code so i can see how you implemented it. I can see if any hanging logic as well that may be screwing up.
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

lnevo wrote:I do have an alert on my float switches and haven't had any false alerts at all. Quite the opposite...a few alerts i should have received i have not. I don't know if roberto put any time delay on the alert page or if our strings are using up too much of the serial buffer or not. It has been working well, but i wouldn't say 100% at this point.

Can you post your code so i can see how you implemented it. I can see if any hanging logic as well that may be screwing up.
Lee,
I also have a buzzer implemented which has been a very reliable alert for me so I have a good indicator when the float switches have been activated. I receive random SMS text alerts at all times to the extent that I have decided to disable the ATO container empty alert because it is triggered too frequently while the ATO container is actually full. Here are my code snippets...

Code: Select all

// ************ PLACE GLOBAL VARIABLE CODE BELOW HERE *******************

class WiFiAlert
{
public:
  WiFiAlert();
  void Send(char *message, char *key);
  inline void Send(char *message) { Send(message,""); }
  inline void SetDelay(int delay) { AlertDelay=delay; }
private:
  int AlertDelay;
  time_t LastAlert;
  boolean IsAlert();
  void WiFiSendAlert(char *message, char *key);  
};

WiFiAlert::WiFiAlert()
{
  AlertDelay=900;
  LastAlert=0;
}

boolean WiFiAlert::IsAlert()
{
  if (now()-LastAlert >= AlertDelay) 
  {
    return true;
  }
  return false;
}

void WiFiAlert::Send(char *message, char *key)
{
  if (IsAlert())
  {
    LastAlert=now();
    WiFiSendAlert(message, key);
  }
}

void WiFiAlert::WiFiSendAlert(char *message, char *key)
{
  Serial.print("GET /status/wifialert.aspx?id=");
  Serial.print(ReefAngel.portalusername);
  Serial.print("&key=");
  Serial.print(key);
  Serial.print("&msg=");
  Serial.println(message);
  Serial.println("\n\n");
}

// Initialize Buzzer variables
byte buzzer=0;
byte overheatflag=0;
byte atoflag=0;

// Declare variables for Wifi Alert
static WiFiAlert sumpOverflowAlarm, tempAlarm;
static WiFiAlert atoEmptyAlarm;

void setup()
{
  
// Added buzzer 1-19-13    
// Sound buzzer if any flag is set.
// Added 1-19-13 - Uncomment when I purchase the IO expansion module.
//   buzzer = overheatflag + atoflag + iochannel0flag + iochannel1flag + iochannel2flag + iochannel3flag + iochannel4flag + iochannel5flag;
   buzzer = overheatflag + atoflag;
   if ( buzzer >= 1 ){
     buzzer = InternalMemory.read(buzzer_volume); // Set value of buzzer volume.
 } else {
     ReefAngel.PWM.SetDaylight(0);
   }  
//   Do not sound the buzzer for empty ATO reservior between 7:00 am and 10:00 pm.
   if (!ReefAngel.LowATO.IsActive() && ( hour() >= 7 && hour() < 22)) {
      ReefAngel.PWM.SetDaylight( buzzer );
      atoEmptyAlarm.SetDelay(3600); // delay SMS text alert for 1 hour.
      atoEmptyAlarm.Send("ATO_container_empty","xxxxxxxxxx");
 } else {   
      ReefAngel.PWM.SetDaylight(0);
      if (!ReefAngel.HighATO.IsActive()) { 
        ReefAngel.PWM.SetDaylight( buzzer );
        sumpOverflowAlarm.SetDelay(300); // delay SMS alert for 5 minutes.
        sumpOverflowAlarm.Send("Sump_WaterLevel_too_high","xxxxxxxxxx");
    } else {
        ReefAngel.PWM.SetDaylight(0);
      }
   }    
Thanks for your help,
John
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

So two things to check...is it just the ato empty alarm being flakey? Or both?

What is the IP the alert is coming from? I did have a false alarm early on but it was from someone or some bot clicking in this thread...i changed the url in the post and havent had any others..

We may need some logs from roberto to see if these hot queued up on his end or if he's getting valid alerts from your controller.

The code looks good at first glance.
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

lnevo wrote:So two things to check...is it just the ato empty alarm being flakey? Or both?

What is the IP the alert is coming from? I did have a false alarm early on but it was from someone or some bot clicking in this thread...i changed the url in the post and havent had any others..

We may need some logs from roberto to see if these hot queued up on his end or if he's getting valid alerts from your controller.

The code looks good at first glance.
They are both sending false alerts, but the ATO empty occurs every few minutes where the Sump overflow occurs every few hours. The buzzer works flawlessly and is triggered by the same float switches.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

Ok a few strange things i noticed.

One is you have all that code in setup() and not in loop()...not sure why that would make a difference, but something worth correcting, I had a block of code in setup and it was behaving completely different than what I'd expect.

Second you have your wifi alarm variables as globals and static which might cause it to behave strangely. Try taking off the static or leaving it but putting it inside setup or eventually to loop.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

mudcat1 wrote:They are both sending false alerts, but the ATO empty occurs every few minutes where the Sump overflow occurs every few hours. The buzzer works flawlessly and is triggered by the same float switches.
Are you sure the empty is alarming every few minutes...the overflow is the one with the 5 minute delay...
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

lnevo wrote:Ok a few strange things i noticed.

One is you have all that code in setup() and not in loop()...not sure why that would make a difference, but something worth correcting, I had a block of code in setup and it was behaving completely different than what I'd expect.

Second you have your wifi alarm variables as globals and static which might cause it to behave strangely. Try taking off the static or leaving it but putting it inside setup or eventually to loop.
Lee,
I tried to make my code similar to yours, however, I was not sure how to use the #include statement as you did so I copied the wifialert() code immediately following the include statements. I added the static declaration because I saw it in your ino but I will remove it shortly.
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

lnevo wrote:
mudcat1 wrote:They are both sending false alerts, but the ATO empty occurs every few minutes where the Sump overflow occurs every few hours. The buzzer works flawlessly and is triggered by the same float switches.
Are you sure the empty is alarming every few minutes...the overflow is the one with the 5 minute delay...
Yes, the ato empty alert was occurring more frequently than the sump overflow.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

mudcat1 wrote:
lnevo wrote:Ok a few strange things i noticed.

One is you have all that code in setup() and not in loop()...not sure why that would make a difference, but something worth correcting, I had a block of code in setup and it was behaving completely different than what I'd expect.

Second you have your wifi alarm variables as globals and static which might cause it to behave strangely. Try taking off the static or leaving it but putting it inside setup or eventually to loop.
Lee,
I tried to make my code similar to yours, however, I was not sure how to use the #include statement as you did so I copied the wifialert() code immediately following the include statements. I added the static declaration because I saw it in your ino but I will remove it shortly.
The main thing I'm concerned about is your custom code should all be inside loop() not inside setup() which is what you showed. But the static thing is easy to fix.
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

Sorry Lee, i didn't read your post closely enough. I do have my custom code in the void loop() section, I just forgot to copy it in the snippet section that I provided.

Code: Select all

    // ************ PLACE GLOBAL VARIABLE CODE BELOW HERE *******************

    class WiFiAlert
    {
    public:
      WiFiAlert();
      void Send(char *message, char *key);
      inline void Send(char *message) { Send(message,""); }
      inline void SetDelay(int delay) { AlertDelay=delay; }
    private:
      int AlertDelay;
      time_t LastAlert;
      boolean IsAlert();
      void WiFiSendAlert(char *message, char *key); 
    };

    WiFiAlert::WiFiAlert()
    {
      AlertDelay=900;
      LastAlert=0;
    }

    boolean WiFiAlert::IsAlert()
    {
      if (now()-LastAlert >= AlertDelay)
      {
        return true;
      }
      return false;
    }

    void WiFiAlert::Send(char *message, char *key)
    {
      if (IsAlert())
      {
        LastAlert=now();
        WiFiSendAlert(message, key);
      }
    }

    void WiFiAlert::WiFiSendAlert(char *message, char *key)
    {
      Serial.print("GET /status/wifialert.aspx?id=");
      Serial.print(ReefAngel.portalusername);
      Serial.print("&key=");
      Serial.print(key);
      Serial.print("&msg=");
      Serial.println(message);
      Serial.println("\n\n");
    }

    // Initialize Buzzer variables
    byte buzzer=0;
    byte overheatflag=0;
    byte atoflag=0;

    // Declare variables for Wifi Alert
    WiFiAlert sumpOverflowAlarm, tempAlarm;
    WiFiAlert atoEmptyAlarm;

    void setup()
    
    void loop()
   {
     
    // Added buzzer 1-19-13   
    // Sound buzzer if any flag is set.
    // Added 1-19-13 - Uncomment when I purchase the IO expansion module.
    //   buzzer = overheatflag + atoflag + iochannel0flag + iochannel1flag + iochannel2flag + iochannel3flag + iochannel4flag + iochannel5flag;
       buzzer = overheatflag + atoflag;
       if ( buzzer >= 1 ){
         buzzer = InternalMemory.read(buzzer_volume); // Set value of buzzer volume.
    } else {
         ReefAngel.PWM.SetDaylight(0);
       } 
    //   Do not sound the buzzer for empty ATO reservior between 7:00 am and 10:00 pm.
       if (!ReefAngel.LowATO.IsActive() && ( hour() >= 7 && hour() < 22)) {
          ReefAngel.PWM.SetDaylight( buzzer );
          atoEmptyAlarm.SetDelay(3600); // delay SMS text alert for 1 hour.
          atoEmptyAlarm.Send("ATO_container_empty","xxxxxxxxxx");
    } else {   
          ReefAngel.PWM.SetDaylight(0);
          if (!ReefAngel.HighATO.IsActive()) {
            ReefAngel.PWM.SetDaylight( buzzer );
            sumpOverflowAlarm.SetDelay(300); // delay SMS alert for 5 minutes.
            sumpOverflowAlarm.Send("Sump_WaterLevel_too_high","xxxxxxxxxx");
        } else {
            ReefAngel.PWM.SetDaylight(0);
          }
       }   
Sorry for the confusion.
John
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

Another thing that I noticed is that the time on the SMS text alert is incorrect. The text message that I receive says ...

"(Reef Angel - Alert) Reef Angel Controller AlertTime: 6/3/2013 5:46:46 PM IP Address: xxx.xxx.xxx.xxx ATO_container_empty"

The actual time is 7:46 PM. Is there a date setting that can be adjusted so that the time on the alert is correct?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

That doesn't even make sense. Unless the float switch is getting triggered for a blip not enough to trigger the buzzer.

Can you add a Serial.println(buzzer); before the atoAlarm.Send(); and monitor for a bit through Serial Monitor?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by rimai »

mudcat1 wrote:Another thing that I noticed is that the time on the SMS text alert is incorrect. The text message that I receive says ...

"(Reef Angel - Alert) Reef Angel Controller AlertTime: 6/3/2013 5:46:46 PM IP Address: xxx.xxx.xxx.xxx ATO_container_empty"

The actual time is 7:46 PM. Is there a date setting that can be adjusted so that the time on the alert is correct?
That would have to be modified in the server to accept GMT offset.
Currently, it will use the server's local time.
Roberto.
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

lnevo wrote:That doesn't even make sense. Unless the float switch is getting triggered for a blip not enough to trigger the buzzer.

Can you add a Serial.println(buzzer); before the atoAlarm.Send(); and monitor for a bit through Serial Monitor?
Lee,
I added the Serial.println(buzzer); before the atoAlarm.Send() and received the following output from Serial Monitor.

Code: Select all

GET /status/submitp.aspx?t1=793&t2=739&t3=0&ph=1045&id=mudcat1&em=0&rem=0&key=xxxxxxxxxx&atohigh=1&atolow=1&r=49&ron=0&roff=255&pwma=45&pwmd=0&c0=160&c1=160&c2=50&c3=0&c4=50&c5=15&c6=45&c7=45


0
GET /status/wifialert.aspx?id=mudcat1&key=xxxxxxxxxx&msg=ATO_container_empty



0
0
Eventually the ATO container was actually empty so that buzzer sounded but when I checked the Reef Angel it appeared to be locked up and the Reef Angel display was black, so I did not receive the Serial Monitor output for the actual alarm. I just cycled power to the Reef Angel and will run Serial Monitor a little longer.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

I think you are getting noise on your float switch that may not be causing your buzzer to go off...maybe for one millisecond..thats the only way those Serial.print would get triggered....unless some bracket is missing somewhere causing the code blocks to be messed up...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

Actually you can see in the output the reason your buzzer is not going off is because the volume is 0.

However, your float is definitely getting triggered.... You can even see the Serial.print happen followed by the alarm.
You can then see subsequent triggering of the Serial.print followed by no alarm. It looks like the alert is working properly...

Code: Select all

0
GET /status/wifialert.aspx?id=mudcat1&key=xxxxxxxxxx&msg=ATO_container_empty



0
0
What condition do you set the volume of the buzzer maybe you can add the additional checks in this block of code. You could even wrap the atoEmptyAlarm.Send() like this:

if(buzzer > 0) atoEmptyAlarm.Send();

I think thats your best course of action..
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by mudcat1 »

lnevo wrote:Actually you can see in the output the reason your buzzer is not going off is because the volume is 0.

However, your float is definitely getting triggered.... You can even see the Serial.print happen followed by the alarm.
You can then see subsequent triggering of the Serial.print followed by no alarm. It looks like the alert is working properly...

Code: Select all

0
GET /status/wifialert.aspx?id=mudcat1&key=xxxxxxxxxx&msg=ATO_container_empty



0
0
What condition do you set the volume of the buzzer maybe you can add the additional checks in this block of code. You could even wrap the atoEmptyAlarm.Send() like this:

if(buzzer > 0) atoEmptyAlarm.Send();

I think thats your best course of action..
Thanks Lee. I will try your suggestions.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

Hey Roberto,

I've definitely been having some odd issues since adding in this code to my INO. I been having some strange issues like today I noticed that the portal hasn't updated since 6/15. I had some odd alerts at that time I was getting power outage alarms which I got to silence by resetting the expansion bus. Reading from the controller was working but obviously it was not sending to the portal.

Also, in troubleshooting code with another user and adding Serial.print's he was having the wifi not work at all. I'm wondering if there is something I'm missing after an alert to reset the wifi module or something and maybe it's not in the right state.

Anyway, the occasional wifi lockups. Any insight? I'd love to submit a patch to include this in the libs.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by rimai »

Humm. Not so sure...
Does it happen if you use the old code too?
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

I was never using the old code. It doesn't happen all the time and may not even be related as I've had other network issues going on as well.. was hoping there would be some strings that I'm missing to send to flush the wifi module. As far as what's being printed to the serial it's pretty much the same as before a GET request with two newlines...
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: I can't find the WifiSendAlert() function in the librari

Post by rimai »

I may need to add your code to check when I get some time.
I've been using the old one for about 3 years and it works fine, but the old one doesn't have the portal integration either.
The problem with the portal integration is that one server needs to forward requests to another one through a proxy.
It could be that, but it is nothing different than what we are all already doing with the Portal() function.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

The strangest thing is that my RA was not sending or was not registering properly updates to the portal, but was able to read/write no problem from iphone.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

I think I figured out what my issue is....

I mentioned that the problems started when I added the code to my INO, but I was also home for 3 weeks which is how I got so much coding done recently to begin with. Anyway, the internet on my WiFi has been having all kinds of other issues latetly and I've been banging my head over it. It finally dawned on me today that the new 2.4Ghz baby monitor in the house is probably the culprit. :) I'll be checking my wifi when I get home tonight, but I'm pretty sure that's what is causing my problems.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

So, the interference was definitely from the baby monitor. As soon as I unplug it internet starts working much better and I don't lose my connection as much. I did however upgrade the firmware on the wifi module and that has helped a lot. The only time I've lost connection the device reconnected and I was able to maintain my connection. For anyone that has wifi problems with their module, I recommend checking for other 2.4Ghz wireless devices and definitely look at the 4.0 WiFly firmware.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

Here's the latest version. Updated for 1.1.0 (requires a patch to RA_Wifi class to add portalkey)
Attachments
WiFiAlert.zip
(17.33 KiB) Downloaded 654 times
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: I can't find the WifiSendAlert() function in the librari

Post by lnevo »

Download and unzip in libraries folder...what else do you need? :)
Post Reply