ChipChop Support Forum
Log in
Log out
Join the forum
My Details
REPLIES: 1
VIEWS: 289
BACK
REPLY TO THIS POST
Gizmo
16 Jan 2024
Small Log
This is a new feature that will enable you to log a small amount of data for your device is now available.

I have to put some restrictions in terms of the amount of data that you can store on your account as storage costs and this is after all free! If you want to store more data or have the logging run more frequently, let me know and we can figure out some storage cost contribution.

Here's the overview of functionality:

- You can have up to 100kb of logs per device
- You can specify up to 3 components per device to have their statuses automatically logged
- The minimum time between logs is 10 minutes so that's 144 entries a day per component or approx 432 entries per device. The exact number will depend on physical log size
- There is no time limit like 1 day etc. it's how much fits
- The log entries are automatically stamped with a UNIX timestamp in milliseconds in GMT 0

- The log is automatically rotated like this:

        1. The log is split in two data containers of equal size
        2. When both containers get filled the second one with older data get's erased, the first one becomes second and a new empty primary container gets created
        3. The process repeats indefinitely

So, if you had data let's say spanning across two weeks and the log gets filled, roughly the second week will get binned and you will start from today with saved data from the week before.

- You can view and download the logs in .csv format through the WebApp, if a device has logging enabled it will show as the last button in the device detailed panel (not in the widget view)
- note - The log doesn't refresh automatically in the WebApp, you have to press the "View Log" button that requests it from you API server and to reload it (refresh it) simply close the log page and click the View Log button again
- You don't need to do anything special in your device code, it's all done through the Dev Console, just tick the box "Enable logging" for the components you want to track and chose the logging interval 10min, 30min & 1 hour (will add 1 day at some point)...that's it


Hack advice

1. If you want to log something that is not a physical device component, for example if you have multiple sensors measuring something and you want to log an average or total between them

- create a component called Average or Total or something like that in the Dev Console
- do whatever calculations you want in your device code
- send the values as any normal heartbeat for that component "ChipChop.updateStatus("average_component_name",some_value);"

2. You can log whatever values you want, strings and numbers so you can sort of cheat and send things as strings containing combined values at once.


Example:

- You have created only one log component called "totals"
- You send a total for multiple sensors as a string combining multiple values, something like this:



        int temp_total = t_sensor_1 + t_sensor_2 + t_sensor_3;
        int humidity_total = h_sensor_1 + h_sensor_2 + h_sensor_3;

        String total = "temperature: " + String(temp_total) + " - humidity: " + String(humidity_total);

        ChipChop.updateStatus("totals", total);

        //when viewed through the web app the log will contain entries like this:
        // temperature: 24.6 - humidity: 48



ChipChop doesn't care what you are sending an doesn't do any calculations on it so you are free to log whatever you want as long as the logging is assigned to at least one component.

Just note that the entries may not look nice on the screen if the string is too long so for the example above it may be better to use shorter words like "T" & "H"




Gizmo
16 Jan 2024

One more thing, I will be including the log view in the Dev Console soon.

I wanted to include a Graph/Chart view but it didn't work well on a phone screen as there is plenty of space in the Dev Console it should work ok.

I didn't want to double up on the work so bear with me whilst I implement the Graph and then I will add the whole lot in the Dev Console.

p.s. and I will update the Docs, the quick help is already updated in the Dev Console