How do i combine nodemcu ESP8266 with arduino uno and blynk?

hello i am new to this. i would want to know how to connect the nodemcu ESP8266 with arduino uno and use Blynk app via WiFi for an IOT project.

i have used LM35 as temperature sensor to collect data. i have connected LM35 with LCD display, buzzer, led and 1k ohm resistor with arduino uno and i have no problem with the connections.

so how do i add in the nodemcu with the code and arduino connection?

below is my code:

#include<LiquidCrystal.h> //Header file for LCD Module
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //lcd connected pins
const int sensor = A0; //Assigning analog A0 to variable sensor
float tempC; //variable to store temp in °C
float vout; //variable to store values from sensor
void setup()
{
pinMode(sensor,INPUT); // Configuring A0 as input
lcd.begin(16,2);
pinMode(A0,INPUT);
pinMode(6,OUTPUT); //For buzzer
pinMode(9,OUTPUT); //For LED
Serial.begin(9600);
}
void loop()
{
vout=analogRead(sensor);
vout=(vout*500)/1023;
tempC=vout; // Storing value in °C
lcd.setCursor(0,0);
Serial.println(tempC);
if(tempC>=22) //For easiness I have taken 32°C as alert temperature
{
lcd.print("HIGH TEMP!! ");
lcd.setCursor(0,1);
lcd.print("C=");
lcd.print(tempC);
beep(200); //beeps for 200ms
}
else
{
lcd.print("Temp is Normal.");
lcd.setCursor(0,1);
lcd.print("C=");
lcd.print(tempC);
digitalWrite(9,0);
}
delay(1000);
}
void beep(unsigned char delayms){
analogWrite(6, 20); // Any value can be used except 0 & 255
digitalWrite(9,1);
delay(delayms); // wait for a delayms ms
analogWrite(6, 0); // 0 turns it off
digitalWrite(9,0);
delay(delayms); // wait for a delayms ms
}

Why? It is simpler only with ESP8266. Why do you need an Arduino Uno? ESP8266 has fewer pins but is a much faster microcontroller with much more memory. You can replace the display with SSD1306, which uses only 2 pins for control. I think it will be easier to program.

i see, i am not sure on how to connect the esp8266 pins with the components. as for now, i dont have the ssd1306 display. i am currently using the nds1602a. is it possible to tell me how?

The 1602 display you are using can be connected to an Arduino or ESP8266 via an I2C board such as PCF8574. If you have a PCF8574 board or if you can buy them (they are cheap) you will only need 2 pins from the microcontroller to control the display.

ESP8266
https://laptrinhx.com/how-to-interface-pcf8574-i2c-lcd-with-esp8266-nodemcu-936725032/

Arduino Uno

This will leave you with a lot more free pins for other purposes.

1 Like