AI on Arduino (learning Irrigation Station)

25,814

332

30

Introduction: AI on Arduino (learning Irrigation Station)

Artificial Intelligence of my Arduino consists so far of a single soft (programmed) neuron, which I can teach and leave my pot flowers' irrigation in the trust of.

In this instructable we are going to implement an artificial neuron into Arduino. I visited a whole class :) of neurology course, so I can explain it's functioning to you in detail.

A neuron is a unit making decision on the basis of synapse signal (input 0-1) and a weight (importance) of this signal. Say we have a neuron whose synapse is coming from a soil moisture sensor. Weight (excitation threshold) is the level of the signal by which a neuron knows that the soil is dry enough and needs watering.

But every flower has its own comfortable moisture level. That's where a backpropagation can be implemented. By manually watering the flower pot we instruct our neuron what should be the weight of the signal or excitation threshold.

Now you know almost everything a certified neurologist knows about your brains.

Step 1: ​How Can We Put This in Practice?

Simple. We use quantum computing of the neuron coherent state linear superposition...

Just kidding! No, we use:

You just wire everything to Arduino's pins according to the diagram in this step.

I added 4 digit LED inicator to show current moisture level

  • pin SCLK = 7; // CLOCK
  • pin RCLK = 6; // LATCH
  • pin DIO = 5; // DATA and GND

*I modified a soil moisture sensor by replacing it's copper probes with 5cm long stainless steel rods to prevent them from decay due to galvanizing (see pic).

Step 2: Arduino Sketch

Upload the sketch into your Uno and power it up.

To make the process more obvious I added a 7 segment 4 digit LED indicator.

It is indicating current moisture level in relative units (0-255, actually about 40-150). Learned threshold is indicated to COM port monitor of Arduino IDE.

Step 3: ​Learning

When you assembled the station you need to teach it the moisture level it should maintain. Learning is the most crucial for this project!

I upgraded my neuron so it can learn anytime. Anytime when the pot had been watered not by the neuron itself, it understands that that was teaching and remembers the moisture threshold.

You should find the exact soil moisture the flowers must be watered at. And simply add water. Teaching done!

If you need to re-teach the neuron, just pour some water into the pot again manually. I mean let the soil dry to the condition you (or you think your flower) desire and add water. In some cases you will have to disconnect the water tank if you want to teach it drier threshold.

It was one neuron with two synapses. Imagine our brain with 86 billion neurons each having 1000 to 10 000 synapses!

Share

Recommendations

  • Creative Misuse Contest

    Creative Misuse Contest
  • Metalworking Contest

    Metalworking Contest
  • Water Contest

    Water Contest

30 Discussions

Hi,
I'm new to this. Please guide me how to train this by keeping in a pot. I'm not able to train my Arduino.
Thank you

Cool! I'm running a similar project (early stage) but would like to use latching solenoid to limit wiring in my garden. Has anyone any idea where can I find a latching 1/2-3/4" plastic valve for a reasonable price?

1 reply

Very interesting project. In code the #define can be replaced with const, right? But can uint8_t be replaced with byte?

3 replies

As far as I understand you're right. I'm not a C++ artisan, so I can't judge which way is more memory/processor efficient. If you explained the difference I would appreciate it indeed. Thank you!

I'm not a guru and just ask this because I can't find in the Arduino Reference command: uint8_t.

Does it mean that that in this project we want to store into EEPROM a data that occupies just one byte?

Exactly. uint8_t

u - unsigned

int - integer

8 - number of bits

_t - means it's not macros, not function, not procedure, but type

Hi, I´ve built the project, however I don´t really understand the meaning of the sounds and color led.

Can you also explain a bit more, the modification you did the the moisture probe, mine has GND, VCC and SIGNAL however in the picture only two wires are shown,

2 replies

The color led. In current version of the sketch color indicates the moisture level

- Bluish - moist

- Yellow and orange - average

- Red - dry

The more blue - the more moist the soil, the more red - the drier.

Sounds.

It makes sounds when pumping water - you can always disable it, I used it for debugging. Just place two slashes (//) in the beginning of line 134 ( playPump(pump); // pumping for seconds) or just delete the line.

It makes descending alarm sound when water tank is empty. You'd better leave it, it will remind you to fill the tank.

Moisture sensor was once like on picture here, but in my previous project it's probe was eaten out by galvanization within one week (see pic.2). What I did after. I replaced a probe having hieroglyphs with hand-made you can see in the article. It only has two wires which go to the small board with another 4 pins. They are VCC, GND, DO (digital), AO (analogue). I used analogue output along with VCC and GND.

2016-07-26 08.53.45.jpg2016-04-19 15.15.44_191.jpg

Thanks for the upgraded neuron!

Also, I do not understand this line:

if (soilValue > setValue) // current < eeprom, run the pump

If setValue is the value stored in eeprom, then the code

is not it supposed to be:

if (soilValue < setValue) // current < eeprom, run the pump

??

2 replies

You're right. The comment (after //) to this line is ambiguous. It should better be:

// if current (dryness) > eeprom value, run the pump

Actually soilValue is a dryness parameter not moisture. The sensor is made that way. The more dry the soil the higher the value. That's why when it becomes more than set value we have to start the pump.

Отлично. Думаю ардуино нано полойдет?

1 reply

Great project - what software did you use for neuron emulation?

1 reply