Using AMPL with Node red

#1

Hello, it might be an unusual question but here it is:
I'm working on a smart irrigation system with NodeMCU and Node red using MQTT protocol, and I'm using dht22 and soil moisture sensors to collect data evey 30 s.
Now I want to add a combinatorial optimization ( to have the exact amount of water needed by the plant) using AMPL A Mathematical Programming Language, I want to use the sensors' data like temperature, soil moisture.. and use them in the calculation of AMPL every 30 seconds, and then use the decision of how much water should I use (how long should I turn on the water pump).
If anyone have an idea if that is possible or how to do it, please enlighten because I'm lost.

0 Likes

#2

Are you able to write an AMPL script that does the calculations you want? If so then you could call that every 30 seconds using an exec node, to get the required time.

1 Like

#3

Is it possible to run a file with it ? I mean when I use the IDE I type: ampl: include exemple1.run, could the exec node do a similiar thing (This is the first time I hear about it sorry)

0 Likes

#4

I don't know anything about the IDE, but presumably somehow you can write a script that you can call to do that from the command line. Find out how to run it from the command line and then you put that in an exec node.
Are the calculations so complex that you cannot convert them easily to javascript? Then you just put that in a Function node and trigger it every 30 seconds.

1 Like

#6

I didn't think about that actually, but It is a solution of a non linear equation problem using dynamic programming. so I think it is complicated :confused:

0 Likes

#7

OK, well you just need to find out how to call it from the command line rather than within the IDE. I will be astonished if that is not possible.

0 Likes

#8

Okay I'll try to, Thank you very much! :smiley:

0 Likes

#9

By the way, others here have solved the irrigation problem by using PID control of the water injection to control soil moisture content.

Also I think the DHT22 is considered a poor sensor, by some at least. See

1 Like

#10

It seems like what I want to do, I'll check it out, Thanks!

0 Likes