AM2303 and LCD Keypad shield example

In this example we take our Nucleo and AM2303 sensor example and we add an LCD Keypad shield and display the temperature and humidity on this. Here is  a picture of that shield

lcd keypad shield
lcd keypad shield

You will need to add the freetronics LCD shield library


[codesyntax lang=”cpp”]

#include "mbed.h"
#include "AM2303.h"
#include "freetronicsLCDShield.h"

freetronicsLCDShield lcd(D8, D9, D4, D5, D6, D7, D1, A0);
/* Humidity sensor */
AM2303 h(D12);
/* The main function */
int main()
    /* Variables */
    lcd.printf("AM2303 Humidity");
    lcd.setCursorPosition(1, 0);
    int state;
    /* Infinate loop */
        /* Wait for measurement */
        /* Read the measured results */
        state = h.readData();
        lcd.setCursorPosition(1, 0);
        /* Show the data, otherwise error */
        if (state != AM2303::OK) 
            lcd.printf("<Error: %d>\n", state);
            lcd.printf("T:%2.1fC, H:%2.1f%%\n", h.readTemperature(), h.readHumidity());





DHT22 AM2302 Digital Temperature Humidity Sensor Chip Electronic Brick

1602 LCD Board Keypad Shield Blue Backlight

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :