Tag Archive: loggers

Tasker is able to perform many different things, one of which is the ability to log information. Tasker contains a Logger tab that can create Logger profiles to record data. These Loggers tell what needs logged and which file it should be stored in when used in a task. This post will show how to record temperature values from an environmental sensor using Tasker.

In order to setup Tasker to record temperatures from a environmental sensor, there are a few step we need to take:

  1. First we need to create Signals in the Signal Tab. These will be used in the Logger tab to record their values.
  2. Next we create a Logger in the Logger tab. Here we use the Signals to document their values in log files.
  3. After creating the Logger, we now go to the Task tab and create a task that includes the Logger that was just created.
  4. Finally, once the task is created, in the Schedule tab we create a Schedule that runs the task for however often we wish to record the environmental sensor values.

NOTE: In step 4 you can also use a Trigger, but this example will focus on using a Schedule.

Creating Signals

Signals are Input/Output values from the JNIOR or from expansion modules compatible with the JNIOR. In this example we are using a environmental sensor expansion module to record these values. First we’ll create a new workspace using the File Drop-Down. Then in the Signals tab, After clicking the “Add Signal” button, we’ll create a new signal called Temp_1. After the Signal is created, it has three value fields to fill out. The first one is the Signal drop down value, where you will pick where we are getting the Input/Output values from. As stated previously, we are grabbing these values from a environmental sensor, so we’ll select it from the drop down options. Next is the channel for the environmental sensor. Each channel represents a different environmental sensor. Since we are only using one sensor, we’ll select channel 1. Lastly is the variable type, and while the values you can get are either Celsius, Fahrenheit, or humidity, we are going to be logging the info in Fahrenheit, so that’s what we’ll chose.

Signal tab in Tasker

Creating a Logger

Now that the Signal is created, we can create a Logger to record those values to a file. We’ll go to the Logger tab and select “Add Logger”. The first value is the File Name, which is where you define what the name of the log will be when its created, and the file path on the JNIOR where it will be saved. In our example, we used the file path /flash/tasker/logging/temps-{{date(YYMMDD)}}.log. If you run this logger and go to the directory on the JNIOR where you saved this log, you’ll see the date(YYMMDD) will be replaced with the date the log was created. After this is the Headers field which create headers in the log right above where values will be added. We define a header in the example that will add Temperature to the top of the log. The next field is the Timestamp Format, which defines how the time is recorded next to the value being logged, leaving this blank will used the grayed out default (MM/dd/yy HH:mm:ss zzz).  After that is the Schema field, which lets you define what values should be logged when the logger activates, here we simply log the temperature from a Temp sensor connected to the JNIOR by entering {{temp[1].f}}. Lastly, is the file retention count. All this does is decide how many files of information Logger will create before overwriting previous files, so if the number is set to 10, once Logger has created 10 files of information, next file it create will overwrite the previous 1st Logger file. This example uses 30.

Here is the resulting log on the JNIOR created from the Logger.

Creating a Task

With the Logger being created, we now need a task that uses our Logger so it will activate and record the data we want. In the Task tab, we’ll select the button “Add Task”. Once the Task is named, click on its name and select “Add Action”. The Action Dialog box will appear which has all the actions a task can perform. Here we’ll select the Log Profile action, which we can use to call the Logger we created in the Task. Once the action is added, the only value to enter is the name of the Logger we just created. This will now make the Task activate the Logger each time its run.

Task tab in Tasker

Creating a Schedule

Lastly, having a task activate a Logger is good, but it will only record when you activate it. Adding the task to a schedule will allow us to record these values on a time interval. Going to the Schedule tab, you’ll click on the “Add Schedule” button. After naming the Schedule, there will be two options to fill out. The first one appears by selecting the “Add Rule” button, which will bring up the Rule Dialog box where you can configure when the schedule is timed. For this example we will set the Schedule type to schedule so we have more options rules to pick from. The start on date is  the date for whenever you want the schedule to begin activating the task you set with it. Next is the Start Time, Repeat Every, and End Time options (End Time appears after you edit Repeat Every). We set both the Start and End Time to Midnight so that the interval is always running. Repeat Every is set to 2.5 minutes so that with the Start and End time set, the task will run every 2.5 minutes for an entire day. For the Date Selection type, we used daily in this example so we can set the Recur Every option to 1. This will make the task run every day. Lastly, after completing the Rules for the schedule, we add a task that we want the schedule to activate based off the rules we set for it, which will be the task we created in the Tasks tab.

Scheduling Tasks in Tasker

Once the Schedule is completed, the Logger will now record the Signal values of the environmental sensor as values in a .csv file from a task that is scheduled to run every 2.5 minutes, every day.

Sometimes you may want something to occur at a specific time of day or sometimes you may want something to occur with certain events during the day.  The “events” in this case are the Sunrise and Sunset events.  These events occur at different times during the day based on the time of year and your geographic location.  Tasker grabs the location from the JNIOR registry, and uses it to calculate the time of sunrise and sunset for that day.

We had written a custom application called the SunEquation Application to accomplish the following before implementing the logic in Tasker.  You may ask, “What is the SunEquation application and can Tasker handle the same logic?”  The SunEquation Application simply calculates the time of Sunrise and Sunset only, and yes Tasker can do what the SunEquation Application does. The difference between the two is that Tasker is a heavyweight application that uses more processing power than a simple custom application like SunEquation that was designed to do one thing.  The SunEquation application was written for someone that was already running two other applications and the addition of Tasker might slow those other applications down.  Specifically the DMX application is sensitive to performance and that application is one of the two applications that were in use.

Below is an example to activate Loggers in Tasker at sunrise or sunset that will record the time the Loggers activated. This requires having the support tool downloaded along with the Tasker Application  There are several steps that will need to be configured to get this to work.

  1. Create a Logger in Tasker that will record the time it activates
  2. Create a Task that will perform the action of activating the Logger.
  3. Create Schedules that will execute the Tasks based on Sunrise and Sunset.

Create the Logger

The first thing we’ll want to do is create a Logger that will record the time its executed at. We’ll open the Tasker Web Page and go to the Logger Tab. Here we will create a Logger called SunriseSunset. Then we will append to the File Name field of the Logger so it has /flash/tasker/logging/sunrisesunset.log. By default, the Timestamp Format field will have a format that will be used, so the Logger should be complete.

Create the Task

The next thing needed is a Task that will activate the Logger. Go to the Task Tab and create a Task called Call_Sunrise_Sunset. Here we’ll add the call Log Profile action and enter the Logger’ name SunriseSunset. Now when the task is called, the Logger will activate.

Create a Schedule

To trigger the logger to run at sunrise and sunset, you’ll now want to go to the schedule tab of the Tasker application. You’ll then add two schedules, and name one them “Sunrise” and the other “Sunset”. For the “Sunrise” Schedule, you’ll want to enter the Task we created for it in the Task Name field, which is “Call_Sunrise”. You’ll do the same for the “Sunset” Schedule. Then you’ll add the rules to the Schedules.

Once you’ve clicked “Add Rule”, the Rule Dialog box will open. Here we’ll want to select the Schedule Type option, which will present 4 options. Two of those options will be Sunrise and Sunset.

Clicking the blue text in the dialog links to https://www.latlong.net. Here you can enter your address to get your current Latitude and Longitude.

After selecting the sunrise option for the sunrise task, and the sunset option for the sunset task, make sure that you enter the Latitude and Longitude of your current location for each, as this is how the JNIOR calculates the time of sunrise and sunset. Once entered, those tasks will now run at those times.

Sunrise and Sunset Scheduled tasks

Once this is all done, whenever it is sunrise/sunset for the day, Tasker will log each day when sunrise and sunset occur!

To monitor the environment with the JNIOR you will need 3 things. First, either the Environmental Sensor or the Rugged External Temperature Sensor. Second, the Tasker application that will read that sensor and log the values. Third, the Grapher application to graph the data logged from Tasker.

INTEG resells an environmental sensor from Embedded Data Systems. The sensor itself wont work directly with the JNIOR until it is wired. They have several different models that provide different environmental metrics. Temperature and humidity have been the consistent requests. INTEG also sells a rugged external sensor that tracks just temperature.

NOTE: Only the Environmental Sensor records humidity.

Set Up

The first thing to check when setting up is the sensor module you connect to the JNIOR. In the Console Tab of the JNIOR Web Tool, commands you can use to see what sensor is connected are the extern command to tell you what modules you have connected, and the extern -r command to remove a module on your device that is no longer connected. To tell which sensor module you have connected, look at the ID of the device from the extern command. If it ends with 7E its the Humidity Sensor, if its 28 its the Rugged External Temperature sensor.

extern command for JNIOR command line

After that, you’ll want to make sure that you have the applications to graph the data logged.

Name Version Release Date Size MD5
Tasker v12.0 Jun 20 2023 2.9 MB edfd2578eccdf8595b4f3d35f1ca4bf8
Grapher v4.1 Jun 18 2020 788.5 KB 75e992513636e0c45c7aa7f71d8c1303

You’ll want to do an update project one at a time, publishing these to the JNIOR you have the sensor connected to. After that, to get to the Grapher application, you can either type (JNIOR’s IP)/Grapher into the URL of a web browser or you can select it under the tools tab of Tasker to take you to the application. There you can create the graph to monitor your Temperature. 

Once on the Grapher application page, you’ll want to go to the Grapher Configuration page to enter settings for creating a graph. You can access this by going to the top of the Grapher application page and at the top click Tools/Grapher Configuration. To start, you can go down to the files section and add the files that give the values to be put on a graph.

At the top, you can define the directory path of the file you want monitored, but keep in mind whatever path and file name is set here should match what you set in the Tasker application. The column value field is where you enter what you want the names of the values from the log file in Tasker to be called. One of the column values needs to be Timestamp since the graph needs that information to know where to plot it the value being pulled. The Date format can be set to MM-DD-YY HH:mm:ss.SSS. The file count is specified to how many files you want added. After setting this, you can configure the Graph section described below that will be monitored for the graph.

Here you can create the graph name, and then set the range of the graph and also the time range being charted. Below that you can create the lines that go into the graph that are tracked. You can add their names, what the units they are measured in are called, and the color of the line. Once this is all set you’ll now want to open the Tasker application by typing in the URL (JNIOR’s IP)/tasker, or by clicking the link for it from the JNIOR Web Page in the applications section of the Configuration tab.

In the Tasker application, the first thing we’ll want to do is create a workspace. After that we’ll create a Logger using the Logger Tab. Once on the Logger Tab of Tasker, clicking the “add Logger” button will create an empty Logger in the Logger Tab, which you can name Log_Temp for this example. This is where the file will be created that Grapher pulls the data from to graph.

Like in the picture above, you’ll want to set the log file path. The one in the example is called temps-{{date(YYMMDD)}}.csv just like the one named in the file section in Grapher of this example, the only difference being that the YYMMDD has “” around it while the file section in Grapher should not. (The date.format part of the file name auto inputs the date when creating the file). The Timestamp Format specifies the Timestamp of when the value are logged. This is needed to know where the files need to be plotted in Grapher, which is also why we included the Timestamp value in Grapher eariler. Entering nothing in the Timestamp Format field will default it to MM/dd/yy HH:mm:ss zzz, so you don’t need to enter anything in this field unless you want to change formatting of the default timestamp. The Schema field will contain separate values that act as the referenced schema values we defined in the graph section of Grapher.

For how the schema values work, they simply refer to values on the JNIOR such as the I/O or analog values. The double squiggly brackets and comma between each value are needed to separate each value. The picture above uses Signals from the signal tab, so you’ll need to go to the Signal tab after this and create two signals for Celsius and Fahrenheit for the humidity temperature sensor. Make sure the names in brackets in the schema under logger and the signal names in the signal tab match each other. More information on how to reference values on the JNIOR in a Logger, go to the help drop down at the top of the Tasker page and select the help link.

After defining the values for the Logger in Tasker, we’ll now want to create a Task in the Task Tab of Tasker. Once in the Task Tab, we’ll select the “add Task” button. This will add an empty Task to Tasker that you can name. Once we do that, we’ll want to select the “add Action” button to add an action to the Task to run the Logger we just created. In the action submenu we’ll want to select the Force Log Profile action. Once its added, we’ll enter the Logger name we created earlier to the action so it’ll run that Logger every time the Task runs.

Once that is done, we’ll now add a schedule that runs every two minutes so the graph is constantly getting more data every two minutes.

Going to the schedule Tab, we’ll click the “add Schedule” button to add an empty schedule to Tasker. We’ll then select the “add Rule” button to open the rule submenu. Here we’ll set the Schedule to run every two minutes, every day, from Midnight to Midnight like shown in the picture below. We’ll also set the schedule to run the Task that activates Logger to every two minutes.

Once this is all set up, going back to the Grapher application should now give you a graph of the logged temperatures!

Grapher Main Page