guild icon
Toit
#Running multiple toit containers with a Global clock that can put ESP32 in deep sleep mode
Thread channel in help
Shadi
Shadi 06/06/2023 08:36 PM
Hi,
I would like to ask you how can I run multiple different Toit containers and also have this possibility to put my ESP in deep sleep mode. I want the device wakes up every 20 mins (e.g.) and process different containers and then go to deep sleep mode again. But now i can just have one container with different functions which also has the deep sleep. thanks in advance for your support
floitsch
floitsch 06/07/2023 08:23 AM
The easiest would be to use Artemis (https://docs.toit.io/getstarted/fleet). It does this for you.
Otherwise there are a few options:
- Modify Jaguar so it goes to deep sleep when all containers are done. Jaguar is surprisingly small so that isn't as hard as it sounds. https://github.com/toitlang/jaguar/blob/main/src/jaguar.toit
I feel like the biggest challenge would be to install the modified Jaguar. If you have some idea of how to do it it's not hard, but otherwise could be challenging. If you go this route let us know so we can direct you a bit.
- Use services to communicate between the individual applications. When an app is done it simply sends a message to the shutdown service. That one then goes to deep sleep when everything is done. Still requires the individual applications to be shutdown aware, though.
- Probably others.

Unless you need to use open-source, I would try Artemis first, though.
If you like tinkering with other programs, then modifying Jaguar could also be fun.
Use live reloading over WiFI to turbo-charge developing for your ESP32. - jaguar/jaguar.toit at main · toitlang/jaguar
Shadi
Shadi 06/07/2023 08:42 AM
Thanks a lot Florian, one question, in Artemis, I also can have multiple containers?(edited)
floitsch
floitsch 06/07/2023 08:42 AM
yes.
floitsch
floitsch 06/07/2023 08:43 AM
You create a pod-specification that contains all the containers you want.
You then say at which interval they should run.
Whenever no program needs to run Artemis goes to deep sleep until the next program should run.
floitsch
floitsch 06/07/2023 08:44 AM
Releases of the Artemis fleet management tool. Contribute to toitware/artemis-releases development by creating an account on GitHub.
floitsch
floitsch 06/07/2023 08:44 AM
This example has two containers in it.
The "hello" and "solar" one.
floitsch
floitsch 06/07/2023 08:45 AM
If you need your device to go to deep-sleep you also need to change the "max-offline".
If it is 0s, the device will stay awake and continiously request updates from the server.
Shadi
Shadi 06/07/2023 08:45 AM
this seems the Artemis is like as docker-compose?
floitsch
floitsch 06/07/2023 08:45 AM
there are some ideas from docker :🙂:
floitsch
floitsch 06/07/2023 08:45 AM
It's more descriptive.
floitsch
floitsch 06/07/2023 08:46 AM
Docker compose is a bit more imperative. You can write commands one after the other.
The pod specification is a description of what should be installed. Things aren't executed in any order.
floitsch
floitsch 06/07/2023 08:46 AM
I think you had a look at Toit v1 at some time. Artemis is the successor to it.
Shadi
Shadi 06/07/2023 08:49 AM
perfect, Now I completely understand what is going on, Thanks a lot
👍1
Shadi
Shadi 06/07/2023 08:57 AM
I am trying to install Artemis on mac, but I get error: % /Volumes/artemis/artemis ; exit;
Error: Missing subcommand.
floitsch
floitsch 06/07/2023 08:57 AM
That's a good start.
floitsch
floitsch 06/07/2023 08:57 AM
artemis is a command line application.
floitsch
floitsch 06/07/2023 08:59 AM
You can follow the "getting started" at https://docs.toit.io/getstarted/fleet

But fundamentally you now need to:
- signup
- create an organization
- initialize a fleet directory
- modify the pod specification
- create a pod and install it
floitschfloitsch
You can follow the "getting started" at https://docs.toit.io/getstarted/fleet But fundamentally you now need to: - signup - create an organization - initialize a fleet directory -...
Shadi
Shadi 06/07/2023 09:07 AM
Actually I followed these steps to sign up and I get the error: zsh: command not found: artemis
Shadi
Shadi 06/07/2023 09:07 AM
I believed I did not install artemis in mac correctly
floitsch
floitsch 06/07/2023 09:37 AM
You can always use a relative or absolute path to it.
floitsch
floitsch 06/07/2023 09:38 AM
If you downloaded it you can add it to your path by writing export PATH=$PATH:$PWD (assuming you are in the folder that contains artemis).
floitsch
floitsch 06/07/2023 09:38 AM
After that you can just write artemis and it will find it. At least in the terminal where you wrote export ....
Shadi
Shadi 06/07/2023 09:40 AM
thanks I will try this
Shadi
Shadi 06/07/2023 09:49 AM
One more question, I would kindly ask if you update the Jaguar? because two weeks ago when I try to measure energy consumption of my setup while using toit/jaguar was less than today.
floitsch
floitsch 06/07/2023 09:49 AM
So Jaguar was using less energy two weeks ago than it is today?
floitsch
floitsch 06/07/2023 09:50 AM
We do update Jaguar regularly, but we don't do anything behind your back.
floitschfloitsch
So Jaguar was using less energy two weeks ago than it is today?
Shadi
Shadi 06/07/2023 09:52 AM
yes,
floitschfloitsch
We do update Jaguar regularly, but we don't do anything behind your back.
Shadi
Shadi 06/07/2023 09:52 AM
ok, thanks a lot
floitsch
floitsch 06/07/2023 09:55 AM
Usually the biggest energy consumption comes from connecting to WiFi. So maybe it has a harder time connecting to it.
floitsch
floitsch 06/07/2023 09:57 AM
Artemis is generally better for battery operated devices, so I would redo your measurements with it.
floitschfloitsch
If you downloaded it you can add it to your path by writing export PATH=$PATH:$PWD (assuming you are in the folder that contains artemis).
Shadi
Shadi 06/07/2023 10:02 AM
Excuse me for this basic question, should I export the path of artemis.exe ?
floitsch
floitsch 06/07/2023 10:02 AM
After adding the directory of the artemis executable to your PATH you should be able to just write artemis and the shell will find it.
floitsch
floitsch 06/07/2023 10:03 AM
If you export it then sub programs can also see it.
floitsch
floitsch 06/07/2023 10:03 AM
Typically you export it to make things easier.
floitsch
floitsch 06/07/2023 10:03 AM
In both cases it's just a temporary thing, as a new shell would not have the artemis-folder in the PATH.
floitsch
floitsch 06/07/2023 10:03 AM
You can make it more permanent by changing your .zshrc
floitsch
floitsch 06/07/2023 10:04 AM
(I'm assuming you are running zsh since you mentioned macOS, and that's the default there)
Shadi
Shadi 06/07/2023 10:07 AM
,I export the path of my executable artemis but still i get the error : he error: zsh: command not found: Artemis. , I click on artemis.dmg I get the warning: “artemis” is a Unix app downloaded from the internet. Are you sure you want to open it?
floitsch
floitsch 06/07/2023 10:09 AM
The 'dmg' is just a disk image that contains the artemis executable.
floitsch
floitsch 06/07/2023 10:09 AM
You should be able to drag&drop the artemis file out of the dmg and store it somewhere easier to find.
floitsch
floitsch 06/07/2023 10:09 AM
For example, you could create a local/bin directory in your home and copy it there.
floitsch
floitsch 06/07/2023 10:10 AM
then you would have export PATH=$PATH:$HOME/local/bin
floitsch
floitsch 06/07/2023 10:11 AM
Apparently you should just drap the dmg into your "applications" folder.
floitsch
floitsch 06/07/2023 10:11 AM
(just learned that).
floitsch
floitsch 06/07/2023 10:14 AM
(but we are still investigating. We are just very used to modifying the PATH so we aren't too familiar with the typical macos flow).
floitsch
floitsch 06/07/2023 10:17 AM
After looking more, it seems like applications isn't actually a good place for it. So putting it into local/bin in your home is probably the best.
floitsch
floitsch 06/07/2023 10:18 AM
We will see if we can get a brew setup working. That would make things easier to install.
Shadi
Shadi 06/07/2023 11:06 AM
ok thanks a lot I will try thi sapproach
Shadi
Shadi 06/07/2023 11:56 AM
I would like to ask you a question as I could not install artemis on mac. I tried to install on linux and I add the path to Artemis to my path. but after running this command "artemis auth login" I get thi serror: GLBC_2.29 not found (required by artemis)it(edited)
floitsch
floitsch 06/07/2023 11:58 AM
usually that means that your Linux is not up to date.
floitsch
floitsch 06/07/2023 11:59 AM
It could be that we are compiling on a Linux that is too recent.
floitsch
floitsch 06/07/2023 11:59 AM
Let me check what version we require.
floitsch
floitsch 06/07/2023 11:59 AM
We are using the latest Ubuntu.
floitsch
floitsch 06/07/2023 11:59 AM
I will change it to something older.
floitsch
floitsch 06/07/2023 12:00 PM
Give me a few minutes and I will upload you an Artemis version that hopefully works with your system.
floitsch
floitsch 06/07/2023 12:06 PM
After a second look, it looks like we are already using Ubuntu 20.04 to build.
Is your system older than that?
floitsch
floitsch 06/07/2023 12:10 PM
If you want to try again on macos, here are the commands I would use:
cd /tmp curl -L -O https://github.com/toitware/artemis-releases/releases/download/v0.6.2/artemis-macos.zip unzip artemis-macos.zip chmod +x artemis mkdir -p $HOME/local/bin mv artemis $HOME/local/bin export PATH=$PATH:$HOME/local/bin cd $HOME artemis --version
floitsch
floitsch 06/07/2023 12:11 PM
If you are running the zsh. (You can check by running ps -p $$) you can change the PATH for future sessions by running the following command:
echo "PATH=$PATH:$HOME/local/bin" >> $HOME/.zshrc
floitsch
floitsch 06/07/2023 12:14 PM
You can use chat.openai.com to get a pretty decent description of what each of these commands is doing.
floitsch
floitsch 06/07/2023 12:15 PM
I asked chat.openai.com of whether these commands should work on macos, and it claims that unzip might not be available directly or not have all the necessary features.
If you have difficulties with unzip you can either try to install a better version with brew install unzip (assuming you have brew installed), or simply unzip the archive by hand.
(edited)
floitschfloitsch
If you want to try again on macos, here are the commands I would use: ``` cd /tmp curl -L -O https://github.com/toitware/artemis-releases/releases/download/v0.6.2/artemis-macos.zip...
Shadi
Shadi 06/07/2023 01:05 PM
It works, thanks a lot,
👍1
floitschfloitsch
I asked chat.openai.com of whether these commands should work on macos, and it claims that unzip might not be available directly or not have all the necessary features. If you ha...(edited)
Shadi
Shadi 06/07/2023 01:06 PM
Thanks for the hint, further I will first ask chat.openai.com.
floitsch
floitsch 06/07/2023 01:07 PM
It's not perfect (and often hallucinates/lies), but for these kind of things it's a good help.
👍1
bmentink
bmentink 06/09/2023 02:18 AM
The method that works for me, is to open the. dmg file, then in a terminal, type: cp /Volumes/artemis/artemis /Applications(edited)
👍2
65 messages in total