Detection of a high value change | ThingSpeak Apps | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Detection of a high value change
No permission to create posts
January 18, 2019
3:47 pm
Avatar
naturepur
New Member
Members
Forum Posts: 4
Member Since:
January 18, 2019
sp_UserOfflineSmall Offline

I am a beekeeper (not a software developer ;.)) and I am using a weight system under my beehive which is connected to a Raspberry Pi. The RasPi sends the weight value to a free of charge Thingspeak channel. With Thing React and IFTTT I configured a notification when the weight value changes below a special limit. With such a beehive weight system I can see how much honey my bees collected during a day in summer and how much sugar they consumed in winter.

My goal is to get a notification when the weight value changes suddenly with a high difference (beehive escaped or beehive was stolen). I think that it should be possible to derive the value curve of the weight system and to visualize the 1st derivation of that curve in a separate curve. And then it should probably be possible to send a notification if the value of 1st derivation goes over a specified limit.
But I do not know how the program code has to be implemented.

Is there anybody outside who can help me with that? Do you have a code example?

Thanks a lot
naturepur

January 21, 2019
6:01 am
Avatar
rw950431

Top
Members
Forum Posts: 279
Member Since:
January 29, 2014
sp_UserOfflineSmall Offline

How many times a day do you update the channel?
How often do you want to check the weights?

One possible way is to use the TimeControl App to trigger a Matlab analysis to query the last 2 or more readings and take the difference between the first and last. Actually sending a notification is perhaps the hardest bit of this puzzle- only Twitter is supported "out of the box" and there is no straightforward way to send an email.

January 23, 2019
9:23 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 573
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

You can also use IFTTT to send notifications, though it may not be as 'out of the box' as the twitter solution.
Have a look at
https://www.mathworks.com/help/thingspeak/analyze-channel-data-to-send-email-notification-from-ifttt.html
I have one webhook set up at IFTTT and I use it for notifications on multiple channels. Since you can also send a value with the post to IFTTT webhooks, I also send a word that indicates which channel triggered the email notification.

I think rw950431 is correct that two values (or a few) is probably better than fitting the derivative. You can use thingSpeakRead() in MATLAB analysis to get the values and then compare them. Then call webwrite() to the IFTTT url to get a notification (if the comparison is positive).

Thanks for sharing your application! Beekeeping is a great addition to the ThingSpeak uses.

January 25, 2019
8:58 am
Avatar
naturepur
New Member
Members
Forum Posts: 4
Member Since:
January 18, 2019
sp_UserOfflineSmall Offline

Hey guys,

thanks a lot for your help and ideas how to solve my requirements. I will try to follow your hints to read and compare the values using MATLAB analysis and then I will use IFTTT to push a notification.

Today I am already using IFTTT to send a notification when the weight is lower than a defined, constant value. But this not yet fulfills my requirements, because the weight of a beehive can be very different during a year. The solution is to detect a sudden high different in the weight.

However thanks a lot for your answers and tips.

January 25, 2019
11:54 am
Avatar
piajola

Gold
Members
Forum Posts: 104
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

Hi naturepur

Assuming you record the beehive weight each hour, then 24 numbers a day
Create one TimeControl to run each 12 hours and read the last 12 records (run matlab analysis code)
Then find Min and Max (functions in Matlab) so you have the "range of beehive-weight", then divide Min/Max so the fraction near to 1 is no variations and the fraction "more-near-to-zero" is a well different to the uniform weights, ie. fraction 0.3 then use IFTTT

To convince you,
10
9
8
9
8
11
12
9
10
10
5
5

So Min=5 and Max=12 5/12=0.4 then this fraction is "more-going-to-zero" ... it deserves IFTTT help

In a semi-pseudo-code (means do it in proper syntax)

[weights, timeStamp] = thingSpeakRead(yourChannel, 'fields', [x y necessary fields], 'numPoints', 12,'OutputFormat','table');
disp(weights); % to see the list of weights

xx=min(weights.yourfieldname); % the variable with the Minimum weight
yy=max(weights.yourfieldname); % the variable with the Maximum weight
disp(xx); % to see in Output window
disp(yy);

alarmed=xx/yy;

if alarmed<=0.6 then % the fraction is YOUR magic number
response=webwrite(strcat('https://maker.ifttt.com/trigger/',makerEvent, ...
'/with/key/', makerKey), ...
'value1', xx, ...
'value2', yy, ...
'value3', datestr(datetime('now'),30));
endif

Keep the bees fine mother earth needs (lots of) people like you
I hope this works for you and is of some help Smile
(Batteries not included but questions allowed)

