Communicating with OMEGA HH314A humidity sensor in Matlab *SOLVED*
Show older comments
Hello all, I recently got my hands on an OMEGA HH314A humidity sensor. This communicates with a computer via a RS232 port. It comes with its own proprietary software, however I would like to use matlab to interface with it and receive readings that way. I am able to open up a COM port, however I get a timeout any time I try to read data from the device. My first guess is that perhaps since this device is designed to run off of its own software and driver, that it needs some sort of command before it will send data through the serial port? Trying to figure out what my next steps should be here. I am using version 2007A. Thank you!
- Alex
EDIT: Solved the issue. Played around with a bit of syntax and ended up with this:
s = serial('COM3','BaudRate',9600);
fopen(s);
fwrite(s,'A'); %prompts device to send data
pause(1);
fwrite(s,'c'); %prompts device to stop sending data
for i = 1:7
arr(i,1) = fread(s,1); %put each byte into an array
end
humidity = ((arr(4,1)*255)+ arr(5,1))/10; %convert values
temp = ((arr(6,1)*255)+ arr(7,1))/10; %convert values
fclose(s);
3 Comments
Alex Teichman
on 19 Jun 2017
Edited: Walter Roberson
on 19 Jun 2017
Walter Roberson
on 19 Jun 2017
I would experiment with
fprintf(s, 'E\n')
and
fprintf(s, 'E\r')
and
fprintf(s, 'E\r\n')
Alex Teichman
on 21 Jun 2017
Answers (0)
Categories
Find more on Instrument Control Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!