SHT11 C code Library trouble
Cree
Posts: 132
Hi, sry i'm new to simple IDE program, I have done some c coding in school.
I had found the c code for the propeller from the following link
http://forums.parallax.com/showthread.php/148116-Sensirion-SHT11-SimpleTools-Code?highlight=sht11+code
I had tried to use it, but when I tried to make the lib/library with the header file it came with, I got an error. (unkown type name at line 104) I tried to fix it myself, but I wouldn't figure it out by searching through the forums.
Can someone help me out?
I had found the c code for the propeller from the following link
http://forums.parallax.com/showthread.php/148116-Sensirion-SHT11-SimpleTools-Code?highlight=sht11+code
I had tried to use it, but when I tried to make the lib/library with the header file it came with, I got an error. (unkown type name at line 104) I tried to fix it myself, but I wouldn't figure it out by searching through the forums.
Can someone help me out?
[URL="http://forums.parallax.com/showthread.php/148116-Sensirion-SHT11-SimpleTools-Code?highlight=sht11+code"]/** [/URL]* @file sht11.h * * @author TDL * * @copyright * Copyright (C) 2013. All Rights MIT Licensed. * * @brief Measure sht11 Humidity and Temperature Sensor * */ #ifndef _SHT11_H #define _SHT11_H #if defined(__cplusplus) extern "C" { #endif //#define DEBUGSCOPE #ifdef DEBUGSCOPE #define scopepin 15 // Pick one of the scope triggers //#define TRIGREAD #define TRIGCOMMAND //#define TRIGRESETSEQ //#define TRIGSTARTSEQ //#define TRIGREADSTAUS #endif /* Define a structure to contain the answers calculated from ** */ typedef struct sht11values { // Keep everyting a long like Spin version long rawhum; // Raw Humidity counts long rawtemp; // Raw Temp counts long rhlin; // Humidity linerized long rhtrue; // True Humidity rhlin adjusted for a Temp not at 25 deg C long tempC; // Temp in deg C long tempF; // Temp in deg F } sht11values_t; /* Define the commands sent to the sht11 ** */ #define KREADTEMP 0b00000011 #define KREADHUM 0b00000101 #define KREADSTATUS 0b00000111 #define KWRITESTATUS 0b00000110 #define KSOFTRESET 0b00011110 /*Define constants for doing fixed point math to convert raw counts to integer values representing floating point values*/ /*3.3 VOLT SUPPLY ON SHT11*/ /* Pick one set of constants by un commenting the one desired*/ #define _V5DATASHEET //#define _ORGDATASHEET /*Temp conversion constants from Sensirion data sheet*/ /*Convert 10 Times to get 0.1 degrees*/ #ifdef _V5DATASHEET /*V5 Constants*/ /*Fractional parts of constants cannot be greator than 1*/ #define Kd1C_16_16 25991578 // 10 * 39.66 @ 3.3 Volts, is minus but do a subtract instead of sign here #define Kd1F_16_16 25834291 // 10 * 39.42 @ 3.3 Volts, is minus but do a subtract instead of sign here #define Kd2C_0_16 6554 // 10 * 0.01 #define Kd2F_0_16 11796 // 10 * 0.018 /*RHlin constants to compute 10 times RHlin*/ #define Kc3_0_16 1 // 1.5955e-5 times 65536 actually 1.04 rounded up #define Kc3_0_24 268 // 1.5955e-5 as a 24 bit fraction ie times 2^24 #define Kc3_0_32 85899 // 10 * 2e**-6 times 2**32 #define Kc2_0_16 24052 // 10 * 0.0367 times 65536 #define Kc1_16_16 1341391 // 10 * 2.0468 times 65536 /*Constants to compute RH true ie RHlin adjusted for temp different than 25 Deg C RHtrue = (TC - 25)* (t1 + t2* SOH) + RHlin We have 10 times RHlin so multiply constants by 10*/ #define Kt1_0_16 6554 // 0.1 * 65536 #define Kt2_0_16 52 // 0.0008 * 65536 #endif // V5 Data Sheet Copnstants // Throw everything in so we can call it if needed during testin int Start(int DatP, int ClkP, sht11values_t *pValues); int SetIdle(); int StartSeq(); int ResetSeq(); int SendCommand(uint8_t Cmd); long ReadValue(); long ReadStatusReg(); long RawToTempC(long raw); long RawToTempF(long raw); long ConvertC2F(long degC); long RawToRHlin(long raw); /* Executing Measure() will take a complete measurement of Humidity and Temp and pupulate the sht11values_t structure with raw and calculated values The user of library creates the instance of sht11values_t and a pointer to it to pass to the Start() function */ int Measure(); #if defined(__cplusplus) } #endif /* __cplusplus */ #endif /* _SHT11_H */ /** * TERMS OF USE: MIT License * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */
Comments
#include "stdint.h"
Are you using the latest version of SimpleIDE from Learn Parallax.
or trying to use the code with your own makefile.
The thread you got the code from is one of the first things I tried with Propeller C and there is newer
version I will dig out. However even the one you have builds in the SimpleIDE version back in March.
It should be the latest versipn of simple ide, I dowloaded a few weeks ago.
What do u mean by makefile?
I tried, it didnt work.
This what I got:
The file you have ins't a piece of complete code. Its complaining about the lack of main because you just have an H file there.
A make file is a text file that is read by an application called make or ndmake which tells make how to build
the program from the collection of C and H files.
SimpleIDE hides this from you and it's project manager interface does it in the background for you.
Have you tried the tutorials at http://learn.parallax.com/propeller-c-tutorials and successfully built and ran
the first tutorial.
The thread you refered to in your first post was some initial trys using Propeller C by me with the sensor.
It became a simple library.
Rather than try and get the library and the project files into the right spot in your file structure of SimpleIDE
and Prop C at this time I pulled the latest into a stand alone project.
If you unzip the attached zip file to a folder under your My Projects folder and open the project SHT11Debug.side
it will build and run. You will have to edit the DatPin and ClkPin numbers to match how you wired your sensor.
Mine are 8 and 9 in the source right now.
Also have you read SimpleIDE-User-Guide.pdf
Tom
I did do the hello program for a serial lcd.
I should be good with the code you gave. Thx, I appreciate the help.