Trouble Programming Sensirion Temperature on Activity Board in Propeller C
yoyo
Posts: 15
Hi, I want to use the Sensiroin temperature sensor on the Activity Board, but the example code for the sensor is in Basic Stamp. Anybody know how to program the sensor in Propeller C? I attached the example code I downloaded from Parallax's documentation for the sensor.
Comments
obex.parallax.com/object/186
obex.parallax.com/object/515
obex.parallax.com/object/516
obex.parallax.com/object/517
Here is a link to a Arduino C code example:
https://github.com/practicalarduino/SHT1x/
Here is a link to another Forum posting regarding SHT11 module:
forums.parallax.com/discussion/145830/sht11-sensor-incorrect-readings-calibration
Hopefully the above will help, good luck...
http://forums.parallax.com/discussion/164647/c-language-sensirion-sht11-temperature-humidity-part-28018
I am probably going to be putting together another PropGCC sht11 project, so somewhere down the line I will have to dig up the code, but not at this moment. If I happen to stumble across it, I will post it again. By the way, back in 2013 I did have a thread going for the sht11 module, and if you dig a little you might find the code listing in the thread.
Ray
http://www.aestheticacoustics.com/SHT11_05.htm
line 69:34 "expected ')' before ',' token"
line 69:54"expected expression before ';' token"
line 93:6 "expected identifier or '*' before 'while'"
line 94:1 "expected declaration or statement at end of input".
Thank you for reading, and have a great day.
/*
Blank Simple Project.c
http://learn.parallax.com/propeller-c-tutorials
*/
#include "simpletools.h" // Include simple tools
#include "simpletext.h"
#include "simplei2c.h"
#include "ping.h"
const int ShtData = 14;
const int Clock = 13;
const int ShtTemp = 00011;
const int ShtStatW = 00110;
const int ShtStatR = 00111;
const int ShtReset = 11110;
const int Ack = 0;
const int NoAck = 1;
const int MoveTo = 2;
const int ClrRt = 11;
const int DegSym = 186;
int ioByte;
int ackBit;
int toDelay;
int timeOut;
int soT;
int status;
int shiftout();
int shiftin();
#define int16_t
int main() // Main function
{
shiftout(ShtData, Clock, LSBFIRST, 00000011); // Add startup code here.
pause(250);
CLS;
print("SHT1x Demo", CR);
print("
", CR);
while(1)
{ // Add main loop code here.
// measuretemp();
input(ShtData);
low(Clock);
high(Clock);
low(ShtData);
low(Clock);
high(Clock);
input(ShtData);
low(Clock);
ioByte = ShtTemp;
shiftout(ShtData, Clock, MSBPRE, ioByte);
shiftin(ShtData, Clock, LSBFIRST, ackBit);
input(ShtData);// particular trouble with this section <-
for(int n = 1; n <= 250; n++) // <-
timeOut = (unsigned (int16_t), LSBFIRST, ShtData);
if(timeOut = 0);
{
(ackBit = Ack);
shiftin(ShtData, Clock, MSBPRE, ioByte);
shiftout(ShtData, Clock, LSBFIRST, ackBit);
input(ShtData);
MSBFIRST, soT = ioByte;
ackBit = NoAck;
shiftin(ShtData, Clock, MSBPRE, ioByte);
shiftout(ShtData, Clock, LSBFIRST, ackBit);
input(ShtData);
print("Raw Data Temp: ShtTemp = %d ", ShtTemp);
pause(1000);
goto while(1);
}
pause(1);
}
goto while(1);
}
Thanks
Tom
Is that what you intended?
Tom
HalAlbach, can you please explain line 71 more thoroughly? Thanks.
So, if you want to execute the code body after the if statement then you need to make the following change to the statement;
I believe I was in error when I stated that the code following the if statement would never execute, rather, it will execute regardless what value timeOut held. I failed to notice the terminating semicolon.