February 2, 2019
4:04 pm
Avatar
naturepur
New Member
Members
Forum Posts: 4
Member Since:
January 18, 2019
sp_UserOfflineSmall Offline

Hi piajola,

thank you so much for your help.
In the meantime I have found a very similar solution which is - I must admit - not so perfect as the one you described.
Anyhow, I also have used timecontrol to trigger a Matlab Analysis.

My Raspi sends every 5 minutes a new weight value to Thingspeak. In the Matlab Analysis (triggered by Timecontrol every 5 minutes) I read the last 2 values out of the field and then I use diff(data) to check the difference. If the difference is negative and below of a configurable limit, then I use React and IFTTT to send a notification to my smartphone.

This solution works quite good, but I will try to improve it following your instructions.

Now all the programming and electronic work is nearly completed and I only have to install the weight system below the "rear" of my bees ;-))
When everything is installed and ready then I will publish the channel. So everybody will be able to follow what happens to my bees.
Besides the weight system I also prepared an inside (beehive) and outside temperature sensor as well as an air pressure and air humidity sensor.

Thank you again for your comprehensive solution proposal!

naturepur

February 3, 2019
11:24 pm
Avatar
piajola

Gold
Members
Forum Posts: 104
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

Hi naturepur,

Glad you find my "way" helpful
Waiting for the channel number
Any question(s) from you are very well welcome, glad to help in keeping the bees safe

Keep the good work Wink

February 10, 2019
12:50 pm
Avatar
naturepur
New Member
Members
Forum Posts: 4
Member Since:
January 18, 2019
sp_UserOfflineSmall Offline

Hi piajola,

you are invited to visit my channel. The system is in test run now (without bees ;-)). There is still some cabling and installation work to be done. Probably in March I will be ready to set the real beehive on top of the weight system.

To find my channel look for "naturepur".

Thanks again for your help.

...waiting for spring...
naturepur

February 10, 2019
11:37 pm
Avatar
piajola

Gold
Members
Forum Posts: 104
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

Hi naturepur,

I will be looking for your channel
It will be interesting to know how much honey beehives produce (by the grams?)

Thank you for invite me to see the bee "work" in the beehive 8^) ... a little more than a month for the equinox

Good luck

February 12, 2019
10:02 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 573
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Nice channel! I like the bee video too. Do you still need help with the three line comparison? There may be a better way to do that with MATLAB plots, that example was originally designed for thingSpeakPlot, which is being deprecated.

February 14, 2019
5:50 pm
Avatar
piajola

Gold
Members
Forum Posts: 104
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

Hi naturepur,

I was playing (but seriously) with your public channel, try
- - - - - - - - - - - - - - - - - - - - - - - - - -
[weights, timeStamp] = thingSpeakRead(624932,'fields', [1], 'numPoints', 15,'OutputFormat','table');
disp(weights); % to see the list of weights

xx=min(weights.Gewicht); % the variable with the Minimum weight
yy=max(weights.Gewicht); % the variable with the Maximum weight
disp(['minimum ' num2str(xx) ' -- maximum ' num2str(yy)]);

alarmed=xx/yy;
disp(['weight variation ' num2str(alarmed)]);

if alarmed<=0.06 then % the fraction is YOUR magic number
response=webwrite(strcat('https://maker.ifttt.com/trigger/',makerEvent, ...
'/with/key/', makerKey), ...
'value1', xx, ...
'value2', yy, ...
'value3', datestr(datetime('now'),30));
disp(response);
end
- - - - - - - - - - - - - - - - - - - - - - - - - -

with your data last 15 records are about 4 hours, this is my wild guess. Please correct that ... you are the bee expert

alarmed<=0.06 is to be sure to not send notifications. You need to put valid makerEvent and makerKey ... then replace .06 with 1 to send the notification to see this work.
Then you put your real magic number to be really alarmed, your bees are gone without saying bye
You can try with REACT on data insertion so each time you send your weight you recheck your last 4 hours but you are notified 18 minutes after the problem
You can use TIMECONTROL for example each hour but you are notified 1 hour after the problem ... you get the figure

This is to start you in this programming game I hope. I repeat asking is allowed Smile

February 17, 2019
1:52 pm
Avatar
piajola

Gold
Members
Forum Posts: 104
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

Hi naturepur,

Why is the beehive1 weight going more negative ? yesterday -4 and today -20 ? just curious ...

Regards

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
28 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

kalev, altafali53, harpsler, Sukumar, Monika, aagehmanflor

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457