Exosite JSON to Lua


Hi @Martin and @joeylink,

I am starting a new thread because my first one is becoming a little too long and doesn’t really apply anymore to nodejs.

Currently I am sending information as 1 second timestamp resolution to multiple data sources.

My main goal is to send the JSON data to data alias ‘SGD1’ (more like a “dummy” alias; it doesn’t really contain number values) and then separate the data and send each part to different aliases (‘ADC1’ and ‘ADC2’).

My JSON data looks like this:

Note that ADC1 and the ADC2 are my data source aliases that I am sending to.

My Lua Script looks like this (with an error):

I am not getting any values right now in ADC1 or ADC2, but I am still getting a value of “1” in data alias SGD1:

Could you please help?



One last note - This is my code to get to the JSON-formatted string (which works fine):


Hi Thomas,

The first problem I noticed is that some of your alias names still don’t match up within your lua script. You have to make sure that the alias name you are referencing in your code is the same one described in the available aliases tab (on the top left corner of the script information page). For example, Line 2 should instead read as follows:

local ADC1 = alias ['ADCPin1']

Another thing I noticed is that you aren’t referencing your keys correctly from your decoded JSON table. For example, lines 12 and 13 should instead read:

if data.ADC1 then

It might be helpful to take a look at some example scripts so you can get the hang of how these concepts work. Here’s a link to some example lua scripts that run on the Exosite One platform:



Oops. The first picture was actually an older picture; I had renamed the data alias since then (see the second picture from the first post):

I still am getting an error though even after referencing the keys correctly.



Here is a list of my attempts:




Thomas, try adding a debug statement to printout the contents of your variable ‘data’. My guess is that the value is 1.

Additionally what type of dataport is Smart Grind Database? E.G. Integer, float, or string.


The Smart Grid Database is a float dataport, while ADC1 and ADC2 are integer dataports


You can’t use a floating point dataport to store string data! The platform will treat any characters as if their value was 1.

Try using a dataport whose format is a string. If your write call is sending a stringified valid JSON blob, I think you will get the results you are looking for.


Ok. I changed SGD1 into a string dataport…

…but I am not getting any data for ADC1 or ADC2.

Edit 1: Here is my JSON blob:

Edit 2: Rounding the JSON blob:

Edit 3: And still nothing:


@joeylink and @Martin,

I tried this too:

So the quotes didn’t work either.


Right after I took back the quotes, the JSON blob worked! It probably worked because of the rounding issue from the floating dataports, and I probably didn’t give enough time for Exosite platform to respond…

Thank you so much @Martin and @joeylink; I don’t know what I could without your tremendous help and patience.