Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 11 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, 11 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;
- include "mbed.h"
- 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 13 Jan 2018