PropBasic: SHT11 help
skynugget
Posts: 172
hey all, im trying to come up with a driver for the SHT11 Temp/Humidity sensor, and im coming up a little short.
the following code is producing unexpected results, and im not sure if its my math or my read and write routines. is anyone familiar enough with this sensor able to steer me in the right direction?
thanks so much in advance!
the following code is producing unexpected results, and im not sure if its my math or my read and write routines. is anyone familiar enough with this sensor able to steer me in the right direction?
SUB SHT_GetTmp RawT var __param1 tmp var __param2 SHT_Start ' start sequence SHT_WRByte SHT_Tmp ' request temperature SHT_WAIT ' wait up to 250ms to measure RawT = SHT_RdByte Ack ' get first byte tmp = SHT_RdByte NoAck ' get second byte tx_dec rawt 'debug msb tx_byte 13 'debug cr tx_dec tmp 'debug lsb tx_byte 13 'debug cr RawT = RawT << 8 ' shift over first byte RawT = RawT | tmp ' combine the low byte RawT = RawT << 16 ' shift over for a 16bit result \ SAR RawT,#16 ' shift the sign as well tx_dec rawt 'debug raw temp tx_byte 13 'debug cr 'sensiron forumula: celcius = RawT * .01 - 40 TempC = RawT ** 42949673 'rawt * .01 TempC = TempC - 40 '-40 tx_dec tempC 'debug celcius tx_byte 1 'debug home ENDSUB
thanks so much in advance!
Comments
this is not much information about your problem.
To find out the source of problems - data connection or maths, I would try to display raw data first. If this reacts to temperature changements, then I would try to debug maths.
Good luck,
Christof
instead of aliasing a param, i declared long. though i thought you could alias a param for use to save space?
EDIT: i think param got reset in a nested sub call
thanks for looking everyone! ill post the rest when i get er all done.
so i opted to use the LMM code, but now im getting a compiler error "Address out of range".
ive attached what im working with, uncomment the lmm at program start to see what i mean. am i overlooking something else?
thanks again!