Giter VIP home page Giter VIP logo

stm32-am2320's Introduction

AM2320

STM32 library for temperature and humidity sensor AM2320 using HAL and i2c.

Screenshot from logic analyzers

For using printf with float should be add flag -u _printf_float in C compiler

enter image description here

Pin setting:

| PERIPHERALS | MODES                 | FUNCTIONS      | PINS              |
|-------------|-----------------------|----------------|-------------------|
| I2C1        | I2C                   | I2C1_SCL       | PB8               |
| I2C1        | I2C                   | I2C1_SDA       | PB9               |
| SYS         | Trace Asynchronous Sw | SYS_JTMS-SWDIO | PA13              |
| SYS         | Trace Asynchronous Sw | SYS_JTCK-SWCLK | PA14              |
| SYS         | Trace Asynchronous Sw | SYS_JTDO-SWO   | PB3               |
| SYS         | SysTick               | SYS_VS_Systick | VP_SYS_VS_Systick |
| USART2      | Asynchronous          | USART2_RX      | PA3               |
| USART2      | Asynchronous          | USART2_TX      | PA2               |

Example:

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "am2320.h"
/* USER CODE END Includes */

/* USER CODE BEGIN 2 */
Am2320_HandleTypeDef Am2320_;
Am2320_ = am2320_Init(&hi2c1, AM2320_ADDRESS);
float temperature, humidity;
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
  am2320_GetTemperatureAndHumidity(&Am2320_, &temperature, &humidity);
  my_printf("=====================================\r\n");
  my_printf("Temperature: %.1fºC\r\n", temperature);
  my_printf("Humidity: %.1f%%\r\n", humidity);
  HAL_Delay(3000);
  /* USER CODE END WHILE */
  /* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */

stm32-am2320's People

Contributors

simplemethod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.