////////////////////////////////////////////////////////////////////// terjemahan - ////////////////////////////////////////////////////////////////////// Inggris Bagaimana mengatakan

///////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// //
// Librería C para el control de sensores de Temperatura y Humedad: //
// //
// SHT10, SHT11, SHT15, SHT71, SHT75 //
// //
// Debe cargarse este archivo desde la cabecera del programa principal con: //
// #include //
// //
// * Inicialización del sensor mediante la función: //
// SHTxx_init (); //
// //
// * Obtención de la medida de humedad y temperatura mediante la función: //
// SHTxx (sht_temperatura, sht_humedad); //
// En las variables sht_temperatura y sht_humedad se obtienen los valores //
// reales de temperatura y humedad medidos. //
// //
// * Escritura del valor del registro de estado mediante la función: //
// SHTxx_ESCRITURA_REGISTRO_ESTADO (sht_registro); //
// sht_registro deberá contener el valor a cargar en el registro (defecto 0) //
// bit0 = 0 => Resolución 14bits Temperatura y 12 bits Humedad //
// bit0 = 1 => Resolución 12bits Temperatura y 8 bits Humedad //
// bit1 = 0 => Dato de calibración no se carga antes de cada medida //
// bit1 = 1 => Dato de calibración se carga antes de cada medida //
// bit2 = 0 => Calefactor interno OFF //
// bit2 = 1 => Calefactor interno ON //
// bit6 = 0 => Detección baja tensión Vcc > 2.47V (bit de solo lectura) //
// bit6 = 1 => Detección baja tensión Vcc < 2.47V (bit de solo lectura) //
// //
// * Obtención del valor del registro de estado mediante la función: //
// SHTxx_LECTURA_REGISTRO_ESTADO (sht_registro); //
// sht_registro devolverá el valor del registro de estado //
// //
// * Reset del soft del sensor mediante la función: //
// SHTxx_Reset_Soft (); //
// (Registro de estado a sus valores por defecto) //
// //
// http://robotypic.blogspot.com/ //
// //
////////////////////////////////////////////////////////////////////////////////

/**************** Definición de pines del bus serie **************************/

#define sht_data_pin PIN_A4
#define sht_sck_pin PIN_A3

/** Comand del SHT11 **/

#define SHT11_REG_ESTADO_W 0x06 //Comand escritura en registro de estado
#define SHT11_REG_ESTADO_R 0x07 //Comand lectura de registro de estado
#define SHT11_COMANDO_TEMP 0x03 //Comand medida de temperataur
#define SHT11_COMANDO_kel 0x05 //Comand medida de kel
#define SHT11_SOFT_RESET 0x1E //Comand reset de soft

/***** Variables globales para lectura del valor de temperatura y humedad *****/

float sht_temperatur; //Guardará el valor real de temperatura medida
float sht_kelembaban; //Guardará el valor real de humedad medida
int8 sht_register; //Guardará el valor del register de estado

/******************************************************************************/
/**************** SECUENCIA DE INICIO DE TRANSMISIÓN **************************/
// _____ ________
// DATA: |_______|
// ___ ___
// SCK : ___| |___| |______

void SHT11_InicioTrans (void) {
//DATA a "0" con SCK a "1"
output_float(sht_data_pin); //línea DATA a "1"
output_low(sht_sck_pin); //línea SCK a "0"
delay_us(1);
output_high(sht_sck_pin); //línea SCK a "1"
delay_us(1);
output_low(sht_data_pin); //línea DATA a "0"
delay_us(1);
//SCK a "0" sin cambiar DATA "0"
output_low(sht_sck_pin); //línea SCK a "0"
delay_us(2);
//SCK a "1" sin cambiar DATA "0"
output_high(sht_sck_pin); //línea SCK a "1"
delay_us(1);
//DATA a "1" con SCK a "1"
output_float(sht_data_pin); //línea DATA a "1"
delay_us(1);
output_low(sht_sck_pin); //línea SCK a "0"
}

/******************************************************************************/
/*********************** SECUENCIA DE RESET ***********************************/
// _____________________________________________________ ________
// DATA: |_______|
// _ _ _ _ _ _ _ _ _ ___ ___
// SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |______

