Electronic designer Arduino is very popular among talented teenagers and inquisitive adults. Today we will analyze how to use it to turn an ordinary LCD into a weather station.
How to set up the LCD
If you want to control an LCD with an Arduino, you will need, in addition to the kit and monitor, a connection cable, a potentiometer, and a Breadboard. However, on the Internet you will find many practical and affordable Arduino kits that already have all these components.
- First, connect all the components — as shown in the picture — to the Arduino and start the Arduino IDE.
- First, you must add the #include command (without the quotes) to the code to import the LiquidCrystal library.
- Then you will need to define the LCD with the command “LiquidCrystal lcd (7, 8, 9, 10, 11, 12)”;. If necessary, you will need to adjust the contacts used in the command.
- You have to start your LCD in void setup(). This can be done, for example, using the command “lcd.begin (16, 2);”.
- Now you can test the LCD. Using the command “lcd.print(“Hello, World!”);” the words “Hello, World!” — as in this example — will be shown on the display. Using the command “lcd.setCursor (0, 1)”; you can change the cursor. Note, however, that the computer always starts counting from 0. With the “lcd.clear();” command. You can delete all recorded data on the LCD.
Arduino: how to make a thermometer
- After you have worked with your LCD, you can make a small thermometer yourself. For this you will also need an NTC and a 10 kΩ resistor.
- Connect all components as shown in the figure.
- Now you need to insert the command “int tempPin = 0;” at the very beginning of your code so that the Arduino knows which (analog) pin you connected the NTC to.
- Then add to the void loop() the command “int tempReading = analogRead(tempPin);”, and then the command “double tempK = log(10000.0 * ((1024.0 / tempReading — 1)));”, and also the command “tempK = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * tempK * tempK )) * tempK );” without quotes. Under the variable “tempK” the temperature in Kelvin has been set and stored.
- You can change this with the command “float tempC = tempK — 273.15;” and easily convert units to Celsius.
- Now add (still in the void loop) the command “lcd.setCursor(0, 0);” to place the cursor at the beginning. After that, you need the “lcd.print(tempC)” command; to show the temperature on the display. Since the cursor will now always be placed at the beginning, you will not need to additionally insert the lcd.clear() command.
Photo: manufacturing companies
- Mini-PC Raspberry Pi 3 Model B + can become the center of the “smart” home
- Xiaomi launches E Ink weather station for just $9