Situation
I wanna measure the temperature using LM35DZ on raspberry pi 3.
I'm using MCP3208 ADC. And since the other analogue sensors (eg. flame sensor..) are working normally, I have no problem with MCP3208.
Problem
But LM35DZ are not working with MCP3208, the outputs are always 0
.
Here are my code with nodejs, a circuit and a pin map.
Code
var mcpadc = require('mcp-spi-adc');
var pigpio = require('pigpio');
function analogRead(channel) {
return new Promise((resolve, reject) => {
var sensor = mcpadc.openMcp3208(channel, (err) => {
if (err) reject(err);
sensor.read((err, reading) => {
if (err) reject(err);
resolve(reading);
});
});
});
}
var Gpio = pigpio.Gpio;
var lm35;
var iv;
iv = setInterval(() => {
analogRead(7).then((value) => {
console.log(value);
})
}, 300);
Result
...
{ rawValue: 0, value: 0 }
{ rawValue: 0, value: 0 }
{ rawValue: 0, value: 0 }
...
Circuit
sorry for my poor painting skills..
MCP3208 Din
is not connected directly to GND
.
And I add voltage divider
on connection between MCP3208 Din
and Pi MISO
because someone said I must not put 5V signal into Rpi.
My Circuit and code are working well with the other sensors, but not working on LM35DZ.