Connect LM35 analog temperature sensor to Arduino

The LM35 is an inexpensive, precision Centigrade temperature sensor made by Texas Instruments. It provides an output voltage that is linearly proportional to the Centigrade temperature and is, therefore, very easy to use with the Arduino.

The sensor does not require any external calibration or trimming to provide accuracies of ±0.5°C at room temperature and ±1°C over the −50°C to +155°C temperature range.

One of the downsides of the sensor is that it requires a negative bias voltage to read negative temperatures. So if that is needed for your project, I recommend using the DS18B20 or TMP36 instead. The TMP36 by Analog Devices is very similar to the LM35 and can read temperatures from -40°C to 125°C without any external components.

The pinout of the sensor:

Note that pin 1 (+VS) is the leftmost pin when the flat side of the sensor (with the text printed on it) is facing towards you.

Pin1: +VS  - Positive power supply pin (4 – 30 V)
Pin2: Vout - Temperature sensor analog output
Pin3: GND  - Device ground pin

Source code of Arduino sketch:

#define sensorPin A0

void setup() {
  // Begin serial communication at a baud rate of 9600:
  Serial.begin(9600);

  // Set the reference voltage to the built-in 1.1V reference:
  analogReference(INTERNAL);
}
void loop() {
  // Get a reading from the temperature sensor:
  int reading = analogRead(sensorPin);

  // Convert the reading into voltage:
  float voltage = reading * (1100 / 1024.0);

  // Convert the voltage into the temperature in degree Celsius:
  float temperature = voltage / 10;

  // Print the temperature in the Serial Monitor:
  Serial.print(temperature);
  Serial.print(" \xC2\xB0"); // shows degree symbol
  Serial.println("C");
  delay(1000); // wait a second between readings
}

How to install Composer on Linux server

Composer is a most popular PHP package manager, let’s install composer on website and watch how it works.

You can download Composer from official site: https://getcomposer.org/

Connect to your server via SSH client and run this commands:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

Connect DS3231 real time clock to Arduino NANO

DS1302, DS1307, DS3231 is a real-time modules for Arduino and Raspberry PI. Let’s connect DS3231 to our Arduino NANO.

