Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Chainable_RGB_LED DHT LED_Bar mbed mbedConnectorInterface mbedEndpointNetwork_mjk_regfix
DHT11_TempResource.h
00001 /** 00002 * @file DhtTempResource.h 00003 * @brief mbed CoAP Endpoint 00004 * @author Michael Koster 00005 * @version 1.0 00006 * @see 00007 * 00008 * Copyright (c) 2015 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); 00011 * you may not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, 00018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 */ 00022 00023 #ifndef __DHT_TEMP_RESOURCE_H__ 00024 #define __DHT_TEMP_RESOURCE_H__ 00025 00026 // Base class 00027 #include "DynamicResource.h" 00028 00029 #include "DHT11.h" 00030 00031 /** DhtTempResource class 00032 */ 00033 class DhtTempResource : public DynamicResource 00034 { 00035 public: 00036 /** 00037 Default constructor 00038 @param logger input logger instance for this resource 00039 @param name input the resource name 00040 @param observable input the resource is Observable (default: FALSE) 00041 */ 00042 DhtTempResource(const Logger *logger,const char *name,const bool observable = false) : 00043 DynamicResource(logger,name,"urn:X-ipso:temperature", SN_GRS_GET_ALLOWED,observable) { 00044 } 00045 00046 /** 00047 Get the value of the Temperature Sensor 00048 @returns string containing the temperature value in Fahrenheit 00049 */ 00050 virtual string get() { 00051 char temp_str[6]; 00052 memset(temp_str,0,6); 00053 float temp_f = DHT_sensor.ReadTemperature(FARENHEIT); 00054 sprintf(temp_str,"%5.2f", temp_f); 00055 return string(temp_str); 00056 } 00057 }; 00058 00059 #endif // __DHT_TEMP_RESOURCE_H__
Generated on Wed Jul 13 2022 19:30:15 by
1.7.2