【TB作品】MSP430G2553单片机,MSP430 单片机读取 SHT30 传感器并显示数据

int main(void) { unsigned char dis[10]; WDTCTL = WDTPW + WDTHOLD; if (CALBC1_1MHZ == 0xFF) { while (1); } DCOCTL = 0; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; OLED_Init(); OLED_ShowString(0, 0, "SHT30:"); IIC_Init(); delay_ms(50); while (1) { IIC_Start(); IIC_Send_Byte(SHT30W); while (IIC_Wait_Ack()); IIC_Send_Byte(0x22); while (IIC_Wait_Ack()); IIC_Send_Byte(0x20); while (IIC_Wait_Ack()); delay_ms(2); IIC_Start(); IIC_Send_Byte(SHT30W); while (IIC_Wait_Ack()); IIC_Send_Byte(0xe0); while (IIC_Wait_Ack()); IIC_Send_Byte(0x00); while (IIC_Wait_Ack()); temp = (BUFt[0] << 8) | BUFt[1]; humi = (BUFt[3] << 8) | BUFt[4]; temp = (u16) (175 * (float) temp / 65535 - 45); humi = (u16) (100 * (float) humi / 65535); delay_ms(10); dis[0] = temp % 100 / 10 + '0'; dis[1] = temp % 10 + '0'; dis[2] = 'C'; dis[3] = 0; OLED_ShowString(0, 2, dis); dis[0] = humi % 100 / 10 + '0'; dis[1] = humi % 10 + '0'; dis[2] = '%'; dis[3] = 0; OLED_ShowString(0, 4, dis); delay_ms(200); } }
上一篇:手撕设计模式——克隆对象之原型模式


下一篇:C# WPF入门学习主线篇(七)—— Label常见属性和事件