# Save data from a sensor using a button

**URL:** <https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269>\
**Category:** General\
**Created:** [3 July 2018 11:18 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269 "2018-07-03T11:18:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrieldicieri](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gabrieldicieri](https://discourse.nodered.org/u/gabrieldicieri)\
**Post date:** [3 July 2018 11:18 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/1 "2018-07-03T11:18:32Z")

</div>

I am currently using a GrovePi distance sensor, I would like some ideas as I am new to this area. Would it be possible for me to save in a file to download, the data obtained by the sensor at a certain time? If so, could you tell me where to start?

thanks Gabriel

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [3 July 2018 11:28 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/2 "2018-07-03T11:28:40Z")

</div>

yes

I’d start by looking at [flows.nodered.org](http://flows.nodered.org) and finding a node that can handle data from the sensor. wire that up to a debug to see what you get and then look at the file out to save all the data to a file.

When you have that working I’d move onto how to save it when you push a button, which could be an inject node or on a dashboard

---

<div class="post-metadata">

**Author:** ![gabrieldicieri](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gabrieldicieri](https://discourse.nodered.org/u/gabrieldicieri)\
**Post date:** [3 July 2018 11:33 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/3 "2018-07-03T11:33:49Z")

</div>

this I already did, my sensor is already working, throwing information to a graph, there is a start and pause button, and a reset button. Now I would like to make the button to save data.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [3 July 2018 11:39 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/4 "2018-07-03T11:39:28Z")

</div>

well it might have been worth mentioning that!

There are many ways to do it, for example…  
You can add a change node into your flow to save the last value to a global variable.  
Then in another flow have a button press pick up the global variable and save it to a file.

---

<div class="post-metadata">

**Author:** ![gabrieldicieri](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gabrieldicieri](https://discourse.nodered.org/u/gabrieldicieri)\
**Post date:** [3 July 2018 11:41 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/5 "2018-07-03T11:41:56Z")

</div>

Sorry, I forgot to mention it. Do you have some example of this application? I’m really new in the IOT area

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [3 July 2018 12:00 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/6 "2018-07-03T12:00:52Z")

</div>

Sorry I don’t but you can read about Global Variables in the docs on the website, and theres lots of examples of dashboard buttons on [flows.nodered.org](http://flows.nodered.org)

But the best way to learn, is by having a try yourself

---

<div class="post-metadata">

**Author:** ![gabrieldicieri](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gabrieldicieri](https://discourse.nodered.org/u/gabrieldicieri)\
**Post date:** [3 July 2018 12:03 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/7 "2018-07-03T12:03:18Z")

</div>

i will have a try, thanks

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [3 July 2018 12:13 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/8 "2018-07-03T12:13:11Z")

</div>

Are the buttons physical buttons or buttons in the ui-dashboard?

---

<div class="post-metadata">

**Author:** ![gabrieldicieri](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gabrieldicieri](https://discourse.nodered.org/u/gabrieldicieri)\
**Post date:** [3 July 2018 12:18 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/9 "2018-07-03T12:18:50Z")

</div>

button in the ui-dashboard

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [3 July 2018 13:52 UTC](https://discourse.nodered.org/t/save-data-from-a-sensor-using-a-button/1269/10 "2018-07-03T13:52:06Z")

</div>

Ok, then follow the suggestions from @ukmoose - I just wanted to make sure it wasn’t a physical button.
