gus

gus

Nerves Core Team

Soleil: open source power management hardware for Nerves

Hello everyone,

I’m super excited to announce the first release of my passion project, Soleil! :tada:

What is Soleil?

Soleil is a power management and sleep control board for Raspberry Pi, specifically built for use with Nerves. It allows you to power your project from a battery, charge the battery with USB-C or a solar panel, and features a low-power mode to save battery. There are three wakeup sources so you can control exactly how and when your board powers on.

Additionally, Soleil has the ATECC608A chip (aka NervesKey) onboard to support secure connections to NervesHub.

And finally, the v0.2 board also features a Qwiic connector which allows you to easily plug into a huge ecosystem of third-party electronics. Soleil allows you to focus on building your portable or low-power project without worrying about how to power it.

Software

There is a Nerves system to support Soleil, as well as an Elixir driver library which includes convenience functions for interacting with the hardware.

Getting started is quite easy. From a new Nerves project, add the dependencies and target:

defmodule MyApp.MixProject do
	use Mix.Project

	@app :my_app
	@version "0.1.0"
-	@all_targets [:rpi3]
+	@all_targets [:soleil_rpi0_2]

    # ...

	defp deps do
		[
		    # ...
-			{:nerves_system_rpi3, "~> 1.29.1", runtime: false, targets: :rpi3},
+			{:soleil_system_rpi0_2, "~> 1.29.1", runtime: false, targets: :soleil_rpi0_2},
+			{:soleil, "~> 0.1.1", targets: @all_targets},
			# ...
		]
	end

Then, in your config/target.exs add the following config:

+ config :nerves_time, rtc: Soleil.MCP7940

Finally, add Soleil to your application tree:

defmodule MyApp.Application do

  def start(_type, _args) do
    children =
      [
	    # ...
+		{Soleil, battery_capacity: 2000, battery_energy: 7400},
      ] ++ children(Nerves.Runtime.mix_target())

    opts = [strategy: :one_for_one, name: SoleilDemo.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

The parameters battery_capacity (in mAh) and battery_energy (in mWh) depend on the battery you connect to the board. These values are used by the onboard fuel gauge chip to estimate the remaining battery life.

From here, you have access to all of the Soleil helper functions. You can read the battery info:

iex> {:ok, info} = Soleil.battery_info()
iex> info
%{
	voltage: 3.82,             # volts
	current: 0.202,            # amps
	temperature: 29.34,        # °C
	state_of_charge: 82,       # % battery remaining
}

To control the Soleil low power mode, you can use:

iex> Soleil.sleep_for(5, :hour)
:ok
iex> Soleil.sleep_until(~N[2026-01-01 00:00:00])
:ok
iex> Soleil.power_off()
:ok

On boot, it is often useful to know why Soleil woke up (was it a scheduled alarm, or a manual override?)

iex> Soleil.wakeup_reason()
:alarm

Customization

This project is completely open source with a permissive license. Not only do I want to share it, but I hope that people who need this type of power solution for their projects are enabled to modify the hardware themselves. That’s why, in v0.2 of the hardware, I have moved all of the components to the left side of the board, allowing for a significant open space for you to add your own sensors, connectors, etc.

The source files are available in GitHub, with a well-documented schematic. If you want to make changes, you can easily do so using KiCad, the open source PCB design software.

I will make a video about how to customize Soleil soon!

Project Next Steps

  • If there is enough interest, I want to organize a group buy of the hardware for Q2 this year. I expect that the price would be around $30-35 USD + shipping. Fill out the waitlist form or send me a message to confirm your interest :slight_smile:
  • I am going to discuss more about Soleil (and open source hardware for Nerves in general) at the February edition of the online Nerves Meetup. This would be a good place to learn more about the project and ask questions (plus it is full of cool people!)
  • I’m considering developing other variants of Soleil, such as a LoRa version or a weather station variant. If these interest you or you have other ideas, let me know!
  • I think there’s a lot more interesting and useful projects for this model of open source hardware - stay tuned for more info soon :eyes:

Links

Some of the resources for this project are spread across multiple repositories, so I want to list them all here:

Project homepage

Hardware:
Soleil Hardware
Hardware technical overview and schematic

Software:
soleil_system_rpi0_2 (hex)
soleil (hex)
soleil demo project

If you want to follow me, I post project updates on BlueSky:

Most Liked

Margaret

Margaret

Really cool! Also, great timing with the other poster @cblavier who was asking about power management.

@gus if you’d be interested in authoring a short project-based book like: Build a Binary Clock with Elixir and Nerves: Use Layering to Produce Better Embedded Systems by Frank Hunleth and Bruce A. Tate
and
Build a Weather Station with Elixir and Nerves: Visualize Your Sensor Data with Phoenix and Grafana by Alexander Koutmos, Bruce A. Tate, Frank Hunleth
that focuses on a project that uses Soleil, hit me up: margaret.eldridge@pragprog.com. Both are modest sellers, but I think the readers who bought those books really enjoyed them.

jordan0day

jordan0day

This looks really great, nice work!

BigTom

BigTom

This looks like exactly what I will be needing in Q2! I have signed up.

(BTW, any chance you could fedibridge (https://fed.brid.gy/) your bsky account?

Where Next?

Popular in Discussions Top

vans163
So useless benchmarks aside, Its possible to write a webserver that can serve 300k requests per second (perhaps more with optimizations)....
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
WolfDan
After doing a port from a c++ library to my project in phoenix I’ve seen that I need a faster way to run this algorithm and I found this ...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
sergio
There’s a new TIOBE index report that came out that shows Elixir is still not in the top 50 used languages. It also goes on to call Elix...
New
acrolink
How does the two languages compare when it comes to server side application development? Any experiences or ideas? Thank you.
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Qqwy
Looking at the stacks that existing large companies have used, WhatsApp internally uses Mnesia to store the messages, while Discord uses ...
New
kostonstyle
Hi all How can I compare haskell with elixir, included tools, webservices, ect. Thanks
New

Other popular topics Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48342 226
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement