We are connecting a CO2 sensor with the RJ12 connector.
The imp that we are using is the battery powered sensor node which uses imp003
https://electricimp.com/docs/hardware/resources/reference-designs/sensornode/
This is the MISIR CO2 sensor sensor we are using.
http://www.co2meters.com/Documentation/Manuals/Manual-GSS-Sensors.pdf
Datasheet:
The callback function doesn’t get call. However, when we write a command(from the manual above), the callback is triggered and has return some value like 240, 224 or 0.
Please help us read the sensor, this is our first time encountering UART.
Thanks.
Here is the code that we are using.
local MISIR = hardware.uartFG;
local msg = “”;
function readMISIR() {
//local c = MISIR.read();
//server.log©;
//Pull a byte from the UART FIFO
local c = MISIR.read();
// Determine if this byte is a carriage return (triggers to log the line)
if (c == ‘\n’){
// Transmit message to the server
server.log(msg)
// Clear the message buffer
msg = "";
}
else{
// Accumulate the message string
msg=msg+format("%c",c);
}
server.log(msg);
}
imp.setpoweren(true);
local state = 1
hardware.pinY.configure(DIGITAL_OUT, state);
hardware.pinS.write(1);
MISIR.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS, readMISIR);
MISIR.write(“Z\r\n”);