To work with this module we will use universal library: iarduino_RTC (https://github.com/tremaru/iarduino_RTC).

Download latest version of this library you can here: https://github.com/tremaru/iarduino_RTC/archive/refs/tags/1.3.4.zip

First of all connect DS3231 module to Arduino:

GND (-) --> GND
VCC (+) --> +5V
SDA (D) --> A4
SCL (C) --> A5

Include library and initialize module:

#include <iarduino_RTC.h>
iarduino_RTC time(RTC_DS1307);

To set current time in DS3231 module tuesday write next functions in function setup():

void setup() {
    Serial.begin(9600);
    time.begin();
    time.settime(0,20,17,30,3,21,2);  
    // 0  sec, 20 min, 17 hour, 30 day, 3 mon, 2021 year, tuesday
}

In function loop() let’s write to serial port current time:

void loop(){
    if(millis() % 1000 == 0) {
        Serial.println(time.gettime("d-m-Y, H:i:s, D"));
        delay(1);
    }
}

This sketch you need to run once time, when configure DS3231 module.

If you want just to show current time – use this source code:

#include 
iarduino_RTC time(RTC_DS1307);

void setup() {
    Serial.begin(9600);
}
void loop() {
    if(millis() % 1000 == 0) {
        Serial.println(time.gettime("d-m-Y, H:i:s, D"));
        delay(1);
    }
}

Connect I2C LCD 16×2 Display to Arduino Nano

In this Instructable you are going to see how to connect i2c lcd display to arduino and how to print on lcd display.

Each I2C bus consists of two signals: SCL and SDA. SCL is the clock signal, and SDA is the data signal. The clock signal is always generated by the current bus master; some slave devices may force the clock low at times to delay the master sending more data (or to require more time to prepare data before the master attempts to clock it out). This is called “clock stretching” and is described on the protocol page.

To connect 16×2 LCD display to Arduino we use i2c PCF 8574T module. This module expands Arduino pins and allow connection of display using only two Arduino pins.

I2C module has four pins: GND – ground, VCC – 5V power, SDA – data signal, SCL – clock signal. Connect SDA to A4 pin on Arduino, and SCL to A5 pin:

GND <---> GND
VCC <---> 5V
SDA <---> A4
SCL <---> A5

For working with display on Arduino we need two libraries: Wire.h, LiquidCrystal_I2C.h.

Wire.h is standard Arduino IDE library, and LiquidCrystal_I2C.h is the library for work with LCD displays. You can download it from official Arduino project website: https://www.arduino.cc/reference/en/libraries/liquidcrystal-i2c/

And here is the source code of simple sketch, which write text on 16×2 LCD display:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

void setup() 
{
  lcd.init();
  lcd.backlight();

  lcd.setCursor(0,0); // set cursor to 1 symbol of 1 line
  lcd.print("Arduino Lessons:");

  lcd.setCursor(0,1); // set cursor to 1 symbol of 2 line
  lcd.print("www.andjey.info"); 
}

void loop() 
{  

}

Arduino – simple blink program

Let’s write simple program, that will turn on and off LED on our Arduino. For our lesson we need: Arduino, one LED diode, USB cable for programming our Arduino, PC with Arduino IDE, download it you can here: https://www.arduino.cc/en/software

Connect USB cable to Arduino, for connecting LED we will use D13 pin and GND PIN (see Arduino Nano pins here). Positive wire of diode connect to D13, negative wire – to Ground pin as you can see on photo:

In Arduino IDE create new blank project:

Here You can see two functions: setup() – which run when Arduion power on, and function loop() – which run in cycle all type when arduino is working. Now let’s create our program.

Bewore function start() let’s create two constants – it will be basic configuration of our program. BLINK_PIN defines which pin is used for connecting LED. BLINK_TIME – define time in milliseconds how long our LED will be on and off.

#define BLINK_PIN 13
#define BLINK_TIME 1000

In function setup() configure pin 13 as output pin:

void setup() {
  pinMode(BLINK_PIN,1);
}

Now create function blink_led() – that will turn on and off our LED:

void blink_led()
{
  digitalWrite(BLINK_PIN, 1);
  delay(BLINK_TIME);
  
  digitalWrite(BLINK_PIN, 0);
  delay(BLINK_TIME);
}

Now write function blink_led() in loop() to run our program in cycle all time when Arduino works:

void loop() {
  blink_led();
}

Full code of program:

#define BLINK_PIN 13
#define BLINK_TIME 300

void blink_led()
{
  digitalWrite(BLINK_PIN, 1);
  delay(BLINK_TIME);
  
  digitalWrite(BLINK_PIN, 0);
  delay(BLINK_TIME);
}

void setup() {
  pinMode(BLINK_PIN,1);
}

void loop() {
  blink_led();
}

Now save program and compile it to your Arduino:

Arduino Nano pinout

Arduino has 14 digital PIN for digital devices and 8 analog PIN for analog devices. Here is detail information about all Arduino Nano pins:

Visual Studio Code first config

Visual Studio Code is a very powerful free and open source text editor, but before start usage it you need to but to use all its features, you need to configure it.

Visual Studio Code

First of all disable telemetry collection in File > Preferences > Settings menu:

Override “Alt” button to toggle menu bar:

"window.titleBarStyle": "custom",
"window.customMenuBarAltFocus": false

Disable file previewing when clicked on at all is by setting:

"workbench.editor.enablePreview": false

Functionality of Visual Studio Code can be extended with plugins and extensions.

I prefer to install such basic plugins: Project Manager, Ftp-sync, Show Functions, Beautify, and Material Icon Theme, Atom Material Theme:

This is my basic configuration of Visual Studio Code, you can also change other options and config this amazing text editor as you want.

How to change MySQL root password in Debian / Ubuntu

Connect to MySQL Server using Linux terminal:

sudo mysql --user=root mysql

Run the following commands:

UPDATE mysql.user SET authentication_string=null WHERE User='root';
flush privileges;

Replace NEW_PASSWORD with your own.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEW_PASSWORD';
flush privileges;
exit;

How to Flush the DNS Cache on Debian 10

To flush DNS cache in Debian GNU/Linux use command:

sudo systemd-resolve --flush-caches

If you get error message: “Failed to flush caches: Unit dbus-org.freedesktop.resolve1.service not found.“, enable the service on your system:

sudo systemctl enable systemd-resolved.service

Then again run the “systemd-resolve –flush-caches” command.

You can then check the statistics in order to make sure that your cache size is now zero, thus cleared. Run the following command in order to view the statistics:

sudo systemd-resolve --statistics

Configure certificate in HestiaCP

1. Backup current certificates in directory /usr/local/hestia/ssl/:

mv /usr/local/hestia/ssl/certificate.crt /usr/local/hestia/ssl/certificate.crt.old 

mv /usr/local/hestia/ssl/certificate.key /usr/local/hestia/ssl/certificate.key.old 

2. In directory /usr/local/vesta/ssl/ make symbol links to certificates, that we use on our site (for example: site.com):

ln -s /home/admin/conf/web/site.com/ssl/site.com.crt /usr/local/hestia/ssl/certificate.crt 

ln -s /home/admin/conf/web/site.com/ssl/site.com.key /usr/local/hestia/ssl/certificate.key 

3. Restart Hestia service:

service hestia restart