Hi guys!
I’m new to the Electric Imp and I tried to use the Sampler class to get analog data from a sensor with my april devboard. But I think I got stuck with Squirrel now.
In my callback I tried to do this:
function samplesReady(buffer, length)
{
if(length > 0)
{
server.log(buffer);
}
}
This obviously doesn’t work, because I’m just printing the reference to the blob, not the content. Then I found the method readn(string) and tried this:
function samplesReady(buffer, length)
{
if(length > 0)
{
local signal = buffer.readn('i');
server.log(signal);
}
}
This gives me values, I think in the range from 0-65535 from the ADC on my pin.
Am I doing this right? And what other formats can I use with readn(string)?