Skip to content

IciaCarroBarallobre/Eustaquia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌱 Eustaquia

Eustaquia is a playful project that lets a plant “talk” when it’s thirsty. A GRiSP2 board running Erlang reads soil humidity via I²C and drives a servo to switch a face from happy 😀 to sad 😢 — a simple way to explore GRiSP, embedded Erlang, and basic electronics.

Animation ExampleReal test
Eustaquia animationReal test

How it works

stateDiagram-v2
    [*] --> OutOfSoil

    OutOfSoil : Sensor out of soil
    OutOfSoil : Face = Sad (down)
    OutOfSoil --> Measuring : Inserted in soil / Start reading

    Measuring : Reading humidity via I²C
    Measuring --> Happy : Humidity >= Threshold
    Measuring --> Sad : Humidity < Threshold

    Happy : Face = Happy
    Happy --> Measuring : 5s Timer / Recheck humidity

    Sad : Face = Sad (down)
    Sad --> Measuring : 5s Timer / Recheck humidity
Loading

In short:

  1. When the sensor is not in the soil, the face stays down (sad).
  2. Once in the soil, humidity is read every 5 seconds over I²C.
  3. If humidity is above the threshold → Eustaquia smiles 😀.
  4. If humidity is below the threshold → face stays sad 😢.

Tip: The initial state looks like the sad face. To confirm everything works, dip the sensor in water and watch it switch to happy.

Concepts

  • I²C (Inter-Integrated Circuit) — Protocol for talking to devices over two lines: SDA (data) and SCL (clock). GRiSP supports it via grisp_i2c. Used here to read the soil moisture sensor (seesaw protocol).

  • PWM (Pulse Width Modulation) — You turn the signal on and off quickly; the duty cycle (percentage of time on) controls the effect. GRiSP provides grisp_pwm, which we use to drive the servo (happy vs sad position).

Components and wiring

See docs/WIRING.md for the step-by-step wiring guide.

Real Image 1Real Image 2
Real imageReal image: how to connect all items

Build and deploy (SD card)

  1. Compile: rebar3 compile
  2. Deploy to GRiSP: rebar3 grisp deploy
  3. Insert the SD card into the board and power it on.

See the GRiSP wiki for more detail.

Documentation

Generate docs locally:

rebar3 ex_doc
open doc/index.html

Testing

Connect to the GRiSP shell (e.g. over serial), then run the tests below.

Step 1 — Hardware

  • Power the GRiSP (USB or external).
  • Plug the PMOD I²C into the board (external bus, usually i2c1).
  • Connect the soil sensor with the 4-wire cable: VIN → PMOD VCC, GND → GND, SDA → SDA, SCL → SCL. Do not swap SDA and SCL.
  • If using the servo: connect the PMOD R/C Servo and servo as described above.

Step 2 — Compile and flash

  • In the project root: rebar3 compile. Fix any deps with rebar3 deps if needed.
  • Flash: rebar3 grisp deploy (or rebar3 grisp burn). Insert the SD card if required, then power the board.

Step 3 — Open the Erlang shell

  • Connect over serial (see GRiSP wiki).
  • Start the app if it does not start automatically; you should be able to call the project modules.

Step 4 — Check the sensor

In the shell:

1> eustaquia:check_sensor().
Checking soil sensor (I2C seesaw)...
  Moisture: 850 (typical range dry 200, wet 2000)
  Temperature: 22.5 °C
Done. If both OK, sensor is working.
ok

If you see reasonable values (moisture ~200–2000, temperature in °C), the seesaw protocol and sensor are working. On error, check wiring (VIN, GND, SDA, SCL), PMOD connection, and bus (i2c1). You can run grisp_i2c:detect(i2c1) to list I²C addresses (sensor is usually 0x36).

Step 5 — Optional tests

  • eustaquia:test_moisture(). — Read humidity once.
  • eustaquia:test_servo_happy(). / eustaquia:test_servo_sad(). — Move the servo to happy or sad.
  • eustaquia:loop(). — Full loop: every 5 s read humidity and update the face. Stop the process to exit.

Future ideas

  • Notifications — Notify your phone when the plant is thirsty.
  • Plant network — Several plants on BEAM nodes sharing state (e.g. a “neighborhood watch” so you see which one needs water).
  • Configurable humidity threshold — Make the dry/wet threshold configurable (e.g. via config or shell) so you can tune it per plant or soil type.

Further reading

About

A fun, beginner‑friendly way to explore GRiSP, embedded Erlang, and simple electronics. Eustaquia is a playful project that let's a plant "talk" when it's thirsty, reading soil humidity and using a servo motor - to change a face from sad to happy.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages