Arduino for beginners and professional

Arduino for beginners and professional

Share

follow to learn arduino for free
Techincal projects
Automation ideas
Arduino coding
IOT devices ideas

11/02/2025

for temp and humidity
UNO r2 wifi



=========Code========




DHTPIN 2
DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x3F, 16, 2);

void setup() {
Wire.begin();
lcd.begin(16,2); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
dht.begin(); // Initialize the DHT sensor
}

void loop() {
delay(1000); // Wait a few seconds between measurements

float h = dht.readHumidity(); // Read humidity
float t = dht.readTemperature(); // Read temperature in Celsius

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
lcd.setCursor(0, 0);
lcd.print("Failed to read");
lcd.setCursor(0, 1);
lcd.print("from DHT sensor!");
return;
}

// Display the temperature and humidity on the LCD
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(t);
lcd.print(" C");

lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(h);
lcd.print(" %");
}

=====Code end======

03/02/2025

# inbuilt led control over webpage
# Arduino UNO r2 wifi


===≠========code==========
// Include the WiFiNINA library

// Replace with your network credentials
const char* ssid = "your ssid"; // Your WiFi
SSID
const char* password = "your password"; // Your WiFi password

WiFiServer server(80); // Create a server on port 80

// Pin where the LED is connected
const int ledPin = 8;

void setup() {
// Initialize serial communication
Serial.begin(9600);

// Set the LED pin as an output
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW); // Ensure LED is off initially

// Connect to Wi-Fi
Serial.print("Connecting to Wi-Fi");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("\nConnected to Wi-Fi");

// Start the server
server.begin();
Serial.println("Server started");

// Print the IP address
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}

void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (client) {
Serial.println("New client connected");

// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();

// Match the request
if (request.indexOf("GET /LED=ON") != -1) {
digitalWrite(LED_BUILTIN, HIGH); // Turn LED on
} else if (request.indexOf("GET /LED=OFF") != -1) {
digitalWrite(LED_BUILTIN, LOW); // Turn LED off
}

// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();

// HTML content for the webpage
client.println("");
client.println("");
client.println("Arduino LED Control");
client.println("");
client.println("LED Control");
client.println("Click to control the LED:");
client.println("ON");
client.println("OFF");
client.println("");
client.println("");

delay(1000); // Give the web browser time to receive the data
client.stop(); // Close the connection
Serial.println("Client disconnected");
}
}

=======Code end==========

02/02/2025

to wifi using inbuilt wifi on UNO r2
to develop wifi application
tuned for further interesting application over wifi

27/03/2023

Billing system with raspberry pi 4
Thermal printer+ barcode scanner+ gsm module
With python script

Photos from Arduino for beginners and professional's post 07/02/2023

=====esp8266 data logging to aws======
code start
=============================





"Secrets.h"


// DHT 11



float h ;
float t;
unsigned long lastMillis = 0;
unsigned long previousMillis = 0;
const long interval = 5000;

AWS_IOT_PUBLISH_TOPIC "esp8266/pub"
AWS_IOT_SUBSCRIBE_TOPIC "esp8266/sub"

WiFiClientSecure net;

BearSSL::X509List cert(cacert);
BearSSL::X509List client_crt(client_cert);
BearSSL::PrivateKey key(privkey);

PubSubClient client(net);

time_t now;
time_t nowish = 1510592825;


void NTPConnect(void)
{
Serial.print("Setting time using SNTP");
configTime(TIME_ZONE * 3600, 0 * 3600, "pool.ntp.org", "time.nist.gov");
now = time(nullptr);
while (now < nowish)
{
delay(500);
Serial.print(".");
now = time(nullptr);
}
Serial.println("done!");
struct tm timeinfo;
gmtime_r(&now, &timeinfo);
Serial.print("Current time: ");
Serial.print(asctime(&timeinfo));
}


void messageReceived(char *topic, byte *payload, unsigned int length)
{
Serial.print("Received [");
Serial.print(topic);
Serial.print("]: ");
for (int i = 0; i < length; i++)
{
Serial.print((char)payload[i]);
}
Serial.println();
}


void connectAWS()
{
delay(3000);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

Serial.println(String("Attempting to connect to SSID: ") + String(WIFI_SSID));

while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(1000);
}

NTPConnect();

net.setTrustAnchors(&cert);
net.setClientRSACert(&client_crt, &key);

client.setServer(MQTT_HOST, 8883);
client.setCallback(messageReceived);


Serial.println("Connecting to AWS IOT");

while (!client.connect(THINGNAME))
{
Serial.print(".");
delay(1000);
}

if (!client.connected()) {
Serial.println("AWS IoT Timeout!");
return;
}
// Subscribe to a topic
client.subscribe(AWS_IOT_SUBSCRIBE_TOPIC);

Serial.println("AWS IoT Connected!");
}


void publishMessage()
{
StaticJsonDocument doc;
doc["time"] = millis();
doc["humidity"] = h;
doc["temperature"] = t;
char jsonBuffer[512];
serializeJson(doc, jsonBuffer); // print to client

client.publish(AWS_IOT_PUBLISH_TOPIC, jsonBuffer);
}


void setup()
{
Serial.begin(115200);
connectAWS();

}


void loop()
{
h = 24;
t = 27;

if (isnan(h) || isnan(t) ) // Check if any reads failed and exit early (to try again).
{
Serial.println(F("Failed to read from DHT sensor!"));
return;
}

Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.println(F("°C "));
delay(2000);

now = time(nullptr);

if (!client.connected())
{
connectAWS();
}
else
{
client.loop();
if (millis() - lastMillis > 5000)
{
lastMillis = millis();
publishMessage();
}
}
}

===================code end.

Photos from Arduino for beginners and professional's post 18/06/2022

Home automation using nodmcu and blynk
Handle with care(AC supply included)
==================================
========
Video link:-https://youtu.be/jisDJ8uOVrE

=========
BLYNK_PRINT Serial


char auth[] = "zzzzzzzzz";//copy authentication code from mail
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = " ";//Wifi user name
char pass[] = " ";//Wifi password
void setup()
{
// Debug console
Serial.begin(9600);
digitalWrite(D1 , HIGH);
digitalWrite(D2 , HIGH);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
}
====================================
www.samojconsultancyservices.com

Want your school to be the top-listed School/college in Panvel?
Click here to claim your Sponsored Listing.

Category

Telephone

Address


Panvel Matheran Road
Panvel
410206