Today I wrote my first little program in smart BASIC. I had already a VBA version and translated this into smart BASIC. It was very easy due to the simplicity of smart BASIC. It does nothing else than reading the Spark Core server to which the Spark Core is connected. Each Core has a core ID and each Core has an Access Token. These are personal and you must keep them secret. The data transmission is secure at https level and you need to register your device first.
The Spark Core
Code: Select all
COREID$ = "********************"
ACCTKN$ = "*******************************"
temp_no$ = "temp1"
URL$ = "https://api.******/devices/"&COREID$&"/"&temp_no$&"?access_token="&ACCTKN$
HTTP URL$ GET t$
PRINT t$
{"cmd":"VarReturn","name":"temp2","result":32.19065934065935,"coreInfo":{"last_app":"","last_heard":"2017-06-10T17:35:34.992Z","connected":true,"last_handshake_at":"2017-06-10T17:00:20.923Z","deviceID":"****************","product_id":0}}
Spark Core Program
The Spark Core has a program that reads the temperatuire sensors. The 2 temperature sensors are LM335Z types. The datasheet is here. The output of the sensor is fed to an analog input, which just reads the voltage of the output.
I have a VBA macro program running in Excel and it collects this JSON string and extracts the temperature. It puts the temperature value with the date in a table and the data is shown in a graph.
So you can ask for the temperature where ever you've put such a device at home. This device can also recieve information from the Spark Server. If you create an App with smart BASIC and you want to switch someting on like a LED light you can do that. This wil be my next goal.
I think smart BASIC will become a powerful App to produce home appliance applications for domotics on iPads and iPhones. Now with smart BASIC it is very simple to write your own Apps.
Namaste.