Did you make sure to set the bit in the mraa function? Check mraa: /var/lib/jenkins/workspace/mraa-doc/api/mraa/aio.h File Reference and you’ll see the mraa_aio_set_bit function; it requires you to set the number of bits in order to work correctly.
Thanks for the response. I have reading around the setBit() method, is a function to set the bit value which mraa will shift the raw reading from de ADC.
Using node.js I guess that the mraa library set it by default by 10. I have been toying around with different values, 8, 10, 12 and 0. Using 10 and 0 I got the same values as not declaring the setBit() method in the program.
I don´t know if it is a problem of the mraa but having 4 analog sensors connected when for example I change the value of the potentiometer the rest of the readings gone crazy for a while, around 10 seconds. With a tester I will try to read the voltage outputs to see if it corresponds to mraa readings or if there is any issue with the board
Anybody has the same issue?
Did you have a chance to read the voltage outputs of the sensors? If you change the value of for example a potentiometer then the readings should not be throwing wrong readings for that long. Have you checked that this is not an issue with the components/sensors you are using rather than the board or the mraa library?
You can update mraa with:
echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic-dev" > /etc/opkg/mraa-upm.conf opkg update opkg install libmraa0
You can also post the code you are using here to see if I can help you determine the cause of the issue.
Yes, I had read the voltage outputs of every sensor and in the moment I read the readings are correct form the board, but when I check the graphs there are kind of spikes and patterns.
I have a big problem is with the temperature sensor TMP36GZ that is driving me crazy. I change the TMP36GZ with other new one but I got the same results so for the moment I disconnected on Monday 25 to see if something changes in the rest of the readings.
I post you some code of the main.js. The declaration of the variables and the pins and the function of the TMP36GZ. If you need any other part of the code please ask.
As you see I had commented the TMP36GZ and disconnected form the board to see the behavior of the other variables. Below you can see the readings in a chart
MRAA Version: V0.6.2-13-gf4d67b5
/*jslint node:true,vars:true,bitwise:true,unparam:true */
/*jshint unused:true */
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var MongoClient = require('mongodb').MongoClient;
var mraa = require("mraa");
var myAnalogPin = new mraa.Aio(0);
var lightPin= new mraa.Aio(1);
var moistPin = new mraa.Aio(2);
var waterLevelPin = new mraa.Aio(4);
//var tempPin = new mraa.Aio(3);
console.log('MRAA Version: ' + mraa.getVersion());
d = tempPin.read();
tempC = d * 0.004882814; // for 5volts input
tempC = (tempC-0.5)*(-100); -------> IT SHOULDN´T HAVE THE '-' SING BUT IF NOT ALL THE READINGS WHERE NEGATIVE. SEE THE CHART TO SEE WHEN I PUT THE MINUS SING
tempC = tempC.toFixed(2);
//console.log("Temperatura " + tempC);
Potentiometer(It is written moist in the Y-axis but is the potentiometer) Word that I did´t change the value of the potentiometer.
Temperature (It is crazy. On monday 25 I decided to disconnect and find another sensor)
Just to point. In Tue 26 I connected another analog sensor, a Milone Etape , and can see the same pattern in the moist and in the potentiometer. Btw the pattern repeats all along the graph
Thanks for posting the code. I looked at it and it seems ok, both the declaration of variables and the rest of the code. If you tested this with more than one sensor and got the same results it is unlikely that the errors were caused by a damaged device. Maybe a connection issue, I checked the datasheet of the TMP36 and it is supposed to be connected to a capacitor, did you connected one? Are you using an external power supply for the sensors, and making sure they are receiving enough current?
Take a look at Intel® XDK IoT Edition node.js Templates | Intel® Developer Zone . Even though your code seems correct you can double check taking this document into account to see if the is something you missed.
Sorry for taking so long to answer but I was waiting a 5V - 2amp power supply, mine was 5V - 500mAmp. After connecting the capacitor to the TMP36GZ and changing the power supply I still have problems with the temperature sensor. I will open another discussion to see if the people make it work.
Meantime disconnecting the TMP36GZ everything works fine so I´m going to change the sensor.