void SHTxx_Reset (void) {

int i;
//inicio de secuencia con SCK a "0" y DATA a "1"
output_float(sht_data_pin); //línea DATA a "1"
output_low(sht_sck_pin); //línea SCK a "0"
delay_us(2);
//conmuta SCK 9 veces con DATA a "1"
for(i=0; i=1; bit--) {
output_low(sht_sck_pin); //línea SCK a "0"
//Línea DATA a "1" si MSB es "1"
if((sht_comando & mascara) > 0) output_float(sht_data_pin);
//Línea DATA a "0" si MSB es "0"
else output_low(sht_data_pin);
delay_us(1);
output_high(sht_sck_pin); //línea SCK a "1"
delay_us(1);
mascara = mascara >> 1; //siguiente bit pasa a ser MSB
}
/** lectura del ack **/
output_low(sht_sck_pin); //línea SCK a "0"
delay_us(1);
ack = input(sht_data_pin); //lectura del ack
output_high(sht_sck_pin); //línea SCK a "1"
delay_us(1);
output_low(sht_sck_pin); //línea SCK a "0"

return(ack);
}

/******************************************************************************/
/**************** SECUENCIA DE ESPERA DE MEDIDA TERMINADA *********************/

void SHT11_Espera (void) {
int16 sht_delay;
output_float(sht_data_pin); //línea DATA a "1"
output_low(sht_sck_pin); //línea SCK a "0"
delay_us(1);
//Espera a que linea DATA pase a "0" máximo 300msg.
for(sht_delay=0; sht_delay fin de la medición
if (!input(sht_data_pin)) break;
delay_us(10);
}
}

/******************************************************************************/
/*************** SECUENCIA DE LECTURA DEL DATO DE LA MEDIDA *******************/
// _ _ _ _ _ _ _ _ ___ _ _ _ _ _ _ _ _
//SCK:__| |_| |_| |_| |_| |_| |_| |_| |_|ack|_| |_| |_| |_| |_| |_| |_| |_| |__
// | | |
// |-- idle bits -|Msb --------- 12 bit Humidity Data ------------ Lsb|
// | _ _ _ _ | _ _ _ _ ___ _ _ _ _ _ _ _ _ |
//DATA:_|F|_|E|_|D|_|C|_|B|_|A|_|9|_|8|_|ack|_|7|_|6|_|5|_|4|_|3|_|2|_|1|_|0|__

int16 SHT11_Lectura (void) {
int8 bit;
int16 sht_dato = 0;
const int16 mascara0 = 0x0000;
const int16 mascara1 = 0x0001;
//guarda byte alto del dato leído en byte alto de sht_dato bit a bit
for(bit=8; bit>=1; bit--) {
sht_dato = sht_dato =1; bit--) {
sht_dato = sht_dato
0/5000
Dari: -
Ke: -
Hasil (Inggris) 1: [Salinan]
Disalin!

/ / / /
/ / Libreria C para el control de sensores de Temperatura y Humedad: / /
/ / / /
/ / SHT10, SHT11, SHT15, SHT71, SHT75 / /
/ / / /
/ / Debe cargarse este archivo desde cabecera del programa main con: / /
/ / #include / /
/ / / /
/ / * initialization del sensor mediante la Función: / /
.SHTxx_init ();
/ / / /
/ / * Obtenteurs de medida de humedad y temperatura mediante la Función: / /
/ / SHTxx (sht_temperatura, sht_humedad);
/ / Las variables sht_temperatura y sht_humedad is Las los valores / /
/ / reales de temperatura y humedad medidos.
/ / / /
/ / * Escritura del valor del registro de estado mediante la Función: / /
.SHTxx_ESCRITURA_REGISTRO_ESTADO (sht_registro);
/ / sht_registro debe contener el valor a cargar El registro (defecto 0) / /
/ / bit0 = 0 => resolución 14 bit Temperatura y 12-bit Humedad / /
/ / bit0 = 1 => resolución 12 bit Temperatura y Humedad 8‑bit / /
/ / bit1 = 0 => Dato de meet no. is carga antes de cada medida.
bit1 = 1 => Dato de di is carga antes de cada medida / /
/ / bit2 = 0 => heater OFF interno / /
/ / bit2 = 1 => heater interno it / /
/ / bit6 = 0 => Detección baja voltage VDC > 2.47V (bit de solo lectura) / /
/ / bit6 = 1 => Detección baja voltage VDC < 2.47V (bit de solo lectura) / /
/ / / /
/ / * Obtenteurs del valor del registro de estado mediante la Función: / /
.SHTxx_LECTURA_REGISTRO_ESTADO (sht_registro);
/ / sht_registro devolvera el valor del registro de estado / /
/ / / /
/ / * Reset del soft del sensor mediante la Función: / /
/ / SHTxx_Reset_Soft ();
/ / (Registro de estado sus valores por defecto) / /
/ / / /
/ / http://robotypic.blogspot.com/ / /
/ / / /
/ / /

* Definición de pines del bus series * /

#define sht_data_pin PIN_A4
#define sht_sck_pin PIN_A3

/ * Comand del SHT11 * /

#define SHT11_REG_ESTADO_W 0 x 06 //Comand escritura in registro de estado
#define SHT11_REG_ESTADO_R 0 x 07 //Comand lectura de registro de estado
#define SHT11_COMANDO_TEMP 0 x 03 //Comand medida de temperataur
.#define SHT11_COMANDO_kel 0 x 05 //Comand medida de kel
#define SHT11_SOFT_RESET 0x1E //Comand reset de soft

/ * Global Variables para lectura del valor de temperatura y humedad * /

float sht_temperatur; Guardara el real valor de temperatura medida
float sht_kelembaban; Guardara el real valor de humedad medida
int8 sht_register; Guardara el valor del register de estado

./ * /
/ * INICIO DE TRANSMISIÓN ESQUEMA * /
/ / _
/ / DATA: |
/ / _
/ / SCK: _ | |

void SHT11_InicioTrans (void) {
//DATA has "0" con SCK a "1"
output_float (sht_data_pin); //linea DATA a "1"
output_low (sht_sck_pin); //linea SCK has "0"
} delay_us (1);
output_high (sht_sck_pin); Linea SCK has "1"
delay_us (1);
output_low (sht_data_pin); Linea DATA a "0"
delay_us (1);
//SCK a "0" sin cambiar DATA "0"
output_low (sht_sck_pin); Linea SCK has "0"
delay_us (2);
//SCK has "1" sin cambiar DATA "0"
output_high (sht_sck_pin); Linea SCK has "1"
delay_us (1);
//DATA has "1" con SCK a "1"
output_float (sht_data_pin); Linea DATA a "1"
delay_us (1);
output_low (sht_sck_pin); //línea SCK a "0"
}

/******************************************************************************/
/*********************** SECUENCIA DE RESET ***********************************/
// _____________________________________________________ ________
// DATA: |_______|
// _ _ _ _ _ _ _ _ _ ___ ___
// SCK : _ | | | | | | | | | | |

void SHTxx_Reset (void) {

int i;
//inicio de secuencia con SCK a "0" DATA is a "1"
output_float (sht_data_pin); //linea DATA a "1"
output_low (sht_sck_pin); //linea SCK has "0"
delay_us (2);
//conmuta SCK 9 veces con DATA a "1"
for(i=0; i<9; i) {
output_high (sht_sck_pin);
delay_us (2);
output_low (sht_sck_pin);
}} delay_us (2); {
}
/ / esquema de inicio de transmisión
SHT11_InicioTrans ();
}

/ * /
/ * ESQUEMA ENVIO DE COMANDO * /
/ / _ _ _ _ _ _ _ _ _
/ / DATA: _A2|_|A1|_|A0|_|C4|_|C3|_|C2|_|C1|_|C0|_|ack|_
// __ __ __ __ __ __ __ __ ___
// SCK : _ | | | | | | | | |

int1 SHT11_Comando (int8 sht_comando) {
int8 bit;
int8 mascara = 0x80;
int1 ack;
delay_us (4);
//Salida del comando bit a bit
for(bit=8; bit>=1; bit--) {
output_low (sht_sck_pin); //linea SCK has "0"
//linea DATA has "1" If MSB es "1"
if ((sht_comando & mascara) > 0) output_float (sht_data_pin);
//linea DATA is "0" If MSB es "0"
}} else output_low (sht_data_pin);
delay_us (1);
output_high (sht_sck_pin); Linea SCK has "1"
delay_us (1);
mascara mascara = > 1; {siguiente bit pasa a ser MSB
}
/ * lectura del ack * /
output_low (sht_sck_pin); Linea SCK has "0"
delay_us (1);
ack = input (sht_data_pin); LECTURA del ack
output_high (sht_sck_pin); Linea SCK has "1"
delay_us (1);
output_low (sht_sck_pin); Linea SCK has "0"

return (ack);
}

/ * /
/ * MEDIDA TERMINADA ESPERA ESQUEMA * /

void SHT11_Espera (void) {
int16 sht_delay;
output_float (sht_data_pin); //linea DATA a "1"
output_low (sht_sck_pin); //linea SCK has "0"
delay_us (1);
} {Espera a linea DATA pase a "0" maximo 300msg.
for(sht_delay=0; sht_delay<30000; sht_delay) {
cause linea DATA pasa a "0" => end de la medición
if (! input (sht_data_pin)) break;
delay_us (10);
}
}

/ * /
/ * LECTURA DEL DATO LA MEDIDA ESQUEMA /
.// _ _ _ _ _ _ _ _ ___ _ _ _ _ _ _ _ _
//SCK:__| |_| |_| |_| |_| |_| |_| |_| |_|ack|_| |_| |_| |_| |_| |_| |_| |_| |__
// | | |
// |-- idle bits -|MSB - 12-bit Humidity Data - Lsb|
/ / | _ _ _ _ | _ _ _ _ ___ _ _ _ _ _ _ _ _ |
//DATA:_|F|_|E|_|D|_|C|_|B|_|A|_|9|_|8|_|ACK|_|7|_|6|_|5|_|4|_|3|_|2|_|1|_|0|__

int16 SHT11_Lectura (void) {
int8 bit;
int16 sht_dato = 0;
} const int16 mascara0 = 0x0000;
const int16 mascara1 = 0x0001;
//guarda byte alto del dato leido byte alto de sht_dato bit a bit
for(bit=8; bit>=1; bit--) {
sht_dato = sht_dato < 1; //siguiente bit pasa a ser MSB
output_high (sht_sck_pin); //linea SCK has "1"
delay_us (1);
cause linea DATA are "1" pone bit correspondiente in sht_dato a "1"
if (input (sht_data_pin)) sht_dato | = mascara1;}
cause linea DATA are "0" pone bit correspondiente in sht_dato a "0"
else sht_dato | = mascara0;
output_low (sht_sck_pin); Linea SCK has "0"
delay_us (1);
}

//Envio ack poniendo linea DATA a "0"
output_low (sht_data_pin); Linea DATA a "0"
delay_us (1);
output_high (sht_sck_pin); Linea SCK has "1"
delay_us (2);
output_low (sht_sck_pin); Linea SCK has "0"
delay_us (1);
output_float (sht_data_pin); Linea DATA a "1"

//guarda byte bajo del dato leido byte bajo de sht_dato bit a bit
for(bit=8; bit>=1; bit--) {
sht_dato = sht_dato < 1; //siguiente bit pasa a ser MSB
output_high (sht_sck_pin); //linea SCK has "1"
}
Sedang diterjemahkan, harap tunggu..
Hasil (Inggris) 2:[Salinan]
Disalin!
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ / / /
/ / C Librería para el control de sensores of Temperatura there Humedad: / /
/ / / /
/ / SHT10, SHT11, SHT15, SHT71, SHT75 / /
/ / / /
/ / Debe este archivo cargarse desde la cabecera del programa main con: / /
/ / # include/ /
/ / / /
/ / * Inicialización del sensor mediante the función: / /
/ / SHTxx_init (); / /
/ / / /
/ / * obtención of medida de humedad y temperatura mediante the función: / /
/ / SHTxx (sht_temperatura, sht_humedad); / /
/ / En las variables sht_temperatura sht_humedad there is obtienen los valores / /
/ / reales y temperatura of humedad medidos. / /
/ / / /
/ / * escritura del valor del registro de estado mediante the función: / /
/ / SHTxx_ESCRITURA_REGISTRO_ESTADO (sht_registro); / /
/ / sht_registro deberá contener el valor has cargar en el registro (defecto 0) / /
/ / bit0 = 0 => Resolución Temperatura 14bits y 12 bits Humedad / /
/ / bit0 = 1 => Resolución 12bits Temperatura are 8 bits Humedad / /
/ / bit1 = 0 => Dato calibración of no se carga antes de cada medida / /
/ / bit1 = 1 => Dato calibración of antes de cada is carga medida / /
/ / bit 2 = 0 => Calefactor interno OFF / /
/ / bit 2 = 1 => ON Calefactor interno / /
/ / bit 6 = 0 => detección baja tensión Vcc> 2.47V (bit solo lectura) / /
/ / bit 6 = 1 => detección baja tensión Vcc <2.47V ( bit solo lectura) / /
/ / / /
/ / * obtención del valor del registro de estado mediante the función: / /
/ / SHTxx_LECTURA_REGISTRO_ESTADO (sht_registro); / /
/ / el valor del sht_registro devolverá registro de estado / /
/ / / /
/ / * Reset del del soft sensor mediante the función: / /
/ / SHTxx_Reset_Soft (); / /
/ / (Registro de estado has extra valores por defecto) / /
/ / / /
/ / http://robotypic.blogspot.com/ / /
/ / / /
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / **************** Definición of pines bus serie del ********* ***************** / # define sht_data_pin PIN_A4 # define sht_sck_pin PIN_A3 / ** Comand del SHT11 ** / # define SHT11_REG_ESTADO_W 0x06 / / Comand escritura in registro de estado # define SHT11_REG_ESTADO_R 0x07 / / Comand lectura de registro de estado SHT11_COMANDO_TEMP 0x03 # define / / Comand medida of temperataur SHT11_COMANDO_kel 0x05 # define / / Comand medida kel # define SHT11_SOFT_RESET 0x1E / / Comand soft reset / ***** Global Variables para lectura del valor de temperatura y humedad ***** / float sht_temperatur; / / Guardará el valor real de temperatura medida float sht_kelembaban; / / Guardará el valor real de medida humedad sht_register int8; / / Guardará el valor del register of Secuencia INICIO OF TRANSMISSION OF ************************** / / / _____________ / / DATA: | _______ | / / ______ / / SCK : ___ | | ___ | | ______ SHT11_InicioTrans void (void) { / / DATA has "0" con SCK "1" output_float (sht_data_pin); / / DATA línea a "1" output_low (sht_sck_pin); / / SCK línea "0" delay_us (1); output_high (sht_sck_pin); / / SCK línea "1" delay_us (1); output_low (sht_data_pin); / / DATA línea a "0" delay_us (1) / / SCK "0" sin cambiar DATA "0" output_low (sht_sck_pin); / / SCK línea "0" delay_us (2) / / SCK "1" sin cambiar DATA "0" output_high (sht_sck_pin); / / SCK línea "1" delay_us (1) / / DATA has "1" con SCK "1" output_float (sht_data_pin); / / DATA línea a "1" delay_us (1); output_low (sht_sck_pin); / / SCK línea Secuencia RESET *********************************** / / / _____________________________________________________________ / / DATA: | _______ | / / _______________ / / SCK: __ | | __ | | __ | | __ | | __ | | __ | | __ | | __ | | __ | | ______ | | ___ | | ______ SHTxx_Reset void (void) { int i; / / inicio of secuencia con SCK "0" DATA there is "1" output_float (sht_data_pin); / / DATA línea a "1" output_low (sht_sck_pin); / / Línea SCK "0" delay_us (2) / / conmuta SCK 9 veces con DATA is "1" for (i = 0; i <9 i + +) { output_high (sht_sck_pin) delay_us (2); output_low ( sht_sck_pin) delay_us (2); } / / secuencia de inicio de transmisión SHT11_InicioTrans Secuencia OF SHIPPING OF COMANDO **************************** / / / ___________________ / / DATA: ___ | A2 | _ | A1 | _ | A0 | _ | C4 | _ | C3 | _ | C2 | _ | C1 | _ | C0 | _ | ack | _ / / ___________________ / / SCK : ___ | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ int1 SHT11_Comando (int8 sht_comando) { int8 bit; int8 mascara = 0x80; int1 ack; delay_us (4 ) / / Salida del comando bit a bit for (bit = 8; bit> = 1 bit -) { output_low (sht_sck_pin); / / SCK línea "0" / / DATA Línea a "1" if MSB are "1" if ((sht_comando & mascara)> 0) output_float (sht_data_pin) / / DATA Línea a "0" if MSB are "0 " else output_low (sht_data_pin) delay_us (1); output_high (sht_sck_pin); / / SCK línea "1" delay_us (1) mascara mascara >> = 1; / / Siguiente bit pasa a ser MSB } / ** lectura del ack ** / output_low (sht_sck_pin); / / SCK línea "0" delay_us (1) ack = input (sht_data_pin); / / Lectura del ack output_high (sht_sck_pin); / / SCK línea "1" delay_us (1); output_low (sht_sck_pin); / / SCK línea Secuencia DE DE ESPERA MEDIDA terminada ********************* / void SHT11_Espera (void) { int16 sht_delay; output_float (sht_data_pin); / / DATA línea a "1" output_low (sht_sck_pin); / / Línea SCK "0" delay_us (1) / / Espera has only linea DATA pase a "0" máximo 300msg. forum (sht_delay = 0; sht_delay <30000; sht_delay + +) { / / if linea DATA pasa a "0 "=> end of the medición if (! input (sht_data_pin)) Secuencia Lectura OF THE DEL DATO MEDIDA ******************* / / / ___________________ / / SCK __ | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ | ack | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | __ / / | | | / / | - idle bits - | --------- 12 bit Msb Humidity Data ------------ Lsb | / / | _ ___ | _______________ | / / DATA: _ | F | _ | E | _ | D | _ | C | _ | B | _ | A | _ | 9 | _ | 8 | _ | ack | _ | 7 | _ | 6 | _ | 5 | _ | 4 | _ | 3 | _ | 2 | _ | 1 | _ | 0 | __ int16 SHT11_Lectura (void) { int8 bit; sht_dato int16 = 0, const int16 mascara0 = 0x0000, 0x0001 = const int16 mascara1; / / guarda alto del dato Leïdo byte to byte viola sht_dato bit a bit for (bit = 8; bit> = 1 bit -) { sht_dato 1 << = sht_dato; / / Siguiente bit pasa a ser MSB output_high (sht_sck_pin); / / SCK línea "1" delay_us (1) / / if línea es DATA "1" pone correspondiente bit sht_dato a "1" if (input (sht_data_pin)) sht_dato | = mascara1; / / if línea es DATA " 0 "pone bit correspondiente sht_dato in a" 0 " else sht_dato | = mascara0; output_low (sht_sck_pin); / / SCK línea "0" delay_us (1); } / / ack Envío poniendo linea DATA has "0" output_low (sht_data_pin); / / DATA línea a "0" delay_us (1); output_high (sht_sck_pin); / / SCK línea "1" delay_us (2); output_low (sht_sck_pin); / / SCK línea "0" delay_us (1); output_float (sht_data_pin); / / DATA línea a "1" / / guarda bajo del dato Leïdo byte to byte bajo sht_dato bit a bit for (bit = 8; bit> = 1 bit -) { = sht_dato sht_dato << 1; / / Siguiente bit pasa a ser MSB output_high (sht_sck_pin); / / SCK línea "1"




































































































































































Sedang diterjemahkan, harap tunggu..
Hasil (Inggris) 3:[Salinan]
Disalin!
////////////////////////////////////////////////////////////////////////////////
// //
// Libreria C para el control of sensores temperature y Humedad: //
// //
// SHT10, SHT11, SHT15, SHT71, SHT75 //
// //
// Debe cargarse este archivo desde the cabecera del programa main con: //
// #include //
// //
// * Inicialización del sensor mediante the crucial: //
// SHTxx_init ( ); //
// //
// * Obtención of Medida of humedad y temperature mediante the crucial: //
// SHTxx (sht_temperatura, sht_humedad); //
// In las variables y sht_temperatura sht_humedad obtained several images and los Valores //
// reales temperature y humedad medidos. //
// //
// * Textbook LA ENSENANZA DE LA LECTURA Y La del valor del Registro de estado mediante the crucial: //
// SHTxx_ESCRITURA_REGISTRO_ESTADO (sht_registro); //
// sht_registro'S the operational el valor was from loading. in el registro (ships with 0) //
// bit0 = 0 => Resolución 14-bit Temperature y 12 bits Humedad //
// bit0 = 1 => Resolución 12-bit Temperature y 8 bits Humedad //
// bit1 = 0 => Dato of calibración no se carga antes cada medida //
// Bit1 = 1 => Dato of calibración se carga antes cada medida //
// bit2 = 0 => Calefactor interno OFF //
// bit2 = 1 => Calefactor interno IT //
// bit6 = 0 => Detección baja tensión Vcc > 2.47V (bit of solo lectura) //
// bit6 = 1 => Detección baja tensión Vdc < 2.47V (bit of solo lectura) //
// //
// * Obtención del valor del Registro de estado mediante the crucial: //
// SHTxx_LECTURA_REGISTRO_ESTADO (sht_registro); //
// sht_registro devolverá el valor del Registro de estado //
// //
// * Reset del software del sensor mediante the crucial: //
// SHTxx_Reset_Soft ( ); //
// (Registro de estado a sus valores por ships with) //
// //
// http://robotypic.blogspot.com/ //
// //
////////////////////////////////////////////////////////////////////////////////

/ ****************; of pines del serial bus ************************** /

#define sht_data_pin PIN_A4
#define sht_sck_pin PIN_A3

/ ** Control, also del SHT11 ** /

#define SHT11_REG_ESTADO_W 0x06 //Control, also in textbook la ensenanza de la Lectura y la registro de estado
#define SHT11_REG_ESTADO_R 0x07 //Control, also lectura de registro estado
#define SHT11_COMANDO_TEMP 0x03 //Control, also of Medida temperataur
#define SHT11_COMANDO_kel 0x05 //Control, also medida of kel
#define SHT11_SOFT_RESET 0x1E //Control, also reset of soft

/ ***** Global Variables para lectura del valor temperature y humedad ***** /

float sht_temperatur; //Guardará el valor real temperature medida
float sht_kelembaban; //Guardará el valor real de humedad medida
int8 sht_register; //Guardará el valor del register of estado

/ ****************************************************************************** /
/ **************** SEQUENCE. OF KEY OF Transmisión de Datos SA ************************** /
// _____ ________
// DATA: |_______|
// ___ ___
// SCK: ___| |___| |______

void SHT11_InicioTrans (void) {
//DATA has " 0" con SCK has " 1 "
output_float(sht_data_pin); //linea DATA has " 1"
output_low(sht_sck_pin); //linea SCK has " 0"
Delay_us(1);
output_high(sht_sck_pin); //linea SCK has " 1"
delay_us(1);
output_low(sht_data_pin); //linea DATA has " 0"
delay_us(1);
//SCK has " 0" sin replaced DATA " 0 "
output_low(sht_sck_pin); //linea SCK has " 0 "
delay_us(2);
//SCK has " 1" sin replaced DATA " 0 "
output_high(sht_sck_pin); //linea SCK has " 1"
delay_us(1);
//DATA has " 1" con SCK has " 1 "
output_float(sht_data_pin);//Linea DATA has " 1 "
delay_us(1);
output_low(sht_sck_pin); //linea SCK has "0"
}

/ ****************************************************************************** /
/ consomme SEQUENCE DOES NOT RESET technology announcements. *********************************** /
// _____________________________________________________ ________
// DATA: |_______|
// _ _ _ _ _ _ _ _ _ ___ ___
// SCK:__| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |______

void SHTxx_Reset (void) {

int i;
//key of sequence does not con SCK has " 0" y DATA has " 1 "
output_float(sht_data_pin); //linea DATA has " 1 "
output_low(sht_sck_pin); //linea SCK has " 0 "
delay_us(2);
//conmuta SCK 9 system sometimes con DATA has " 1 "
for(i= 0; i< 9; i ) {
output_high(sht_sck_pin);
delay_us(2);
output_low(sht_sck_pin);
Delay_us(2);
}
// sequence. of key of Transmisión de datos sa
SHT11_InicioTrans ();
}

/ ****************************************************************************** /
/ potrvlfault SEQUENCE. OF ENVIO COMANDO molded case /
// __ __ __ __ __ __ __ __ ___
// DATA: ___|A2 |_|A1 |_|A0 |_|C4 |_|C3 |_|C2 |_|C1 |_|C0 |_|ack|_
// __ __ __ __ __ __ __ __ ___
// SCK:___| |_| |_| |_| |_| |_| |_| |_| |_| |_

int1 SHT11_Comando (int8 sht_comando) {
int8 bit;
int8 mascara = 0x80;
int1 ack;
delay_us(4);
//Salida del comando bit
for(bit= 8; bit> = 1; bit--) {
output_low(sht_sck_pin); //linea SCK has " 0 "
//Linea DATA has " 1" if MSB es " 1 "
if((sht_comando & mascara) > 0) output_float(sht_data_pin);
//Linea DATA to " 0" if MSB es " 0 "
Else output_low(sht_data_pin);
delay_us(1);
output_high(sht_sck_pin); //linea SCK has " 1 "
delay_us(1);
mascara = mascara >> 1; //Siguiente again bit pasa a ser MSB
}
/ ** lectura del ack ** /
output_low(sht_sck_pin); //linea SCK has " 0 "
delay_us(1);
ack = input(sht_data_pin); //lectura del ack
output_high(sht_sck_pin); //linea SCK has " 1 "
delay_us(1);
output_low(sht_sck_pin);//Linea SCK has " 0 "

return(ack);
}

/ /
/ ****************************************************************************** **************** SEQUENCE. ESPERA OF MEDIDA TERMINADA ********************* /

