voodootikigod/voodoospark

Possible to connect two analog sensors?

ericterpstra opened this issue · 9 comments

I'm trying to hook up the TMP36 and the force sensitive resistor from the Spark Core maker's kit. I can only get one reading at a time using the voodoospark firmware. Which ever five.Sensor is declared first is able to get proper readings from a 'data' event. The other just outputs null. Individually, they seem to be working fine.

See the diagram and code below.

spark core fsr and tmp36

Code: https://gist.github.com/ericterpstra/0c4127e1c9c6efc23e03

In this case, I get fairly accurate tmp readings every .5 seconds, and null every 2 secs. If I move the fsr = new five.Sensor above the tmp, then I get fsr readings, but null temperatures. Is this a limitation of Voodoospark, or am I doing something wrong?

Thanks

Try this:
bool which_sensor = 0; // say temp sensor is '0' sensor and force sensor
is '1'
which_sensor ^= 1; // put this wherever you want to toggle, this will
switch '0' to '1' and 1' to '0'

So you can try taking readings from one sensor, then the other, and so
on....

Will this work?

On Sun, Jul 27, 2014 at 3:40 PM, Eric Terpstra notifications@github.com
wrote:

I'm trying to hook up the TMP36 and the force sensitive resistor from the
Spark Core maker's kit. I can only get one reading at a time using the
voodoospark firmware. Which ever five.Sensor is declared first is able to
get proper readings from a 'data' event. The other just outputs null.
Individually, they seem to be working fine.

See the diagram and code below.

[image: spark core fsr and tmp36]
https://camo.githubusercontent.com/2e4340514c80ad2b4639e95c3dc1b2306dce22ca/687474703a2f2f6572696374657270737472612e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031342f30372f737061726b5f746d705f6673725f62622e6a7067

Code: https://gist.github.com/ericterpstra/0c4127e1c9c6efc23e03

In this case, I get fairly accurate tmp readings every .5 seconds, and
null every 2 secs. If I move the fsr = new five.Sensor above the tmp,
then I get fsr readings, but null temperatures.


Reply to this email directly or view it on GitHub
#27.

@Stabitha Unfortunately this does not work. Simply having more than one Five.Sensor defined (whether readings are being taken or not) is enough to cause null values to appear.

Is this intentional?

Looks like there's nothing between the Analog signal and the Analog pin here: https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor

This is a detailed pin diagram for the Spark Core, maybe it will be
informative:
https://docs.google.com/drawings/d/12OdPwacGCoI-6NfFAYS2rjWgYxKWuHG0zupCH1tGLEQ/edit?hl=en&forcehl=1
It might just be an issue with porting Arduino code. Have you tried using
A1 or A6 on the Spark to duplicate the issue?

On Mon, Jul 28, 2014 at 8:51 AM, Rick Waldron notifications@github.com
wrote:

Looks like there's nothing between the Analog signal and the Analog pin
here:
https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor


Reply to this email directly or view it on GitHub
#27 (comment)
.

@rwaldron The capacitor on the GND pin is recommended by the Spark Core community (see this thread) and the official Spark Core documentation.

Also, I followed along with these threads to hook up the FSR:

http://community.spark.io/t/coffee-break-anybody-with-maker-kit-publish/4091
http://community.spark.io/t/force-sensor-using-with-3-3-v/5201

@Stabitha I've tried other pins. For the FSR, it made no difference. For the TMP36, the readings were actually worse, because the capacitor was further away from GND.

Also, FWIW, using the Tinker firmware seems to work OK. I was able to use the Tinker iOS app, or a simple Cylon.js script (with the Tinker adapter) to read both sensors. Using Cylon with Voodoospark produced null values for both sensors.

I'd prefer to use Johnny-Five + Voodoospark, as it produces the most consistent and reliable readings with low latency (for one sensor at a time, at least).

@ericterpstra thanks for the additional info, I'll take a look at this today.

@ericterpstra I've made some updates to the firmware to prevent command loss. Previously, processInput was only called once per loop if necessary. Now it will keep calling until it has exhausted the available bytes.