Home > other >  Seven lines of code to achieve a temperature and humidity meter (Oled display)
Seven lines of code to achieve a temperature and humidity meter (Oled display)

Time:11-17

one, foreword

Shineblink core development board (hereinafter referred to as the core of library function support SHT30 temperature and humidity sensors, so only need to call the two apis, temperature and humidity measurement functions can be realized,

PS: the Core with only five, six lines of code can be realized Wifi/Ble/NB/Lora/ThreadMesh/RFID/Eth/Usb/RS485/RS232 communication, and more than 30 sensors/more than 10 kinds of hardware peripherals/more than 10 kinds of Mcu internal functions, and these functions can be up to five kinds of random combination running at the same time,



2, production materials

1. Shineblink core development board a

2. Sht30 temperature and humidity sensor module a

3. 0.96 inch oled display a

4. TYPE00-0000003 - f circuit board, the circuit principle diagram and PCB source file, please download (AD engineering) in the network location address below:

https://yunpan.360.cn/surl_yP9fgP7LVGa





three, complete code

 LIB_Sht3xConfig (" IIC0 ", "10", "HIGH") 
LIB_0_96_OledConfig (" IIC1 ")


- began circulationWhile (GC (1)==true)
Do
- delay 1000 milliseconds
LIB_DelayMs (1000)

- query whether sht3x sensor which
Sht3x_flag sht3x_temp, sht3x_humi=LIB_Sht3xGetResult ()
- if the sensor data have an
If sht3x_flag==1 then
- in the second and third lines of the oled screen display temperature and humidity respectively
LIB_0_96_OledPuts (" 2 ", "1", the string. Format (" temprature: % 2 f, "sht3x_temp))
LIB_0_96_OledPuts (" 3 ", "1", the string. Format (" humidity: % 2 f, "sht3x_humi))
End
End





4, the production process & amp; The results show

Core development way is very elegant, with a notepad (or any other editor) open the Core development board of TF card. The main lua files, and then copy the code above to the main. The lua files can, because the Core built-in lua compiler, so without you having to do any processing, the Core can start work in accordance with the above code,

Below for after completion of assembly welding code running effect:





# # 5, conclusion

The above code for every 1 second update shows a temperature and humidity sensor output value, more technical information about the Core, can visit shineblink.com to get to know,

  • Related