6 years, 5 months ago.

AM2320 can't work with nucleo-l476rg i2c

use AM2320 or AM2321 lib + nucleo-l476rg ,can't read temp ,can anyone share sample code ,tks

https://os.mbed.com/components/AM2321/

1 Answer

6 years, 5 months ago.

What do you mean 'can't read temp'? Do you get compilation errors? Do you get inaccurate readings? The example program should work fine on the L476RG as long as you point to the right pins.

there is no build error, but there is no data com port form terminal; and the printf can work fine;means am2321.poll() function fail;

  1. include "mbed.h"
  2. include "AM2321.h" /* nucleo_L476RG I2C_SCL = PB_8 I2C_SDA = PB_9
  • / Serial pc(USBTX, USBRX); Tx, Rx AM2321 am2321(I2C_SDA, I2C_SCL); SDA, SCL DigitalOut led1(LED1);

int main() { uint16_t count = 0; pc.printf("hello am3220"); while(1) { led1 = !led1;

if(am2321.poll()) { pc.printf( ":%05u,%.1f,%.1f\n" , count++ , am2321.getTemperature() , am2321.getHumidity() ); }

wait(0.5); }

posted by z z 13 Jan 2018