void SHT11_Espera (void) {
int16 sht_delay;
output_float(sht_data_pin); //linea DATA has " 1 "
output_low(sht_sck_pin); //linea SCK has " 0 "
delay_us(1);
//Espera has that linea DATA pase has " 0" máximo 300msg.
for(sht_delay= 0; sht_delay< 30000; sht_delay ) {
//if linea DATA asap has " 0" => end of the medición
if ( !input(sht_data_pin)) break;
delay_us(10);
}
}

/ ****************************************************************************** /
/ Recommended Action **************** Displayed during startup as SEQUENCE. OF LECTURA DEL DATO OF MEDIDA potrvlfault /
// _ _ _ _ _ _ _ _ ___ _ _ _ _ _ _ _ _
//SCK:__| |_| |_| |_| |_| |_| |_| |_| |_|ack|_| |_| |_| |_| |_| |_| |_| |_| |__
// | | |
// |-- idle bits - |Msb --------- 12 bit Humidity Data ------------ Lsb|
// | _ _ _ _ | _ _ _ _ ___ _ _ _ _ _ _ _ _ |
//DATA:_|F|_|E|_|D|_|C|_|B|_|A|_| 9 |_| 8 |_|ack|_| 7 |_| 6 |_| 5 |_| 4 |_| 3 |_| 2 |_| 1 |_| 0 |__

int16 SHT11_Lectura (Void) {
int8 bit;
int16 sht_dato = 0;
Const int16 mascara0 = 0x0000;
const int16 mascara1 = 0x0001;
//guarda byte alto del dato missing. in byte alto of sht_dato bit
for(bit= 8; bit> = 1; bit--) {
sht_dato = sht_dato << 1; //Siguiente again bit asap has ser MSB
output_high(sht_sck_pin); //linea SCK has " 1 "
delay_us(1);
//if linea DATA es " 1" bit Pôné desired line in sht_dato has " 1 "
if (input(sht_data_pin)) sht_dato |= mascara1;
//If linea DATA es " 0" bit Pôné desired line in sht_dato has " 0 "
else sht_dato |= mascara0;
output_low(sht_sck_pin); //linea SCK has " 0 "
delay_us(1);
}

//Envio ack poniendo en linea DATA has " 0"
output_low(sht_data_pin); //linea DATA has " 0 "
delay_us(1);
output_high(sht_sck_pin); //linea SCK has " 1 "
delay_us(2);
output_low(sht_sck_pin); //linea SCK has " 0 "
delay_us(1);
Output_float(sht_data_pin); //linea DATA has " 1 "

//guarda byte Bajo del dato missing. in byte bajo sht_dato bit
for(bit= 8; bit> = 1; bit--) {
sht_dato = sht_dato << 1; //Siguiente again bit asap has ser MSB
output_high(sht_sck_pin); //linea SCK has " 1 "
Sedang diterjemahkan, harap tunggu..
 
Bahasa lainnya
Dukungan alat penerjemahan: Afrikans, Albania, Amhara, Arab, Armenia, Azerbaijan, Bahasa Indonesia, Basque, Belanda, Belarussia, Bengali, Bosnia, Bulgaria, Burma, Cebuano, Ceko, Chichewa, China, Cina Tradisional, Denmark, Deteksi bahasa, Esperanto, Estonia, Farsi, Finlandia, Frisia, Gaelig, Gaelik Skotlandia, Galisia, Georgia, Gujarati, Hausa, Hawaii, Hindi, Hmong, Ibrani, Igbo, Inggris, Islan, Italia, Jawa, Jepang, Jerman, Kannada, Katala, Kazak, Khmer, Kinyarwanda, Kirghiz, Klingon, Korea, Korsika, Kreol Haiti, Kroat, Kurdi, Laos, Latin, Latvia, Lituania, Luksemburg, Magyar, Makedonia, Malagasi, Malayalam, Malta, Maori, Marathi, Melayu, Mongol, Nepal, Norsk, Odia (Oriya), Pashto, Polandia, Portugis, Prancis, Punjabi, Rumania, Rusia, Samoa, Serb, Sesotho, Shona, Sindhi, Sinhala, Slovakia, Slovenia, Somali, Spanyol, Sunda, Swahili, Swensk, Tagalog, Tajik, Tamil, Tatar, Telugu, Thai, Turki, Turkmen, Ukraina, Urdu, Uyghur, Uzbek, Vietnam, Wales, Xhosa, Yiddi, Yoruba, Yunani, Zulu, Bahasa terjemahan.

Copyright ©2025 I Love Translation. All reserved.

E-mail: