Hello to all,
Is there any means to get an alert (Mail or anything else) when my Shake&Boom detect an earthquake or something else special (Boom) . To put some threshold to raise a kind of alarm.
Thanks a lot
Hello to all,
Is there any means to get an alert (Mail or anything else) when my Shake&Boom detect an earthquake or something else special (Boom) . To put some threshold to raise a kind of alarm.
Thanks a lot
You might want to take a look at rsudp.
RSUDP can indeed provide alerts after a certain set treshold (that you will have to manually adjust to better reflect the signals recorded at your location) has been crossed. You can plan for Tweets, Telegram messages, and similar applications.
As a note, the software is more advanced that our classic user interface, and is meant for advanced users who are familiar working from the command-line and have some basic programming experience. It is also provided as is and may or may not work out of the box.
We are always looking for improvements, so if you develop something, we would be glad to see it!
Thanks a lot for your answer,
I’m not anymore a programmer, or developer. I’v done it years ago (RPG2, Cobol, Fortran, BULL GCOS 7, Basic, punch card… etc…) Now i’m just a common user. Do you think that an alerting system could be so hard to develop for the RS&Boom. (Mail , etc) ?
Thanks a lot
Hello mejocama,
Well, the steps that the system would have to follow would be:
It sounds simple, but it requires a dedicated set of instructions. As said RSUDP already does these points, but the configuration is left to the user, because every Shake location is different, and the fine-tuning has to be made for that location in particular.
mejocama,
I know you said that you are no longer a programmer … I think I can say that I pretty much fall into that category myself. It has been many years since I sat down and wrote real code.
But I got to wondering how hard/easy it might be to code something to use the udp data stream that is very easy to configure, and is used by RSUDP - which I did get running, but it really wasn’t that easy … different story (if you know python and anaconda it is probably trivial).
So I set up a second udp stream to my Linux system and wrote a bit of C code to grab the data.
I just extracted the count values, and calculated a rolling average over a window of 250 samples (10 seconds) - very trivial algorithm, not a real rolling average, but it works for my purposes.
Wait for 1000 samples to give the average time to stabilize, then subtract the current average from each data value as it arrives, this gives a small delta value, deviation from that average. Take the ABS value of that, so we are only dealing with positive numbers, and if the deviation is more than some value (I used 1,000) print a message.
Does it work? Well, here is the thing running:
(The -67 at the bottom is a bit of diagnostic output, printing the delta from the average of each value.)
So we had a burst of values with a delta of >1000 … was it real?
Yes, there was something happened there. Times agree.
What would I do next??
Well, probably calculate a rolling average with a small “window” and use that for comparison to the long term average to avoid triggering on single, random spikes, and probably a “dead” period after triggering to avoid a lot of output for a single event. Then add code to execute an arbitrary executable when it triggers - eg a script to send an email.
Could this run on the device itself? Yes, I think so. I probably wouldn’t do that … one other thing to consider is that the OS has been stripped down for reliability etc., so there is no email support.
For what it is worth, this is the code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <limits.h>
#include <errno.h>
#include <time.h>
#define PORT 9999
#define BUFSIZE 1024
#define TRIGGER 1000
int main() {
int sockfd;
char buffer[BUFSIZE];
struct sockaddr_in servaddr;
// Create socket to listen for UDP data from r-shake
if ( (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0 ) {
perror("socket creation failed");
exit(EXIT_FAILURE);
}
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(PORT);
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
bind(sockfd, (struct sockaddr *)&servaddr, sizeof(struct sockaddr));
int n, len, c = 1000;
char *str, *endptr, buf[100];
long val, av = 0L;
while (1) {
// Read a UDP packet
n = recvfrom(sockfd, (char *)buffer, BUFSIZE, 0, (struct sockaddr *) &servaddr, &len);
buffer[n] = '\0';
// Skip if not 'Z' data
if (strncmp(buffer, "{'EHZ',", 7)) continue;
endptr = buffer;
str = buffer + 24;
// Process the packet data -- note built-in assumptions about format
while (*endptr != '}') {
errno = 0;
val = strtol(str, &endptr, 0);
str = endptr + 1;
// Calaculate a rolling average over 250 data points
av = av + ((val - av)/(250 +1));
sprintf(buf, "%10ld\r", val-av); write(1, buf, strlen(buf));
// Countdown to allow average to stabilize
if (c) { --c; continue; }
// Check abs value of latest data point to see if it exceeds the trigger point
if (labs(val-av) > (long) TRIGGER) {
struct tm *local_time;
time_t t;
char *p;
// Print a message with timestamp (local TZ)
t = (time_t) strtol(buffer+7, &p, 0);
local_time = localtime(&t);
printf("Event detected: %s", asctime(local_time));
}
}
}
close(sockfd);
return 0;
}
Sorry to be so late, thanks a lot for your help, i’ll let you you when i m done with this. And if i succeed, i’ll send you some proof of my proud (just for me) result …