If you have been following the previous tutorials, you should now be able to collect sensor data, monitor the battery’s state of charge, and send this information to The Things Network (TTN).
Visualising this information on Datacake will allow us to check sensor data (in this case temperature) at a glance, and also tell us when to recharge the battery.
The sketch we uploaded in the previous tutorial Battery power - connecting and charging the Li Po battery, uploaded two pieces of information to TTN.
payload[0] = tempVariable; // Send temperature by LoRa.
payload[1] = cellPercent; // Send state of charge by LoRa.
Now login to your Datacake account, choose your board and click on the ‘Debug’ tab. You should see this.
At the moment, we can only see temperature data. This is because we only set up the Payload Decoder to extract temperature information. We now need to add the battery’s state of charge.
Still in your Datacake account, click on the ‘Configuration’ tab. Newer versions of the Datacake app will also require you to click on the ‘Product and Hardware’ link in the left-hand navigation. Now scroll down to the ‘Payload Decoder’ section.
In the box labelled ‘Payload’, type in some dummy values that you might expect from your sensor.
You could try ’10 11’. These are the hexadecimal values for temperature and state of charge, as received from your sensor. Click the blue ‘Try Decoder’ button. You should see this if all is working.
So, the temperature is reported as being 16 degrees and the start of charge is at 17 percent.
We now need to configure Datacake to show our state of charge value in the visualisation. Click on the ‘Configuration’ tab and this time select ‘Fields’ in the left-hand menu.
If you see a ‘Suggested Fields’ section. Then click the blue ‘Create Field’ button. Otherwise, click the blue ‘Add Field’ button.
You will see a form like this.
Here are the instructions for setting up a state of charge visualisation in your Datacake dashboard (some of the following images are for Board 4 as I already had the screenshots).
Click on the dashboard tab in your Datacake account, then toggle on the edit button on the extreme right of the top navigation bar.
In the ‘Field’ box, select the ‘SOC’ field (or whatever you have called your state of charge field when you originally created it).
The current state of charge should appear in the window at the top of the pop-up box.
The state of charge of the battery is being reported as 4%. Time to charge the battery perhaps.
The colours are in hexadecimal. The colour code starts with a #. Colours are represented on screen as varying proportions of red, green and blue. The first two digits represent the amount of red colour, the next two the green colour, and the last two digits represent the colour blue. For each colour, it’s absence is represented by 00, and the maximum possible value is ff. So, my blue colour is #0000ff.
Click the ‘Add’ button again to specify the colour of the maximum percentage of 100. I have coloured this red, so the colour is #ff0000.
Now click ‘Save’ and close the pop-up window. This will return you to the dashboard.
Here you can see that we have added a graphical field, which tells you when the battery was recharged. The graph was added by clicking the blue ‘Add Widget’ button again and selecting the ‘Chart’ widget. In the ‘Data’ tab of the pop-up window, I then selected ‘SOC’ again.
In the next image you will see that the temperature Value and Chart widgets have also been added.
For each widget added, you will see three icons in the top right-hand corner. These allow you to edit the widget, clone it or delete it. You can also click within the widget and drag it to a new location if you wish to reorder your widgets.
Near the top of the page, you will see two buttons, Desktop and Mobile. Up until now, you have been editing the desktop version of your Dashboard. Click on ‘Mobile’ and then select ‘Create from desktop’ after clicking the ‘More’ tab. You can then rearrange your widgets for mobile visitors. Your mobile layout will not affect your desktop layout.
When you are done, toggle off the edit version of your dashboard to save your work. Now check the layouts on your mobile and desktop devices.
Next, we will see how long the battery will last. Click here for the next steps.