% Humidity and temperature are read from a ThingSpeak channel to calculate % dew point. % TODO: Change readChannelID to your ChannelID % Script expects temperature in C. It then calculates dewpoint in C. % Temperatures are then converted to F and charted. % If you read temperature in F, you must first convert it to C % before doing the dewpoint calculation. % Channel ID to read data from % enter your ThingSpeak channel ID here: readChannelID = 123792; % Humidity Field ID HumidityFieldID = 2; % Temperature Field ID TemperatureFieldID = 1; dataPoints = 100; % Read temperature and time [tempC, time] = thingSpeakRead(readChannelID, 'Fields', TemperatureFieldID, 'NumPoints', dataPoints); %tempC = thingSpeakRead(readChannelID, 'Fields', TemperatureFieldID); % Read humidity humidity = thingSpeakRead(readChannelID, 'Fields', HumidityFieldID); % Calculate dew point % Specify the constants for water vapor (b) and barometric (c) pressure. b = 17.62; c = 243.5; % Calculate the intermediate value 'gamma' gamma = log(humidity / 100) + b * tempC ./ (c + tempC); % Calculate dew point in Celsius dewPointC = c * gamma ./ (b - gamma); % Convert temperatures to Fahrenheit for display dewPointF = (dewPointC * 1.8) + 32; tempF = (tempC * 1.8) + 32; thingSpeakPlot(time, [tempF, dewPointF], 'ylabel','Temperature (°F)','legend',... {'Temp °F', 'Dew Point °F'}, 'Grid', 'on', 'linewidth', 2);