Hi,
I try to use MH-Z16 CO2 (datasheet is here). It uses the UART protocol. I connect it to 5 socket (SUY) to my Mountaineer Ethernet board.
Get power (5 volts) from socket - pin 2. And connect TX to 4 pin and RX to 5 pin. Then I tried to send command to sensor and get response from it. Nothing happens. Write method works silently, but Read method freezes the program. If I use ReadTimeout property method Read returns zero:(. May be I’m doing something wrond again?
using System.IO.Ports;
using System.Threading;
namespace SensorsDebug
{
public class Program
{
public static void Main()
{
var s = new SerialPort(Mountaineer.Netmf.Hardware.Socket5.SerialPortName, 9600, Parity.None, 8, StopBits.One);
s.Open();
var buf = new byte[] {0xff, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
s.Write(buf, 0, 9);
s.Flush();
Thread.Sleep(100);
var cnt = s.Read(buf, 0, 9);
}
}
}