Hello Nerves magicians,
I am new to hardware programming but I use elixir professionally for web development.
For my horses I want to use my Raspberry Pi to build a timer that controls an electric shutter. The shutter should open every hour for 20 minutes and then close again.
I know that there are probably easier ways to reach that goal than to use nerves (so many tutorials for python), but I have been yearning to try some nerves programming. For a web developer who does not know much about using GPIOs to pass signals to a relay that powers the electric shutter engine that has four wires. One for up one for down one for phase and one for ground.
How would I control the electric shutter engine using elixir?
I am also grateful for any advice you can give me about how to connect a relay to the Raspberry Pi (as i said total beginner…).
You will probably want to check out https://github.com/elixir-circuits/circuits_gpio if you plan to directly control some hardware that can be controlled by 3.3V I/O pins on the Pi. If you’re using something like the Automation Hat on your Pi, then you’d need to look at how that connects to the Pi in terms of SPI/I2C/GPIO and then use the appropriate Elixir Circuits library to send the commands to it (perhaps referring to the docs and Python examples that come with the board).
From there, it’s just a matter of setting up the processes/supervision tree in Elixir-land to make the correct function calls at the right time!
There are some simple-to-use libraries on the Elixir side for that, given that the timescales you’re talking about are on the order of minutes and not milliseconds. For example, check out the Quantum library, which I think allows you to configure your events using cron syntax. If you want to roll it yourself as a learning experience, though, it also isn’t too complicated.
Thanks for your input Greg. I will certainly use the two libraries you pointed out.
Do you have any suggestions for testing? I do not want to attach the engine yet, so how do I test that the correct signals are being sent at the correct times? This is not really an elixir question, but rather how to setup an environment where I can code and quickly test what I have done and visually see the results. Like a LED perhaps?