Im still new to Thunkable and Im having a hard time with using the local data base…
So in my app, I got a sensor working, and I wanted for a couple of seconds, to store the sensor data in a local datebase so later on I would be able to read the smaller/bigger value retrived by the sensor…
Is it possible? Can anyone help me out?
You can use blocks like this to save your value to a DB:
Then use blocks like this to get the highest value:
The ‘max of list’ block can be found in the Lists drawer of blocks:
As you can see form all of the options, you can do some great analysis on your data with this one block!
Thank you so much for the help!
But is there a way to actually take a look at the data that got saved in the data base? I thought it would be posible to check it out on the table created once you creat the local DB…
You could use a label or the listviewer to display the contents of, for example, the
@geralhivl, can you share you project link to me via private message? Have checked the code above but can’t find any strange. I think I need to check deeper on your component and other blocks.
Light green blocks, like yAcceleration in your example, are local variables that are visible only inside the block in which they are defined. Therefore, your blocks does not work.
Sorry you got me a bit confused there…
How can I fix it?
Use variable block.
myVar < yAccseleration
then use to save to the myVar to store it value
If you don’t know what local and global variables are, here’s some information about it.
A global variable is a variable that can be accessed in multiple scopes. This means that wherever you are in the program you can use that variable; get its current value or set its value to something else. Global variables are created using the initialize global name to block found in the Variables drawer.
A local variable is a variable that is declared within a function or it is an argument passed into a function. This means that you can only access these variables in that specific function where they are declared or passed in as an argument.
@actech so… I should initialize a new variable? then I need to get myVar = YAcceleration, and then change to myVar every field that is now set as Yacceleration?
Im sorry really trying to understand this
Yes, you need to create a new variable if you want to use the received data outside the scope of the local variable.