0

How create a new feed = old feed x 2?
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

How create a new feed = old feed x 2?

by glimmerstumpen on Wed Apr 21, 2021 2:13 pm

Is it possible to create a new feed from an existing feed where the new feed is a basic mathematical operation of an existing feed?

I want to do this because;

I am returning the distance from an ultrasonic sensor to a water level in a tank, in cm.

I would like to create a new feed from this data that is the % full of the tank.

So say I receive the value 99 in my feed from ESP. I want to create a new feed (and line graph) where this value would work out to be say 50%

I can easily calculate this and return the % from the ESP8266 as the raw value, but its different for each tank and its a more general solution to just return the raw distance to water surface.
Cheers

glimmerstumpen
 
Posts: 2
Joined: Wed Apr 21, 2021 2:00 pm

Re: How create a new feed = old feed x 2?

by brubell on Fri Apr 23, 2021 9:47 am

Is it possible to create a new feed from an existing feed where the new feed is a basic mathematical operation of an existing feed?


It should be - you'd use the Create Feed endpoint (see: https://io.adafruit.com/api/docs/#create-feed) to send a request to Adafruit IO to create a new feed.

brubell
 
Posts: 1381
Joined: Fri Jul 17, 2015 10:33 pm

Re: How create a new feed = old feed x 2?

by glimmerstumpen on Wed Apr 28, 2021 12:48 am

Thanks for that I had a look at the request to create a new feed.
Is this something that is static?

I was hoping there would be a way to have the new feed continuously updated from the old feed within the adafruit io cloud framework. The reference docs seem to indicate that you would need to call this command every time you wanted the new feed updated from the old. Is that correct?

If thats true then to make it "live" I would need a separate service/script running on my computer to continuously update the new feed from the old.

cheers

glimmerstumpen
 
Posts: 2
Joined: Wed Apr 21, 2021 2:00 pm

Re: How create a new feed = old feed x 2?

by millercommamatt on Wed Apr 28, 2021 2:02 am

You could write a simple python function do this and have it run on AWS lambda and stay easily in the free tier.

Also, it would be nice if the Adafruit IO dashboards supported simple math operations for unit conversions and the like.

millercommamatt
 
Posts: 649
Joined: Tue Jul 31, 2018 4:57 pm

Please be positive and constructive with your questions and comments.