top of page

Search Results

163 results found with an empty search

  • Bluetooth Controlled Water Level Controller

    Water is one of the essential need for the survival of all human beings, animals and plants. The water overflow from the overhead tanks in the houses, commercial properties, educational institutions the percentage of water overflow wastage. To avoid such Spillage implementation of an automatic water level controller becomes a key factor which further reduces human intervention. In this Project work, an automatic water level controller using bluetooth wireless technology and Ultrasonic water level sensor is proposed. This project can be further enhanced to control and animated the water level as follows. Soft Slider - Automatic ON/OFF Pump The water Pump automatic turning it ON, when the water level is reached LOW level set point, and water Pump automatic turning it OFF when the water level reached is HIGH level set point. The Low & High set point to be adjusted from 0 % to 100 % using slider from android app and value send to arduino and stored in Arduino EEPROM by pressing SET button in the android application. Pushbutton- Tank height Set A push button switch is provided for tank height set and value stored in Arduino EEPROM. If tank is empty then press to push button switch for tank height set in cm and value send to arduino and stored in EEPROM. Gauge Display (Android) The Cylindrical gauge display for water level percentage indication from 0 % to 100%. Bar Graph Display (Android) The Bar Graph LED display for water level percentage indication from 10 % to 100% by step 10. Progress Monitor (Android) The Progress Monitor display for water level percentage indication from 0 % to 100%. Motor Indication (Android) Pump Motor ON/OFF indicator for further animated display. 7 segment LED display (Android) The final Arduino result is send to android application and displayed. Thus, the Arduino water level indicator helps in preventing wastage of water in overhead tank. This project is wireless so, it is easy to install and it can work up to 400cm for HC-SR04 ultrasonic sensor. Circuit diagram Components required Arduino Nano - 1 no Bluetooth module HC-05 - 1no HC-SR04 ultrasonic sensor-1no 1-Channel 5V Relay Module - 1no HC-SR04 ultrasonic sensor The Ultrasonic sensor has four terminals - +5V, Trigger, Echo, and GND connected as follows − Connect the +5V pin to Vin Pin of Arduino Nano board. Connect Trigger to digital pin D12 of Arduino Nano board. Connect Echo to digital pin D13 of Arduino Nano board. Connect GND with GND on Arduino Nano. Datasheet Download Bluetooth HC-05 Module HC-05 is a Bluetooth module which is designed for wireless communication. This module can be used in a master or slave configuration. Bluetooth serial modules allow all serial enabled devices to communicate with each other using Bluetooth. It has 6 pins, Key/EN- NC VCC to Connect 5 V power GND to power Ground TXD to Arduino Nano Rx (D0) RXD to Arduino Nano Tx (D1) State- NC HC-05 module Information HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds. This module works on 3.3 V. We can connect 5V supply voltage as well since the module has on board 5 to 3.3 V regulator. As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit voltage level from microcontroller to RX of HC-05 module. HC-05 Default Settings Default Bluetooth Name: “HC-05” Default Password: 1234 or 0000 Download Datasheet Installing the Arduino Library Download Ultrasonic library , we need to use this library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Download Android application. Android application First open Mobile application and select Bluetooth image button, after that select Bluetooth HC-05 device to connect and enter Password as mentioned above (0000 or 1234). Subscribe and Download code. Arduino Code #include Ultrasonic ultrasonic(12, 13); #include #define relay 7 #define buttonPin 10 int buttonState = 0; char Character; String Text; String TankHigh; String TankLow; String water; int CutOff; int heightset; int TankHeight; //long distance; int distance; float percentage,math; int LowCutoff; int HighCutoff; int Lowlevel; int Highlevel; void setup () { Serial.begin(9600); // We initialize serial connection so that we could print values from sensor. pinMode(buttonPin,INPUT); pinMode(relay,OUTPUT); Serial.setTimeout(200); } void loop () { distance = ultrasonic.read(); ////////////////// if(Serial.available()) { Character = Serial.read(); Text = Text + Character; if (Character == '*') { Text = Text.substring(0, Text.length() - 1); // Delete last char * CutOff = Text.indexOf(','); TankLow = Text.substring(0, CutOff); TankHigh = Text.substring(CutOff+1, -1); Text = ""; LowCutoff = (TankLow.toInt()); EEPROM.update(2,LowCutoff); {LowCutoff= EEPROM.read(2); } HighCutoff = (TankHigh.toInt()); EEPROM.update(4,HighCutoff); {HighCutoff= EEPROM.read(4); } delay(200); } } ///////////////////////////////////// buttonState = digitalRead(buttonPin); if (buttonState == LOW) // +RESISTOR, GND-BUTTON { TankHeight =distance; EEPROM.update(0,TankHeight); } {TankHeight= EEPROM.read(0); } delay(200); heightset= EEPROM.read(0); Lowlevel= EEPROM.read(2); Highlevel= EEPROM.read(4); math = heightset-distance; percentage = (math/heightset)*100; if ((percentage >= 0) && (percentage <= 100)) if (percentage <= Lowlevel) { digitalWrite(relay, HIGH); } if (percentage >= Highlevel) { digitalWrite(relay, LOW); } Serial.print(distance); Serial.print("|"); Serial.print(percentage); Serial.print("|"); Serial.print(Lowlevel); Serial.print("|"); Serial.print(Highlevel); Serial.print("|"); Serial.print(TankHeight); Serial.print("|"); Serial.print(digitalRead(relay)); Serial.print("\n"); delay(1000); }

  • Car Reverse Parking using Ultrasonic Sensor

    In this project Arduino Based Parking System using Ultrasonic Sensor and Android application via Blue tooth HC-05. Totally 8 sensor to used for finding parking slot and detecting/sensing object in front and back side of the car. In this project demo Purpose we are used single Ultrasonic sensor used for explanation. and additionally interface with android application and Bluetooth connectivity. Demo: For Programmed ardunio Uno & Price: https://www.dofbot.com/product-page/car-reverse-parking-using-ultrasonic-sensor-bluetooth-android-app Components Required 1 × Breadboard 1 × Arduino Uno R3 1 × ULTRASONIC Sensor (HC-SR04) 1 x Bluetooth module HC-05 1X 16x2 LCD display with I2c module 1 x Buzzer 1x LED for PWM (BREAKING CONTROL) Android mobile for Mobile display Circuit Diagram: Explanation: The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of an object just like the bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package from 2 cm to 400 cm or 1” to 13 feet. Features Here’s a list of some of the HC-SR04 ultrasonic sensor features and specs: Power Supply :+5V DC Quiescent Current : <2mA Working Current: 15mA Effectual Angle: <15° Ranging Distance : 2cm – 400 cm/1″ – 13ft Resolution : 0.3 cm Measuring Angle: 30 degree Trigger Input Pulse width: 10uS Dimension: 45mm x 20mm x 15mm How It Works – Ultrasonic Sensor Pins VCC: +5VDC Trig : Trigger (INPUT) Echo: Echo (OUTPUT) GND: GND It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance. Example for 4 ultrasonic Sensor for front and 4 ultrasonic sensor for back point, Example for Parallel Parking. Example for angle Parking. The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board. In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled. For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2. speed of sound: v=340m/s v=0.034cm/µs Time=distance/speed t=s/v; therefore 10/0.034/2=294µs Distance: s=t*0.034./2 In this the ultrasonic sensor reads and writes the distance to an object in the serial monitor. In the setup you have to define the triggerPin as an output and the echoPin as an Input and also start the serial communication for showing the results on the serial monitor. The trigger pin is connected to digital pin 8, and the echo pins is connected to digital pin 9. You also create three variables of type long: duration, cm. The duration variable saves the time between the emission and reception of the signal. The cm variable will save the distance in centimeters, and the inch variable will save the distance in inches. long duration, cm, inches; In the setup(), initialize the serial port at a baud rate of 9600, and set the trigger pin as an output and the echo pin as an input. //Serial Port begin Serial.begin (9600);//Define inputs and outputs pinMode(triggerPin, OUTPUT); pinMode(echoPin, INPUT); In the loop(), trigger the sensor by sending a HIGH pulse of 10 microseconds. But, before that, give a short LOW pulse to ensure you’ll get a clean HIGH pulse. First you have to make sure that the triggerPin is clear so you have to set that pin on a LOW State for just 2 µs. Now for generating the Ultra sound wave we have to set the triggerPin on HIGH State for 10 µs. Using the pulseIn() function you have to read the travel time and put that value into the variable “duration”. This function has 2 parameters, the first one is the name of the echo pin and for the second one you can write either HIGH or LOW. digitalWrite(triggerPin, LOW); delayMicroseconds(2); digitalWrite(triggerPin, HIGH); delayMicroseconds(10); digitalWrite(triggerPin, LOW); Then, you can read the signal from the sensor – a HIGH pulse whose duration is the time in microseconds from the sending of the signal to the reception of its echo to an object. duration = pulseIn(echoPin, HIGH); Finally, you just need to convert the duration to a distance. We can calculate the distance by using the following formula: example: distance = (traveltime/2) x speed of sound distance= duration*0.034/2; At the end we will print the value of the distance on the Serial Monitor. For LED brightness control (PWM ), and connected in Pin 6. Future development: This pin used for the Breaking control system for electrical vehicle, If the Front mud guard sensor sense the range upto 4 to 5 meter and Produce PWM signal respectively depends on Front obstacle or front Car distance. This PWM signal is feed to Breaking control signal to avoid Accident or feed to Speed Control to Keep distance. long x; In Loop x=(duration/2)/29.1; x=map(x,0,100,255,0); if(x<255 && x>10) //code stability condition { analogWrite(6,x); } else if (x<10) { analogWrite(6,0); } else { analogWrite(6,0); } Code for Buzzer alarm for object in near by, and Buzzer connected in Pin 7. int Buzzer = 7; In loop if (distance <= 33 && distance >= 0) { // Buzzer start sound when Object near by below 33cm. digitalWrite(Buzzer, HIGH); } else { // Don't buzz digitalWrite(Buzzer, LOW); // // Buzzer stop sound when Object away to 34cm. } // Waiting 60 ms won't hurt any one delay(60); First, pin your LCD with I2C board on the breadboard and power the breadboard by connecting a wire from "5V" (Positive) on your Arduino to the positive row on the breadboard and another one from "GND" (ground or 0V) to the negative row. Then connect the LCD to the I2C module and I2C to Arduino: I2C SCL pin 4 - Arduino pin A5 I2C SDA pin 3 - Arduino pin A4 I2C GND pin 2 – 0V I2C VCC pin 1 – 5V Then connect the Tx(Transmit) pin on your Bluetooth module to the Rx (Receive) on the Arduino, and connect the Rx pin on your BT module to the Tx on the Arduino. Finally, power the BT module by connecting the VCC (or 5V) to the positive row on the breadboard and connect the GND to the negative one on the breadboard. Trouble shooting of Bluetooth issue: Turn on the Bluetooth in your device. Search for new device. Click on Hc05 once it appear. Enter the password "1234" or "0000". Code for LCD 16x2 interface: In Loop: lcd.setCursor(0,1); // Sets the location at which subsequent text written to the LCD will be displayed //lcd.print("Distance: "); // Prints string "Distance" on the LCD lcd.print(distance); // Prints the distance value from the sensor lcd.print(" cm "); ANDROID APPLICATION The Android app developers generally use JAVA language, but this Android app can also build without knowing the Java language. This app inventor is specially designed for Block programmers those who don’t know the JAVA language. Main Screen: Block for Read data: Block for Blueooth Connect and disconnect Android output here below: App front screen: Output for Object is 1cm to 50cm. Output for Object is abobe 51cm Subscribe and Download code. Pay and get Arduino code: Demo: Android app: https://drive.google.com/file/d/1VejZuFdf4gDLgAibmrERzBRLuqi2mVPD/view?usp=sharing

  • Angle Measure using MPU 6050 3-Axis Accelerometer and Gyroscope Sensor

    In this tutorial, Measuring the angle (Object Position) using MPU6050 sensor, Bluetooth HC-05 device for wireless monitor using android application.The MPU6050 sensor module has a built-in gyroscope and an accelerometer sensor. The gyroscope is used to determine the orientation and the accelerometer provides information about the angle, such as X, Y, and Z-axis data. These information send through serial port connected with bluetooth device and send to android mobile application. The android application provide corresponding X,Y,Z values in circular bar format on screen. Circuit diagram Components Required MPU6050 Accelerometer - 1 no Arduino Nano - 1 no Bluetooth module HC-05 - 1no Bluetooth HC-05 Module HC-05 is a Bluetooth module which is designed for wireless communication. This module can be used in a master or slave configuration. Bluetooth serial modules allow all serial enabled devices to communicate with each other using Bluetooth. It has 6 pins, Key/EN- NC VCC to Connect 5 V power GND to power Ground TXD to Arduino Nano Rx (D0) RXD to Arduino Nano Tx (D1) State- NC HC-05 module Information HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds. This module works on 3.3 V. We can connect 5V supply voltage as well since the module has on board 5 to 3.3 V regulator. As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit voltage level from microcontroller to RX of HC-05 module. HC-05 Default Settings Default Bluetooth Name: “HC-05” Default Password: 1234 or 0000 Download Datasheet MPU6050 Sensor The MPU6050 devices combine a 3-axis gyroscope and a 3-axis accelerometer on the same silicon together with an onboard Digital Motion Processor (DMP) capable of processing complex 9-axis MotionFusion algorithms. Also, it has additional feature of on-chip Temperature sensor. It has I2C bus interface to communicate with the microcontrollers. A micro-electro-mechanical system (MEMS) is used to measure velocity, acceleration, orientation, displacement, and many other motion-related parameters. Refer blog for more detail :https://www.dofbot.com/post/iot-based-object-angle-measure-using-mpu-6050-and-blynk Calculations Note that gyroscope and accelerometer sensor data of MPU6050 module consists of 16-bit raw data in 2’s complement form. Temperature sensor data of MPU6050 module consists of 16-bit data (not in 2’s complement form). Now suppose we have selected, - Accelerometer full scale range of +/- 2g with Sensitivity Scale Factor of 16,384 LSB(Count)/g. - Gyroscope full scale range of +/- 250 °/s with Sensitivity Scale Factor of 131 LSB (Count)/°/s. then, To get sensor raw data, we need to first perform 2’s complement on sensor data of Accelerometer and gyroscope. After getting sensor raw data we can calculate acceleration and angular velocity by dividing sensor raw data with their sensitivity scale factor as follows, Accelerometer values in g (g force) Acceleration along the X axis = (Accelerometer X axis raw data/16384) g. Acceleration along the Y axis = (Accelerometer Y axis raw data/16384) g. Acceleration along the Z axis = (Accelerometer Z axis raw data/16384) g. Gyroscope values in °/s (degree per second) Angular velocity along the X axis = (Gyroscope X axis raw data/131) °/s. Angular velocity along the Y axis = (Gyroscope Y axis raw data/131) °/s. Angular velocity along the Z axis = (Gyroscope Z axis raw data/131) °/s. For example, Suppose, after 2’ complement we get accelerometer X axes raw value = +15454 Then Ax = +15454/16384 = 0.94 g. Installing the Arduino Library No need any special libraries. Subscribe and Download code. Arduino Code #include const int MPU_addr=0x68; int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ; // remove wiring from bluetooth while uploading program int minVal=265; int maxVal=402; double x; double y; double z; void setup(){ Wire.begin(); Wire.beginTransmission(MPU_addr); Wire.write(0x6B); Wire.write(0); Wire.endTransmission(true); Serial.begin(9600); } void loop(){ Wire.beginTransmission(MPU_addr); Wire.write(0x3B); Wire.endTransmission(false); Wire.requestFrom(MPU_addr,14,true); AcX=Wire.read()<<8|Wire.read(); AcY=Wire.read()<<8|Wire.read(); AcZ=Wire.read()<<8|Wire.read(); int xAng = map(AcX,minVal,maxVal,-90,90); int yAng = map(AcY,minVal,maxVal,-90,90); int zAng = map(AcZ,minVal,maxVal,-90,90); x= RAD_TO_DEG * (atan2(-yAng, -zAng)+PI); y= RAD_TO_DEG * (atan2(-xAng, -zAng)+PI); z= RAD_TO_DEG * (atan2(-yAng, -xAng)+PI); Serial.print(x); Serial.print("|"); Serial.print(y); Serial.print("|"); Serial.print(z); Serial.print("\n"); delay(500); } Serial monitor After a successful upload, open the Serial Monitor at a baud rate of 9600. see the result on Serial monitor. Android application First open Mobile application and select Bluetooth image button, after that select Bluetooth HC-05 device to connect and enter Password as mentioned above (0000 or 1234). Subscribe and Download code. Android App MIT BLOCK MIT app inventor Block image for android application development.

  • Arduino based 2 Axis Solar Tracking using LDR

    Here is a solar tracker system that tracks the sun’s movement across the sky and tries to maintain the solar panel perpendicular to the sun’s rays, ensuring that the maximum amount of sunlight is incident on the panel throughout the day. The solar tracking system starts following the sun right from dawn, throughout the day till evening, and starts all over again from the dawn next day. Circuit Diagram: Components: Arduino Uno - 1 no Servo Motor SG 90- 2 nos Pan/Tilt Bracket Kit (Multi Attachment) - 1 no LDR medium size - 4 nos 4k7 Resistor - 4 nos Battery 9 V- 1 no Solar Panel - Optional For Programmed ardunio Uno & Price: https://www.dofbot.com/product-page/arduino-based-2-axis-solar-tracking-using-ldr-and-servo-motor Explanation: Let us design a solar tracker using two servo motors, a light sensor consisting of four LDRs and Arduino UNO board. Four LDRs and Four 100KΩ resistors are connected in a voltage divider and the output is given to 4 Analog input pins of Arduino. The PWM inputs of two servos are given from digital pins 9 and 10 of Arduino. LDRs are used as the main light sensors. Two servo motors are fixed to the structure that holds the solar panel, one for the horizontal position and one for vertical position. LDRs sense the amount of sunlight falling on them. Four LDRs are divided into top, bottom, left and right. For east – west tracking, the analog values from two top LDRs and two bottom LDRs are compared and if the top set of LDRs receive more light, the vertical servo will move in that direction. If the bottom LDRs receive more light, the servo moves in that direction. For angular deflection of the solar panel, the analog values from two left LDRs and two right LDRs are compared. If the left set of LDRs receive more light than the right set, the horizontal servo will move in that direction. If the right set of LDRs receive more light, the servo moves in that direction. Subscribe Program Code: #include //defining Servos Servo ServoMotorH; int ServoHorizotal = 0; int ServoHorizotalLimitHigh = 160; int ServoHorizotalLimitLow = 20; Servo ServoMotorV; int ServoVertical = 0; int ServoVerticalLimitHigh = 160; int ServoVerticalLimitLow = 20; //Assigning LDRs int LDR1 = 0; //top left int LDR2 = 1; //top right int LDR4 = 3; // bottom left int LDR3 = 2; // bottom right void setup () { ServoMotorH.attach(10); ServoMotorH.write(0); ServoMotorV.attach(9); ServoMotorV.write(0); delay(500); } void loop() { ServoHorizotal = ServoMotorH.read(); ServoVertical = ServoMotorV.read(); //capturing analog values of each LDR int NorWes = analogRead(LDR1); int NorEas = analogRead(LDR2); int SouWes = analogRead(LDR4); int SouEas = analogRead(LDR3); // calculating average int NORTH = (NorWes + NorEas) / 2; //average of top LDRs int SOUTH = (SouWes + SouEas) / 2; //average of bottom LDRs int WEST = (NorWes + SouWes) / 2; //average of left LDRs int EAST = (NorEas + SouEas) / 2; //average of right LDRs if (NORTH < SOUTH) { ServoMotorV.write(ServoVertical +1); if (ServoVertical > ServoVerticalLimitHigh) { ServoVertical = ServoVerticalLimitHigh; } delay(15); } else if (SOUTH < NORTH) { ServoMotorV.write(ServoVertical -1); if (ServoVertical < ServoVerticalLimitLow) { ServoVertical = ServoVerticalLimitLow; } delay(15); } else { ServoMotorV.write(ServoVertical); } if (WEST > EAST) { ServoMotorH.write(ServoHorizotal +1); if (ServoHorizotal > ServoHorizotalLimitHigh) { ServoHorizotal = ServoHorizotalLimitHigh; } delay(15); } else if (EAST > WEST) { ServoMotorH.write(ServoHorizotal -1); if (ServoHorizotal < ServoHorizotalLimitLow) { ServoHorizotal = ServoHorizotalLimitLow; } delay(15); } else { ServoMotorH.write(ServoHorizotal); } delay(50); } Demo: Subscribe Pay and get arduino code

  • ESP8266 Web server Controlled 8x8 Dot LED Matrix and Scroll

    This tutorial is for How to customize the 8x8 dot LED display and scrolling text on the MAX7219 Matrix display using a custom webpage. Components Required Node MCU ESP8266 Development Board - 1 no MAX7219 8×8 Dot Matrix module - 1 Circuit Diagram Max7219 Single Display This is Dot Led Matrix Module incorporating MAX7219 Driver chip. By using this dot LED module in your upcoming project, you will be able to add some great cool animation. The individual module features 8×8 LED’s, each controlled very precisely by the MAX7219 driver to generate the color pattern you wish. The great advantage of using this is users will have control over all of the 64 LED by just connecting 3 output communication wires to microcontrollers like Arduino etc. Connecting the two modules is also very easy. Only connect the output pins of the previous breakout board to the input pins of the new module, thus with such arrangement, you can connect as many DOT LED Modules to the Arduino as you wish!!! Great…… The MAX7219 Dot Led Matrix Module is a serial input common-cathode driver that interfaces micro-controllers to LED matrices. All common micro-controllers can be connected to this module by using a 4-wire serial interface. Each output can be addressed without refreshing the entire display. This module requires only 3 I/O lines for driving the display, making it ideal for your microcontroller projects. Only one external register is used to set the segment current of each LED. Input Voltage: 3.7 to 5.3 V Input Current: 320 mA Pin Connection from Dot LED Module to the ESP8266 Vcc – 5V GND – GND DIN – Pin 14 CS – Pin 5 CLK – Pin 4 Features Requires only 3 communication wires of MCU Cascading multiple Matrix LED Module is very easy Installing the library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Download Led Control_Library , we need to use this library for Max7219 Matrix display Download WIFI manager , we need to use this library for wifi configuration. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. You need to webpage.h Download and fonts.h Download Subscribe and Download code arduino code #include #include //needed for wifimanager library #include //needed for wifimanager library #include //https://github.com/tzapu/WiFiManager const char *ssid = "TP-Link_3200", *password = "95001121379884265554"; #include #include ESP8266WebServer server(80); #include "webpage.h" boolean showSaved = true; #include "fonts.h" #include int DIN = 14; // D5 OF NODEMCU int CS = 5; // D1 '' int CLK = 4; // D2 '' LedControl lc = LedControl(DIN, CLK, CS, 0); String last_matrix = "0000000000000000000000000000000000000000000000000000000000000000"; #include int eeprom_addr = 0; void setup() { Serial.begin(115200); Serial.println(); Serial.println("LED MATRIX web server"); EEPROM.begin(512); lc.shutdown(0, false); //The MAX72XX is in power-saving mode on startup // lc.setScanLimit(0, 8); // necessary?? lc.setIntensity(0, 3); // Set the brightness to maximum value 0-15 lc.clearDisplay(0); // and clear the display displaySaved(); // display last saved matrix pinMode(LED_BUILTIN, OUTPUT); // blink onboard LED for (int i = 0; i < 10; i++) { digitalWrite(LED_BUILTIN, LOW); delay(100); digitalWrite(LED_BUILTIN, HIGH); delay(100); } Serial.println("configure wifi manager..."); WiFiManager wifiManager; // wifiManager.resetSettings(); // known networks are saved so need to reset for testing wifiManager.autoConnect("matrix"); digitalWrite(LED_BUILTIN, LOW); // inverted pin - LOW is on Serial.println("connected to wifi!"); server.on("/", handleRoot); server.begin(); Serial.print("HTTP server started on "); Serial.println(WiFi.localIP()); scrollText("Dofbot AI Shop IP:" + WiFi.localIP().toString(), 50); displaySaved(); // display last saved matrix delay(2000); } void loop() { server.handleClient(); } void printByte(const byte character []) { int i = 0; for (i = 0; i < 8; i++) { lc.setRow(0, i, character[i]); } } void printInt(int character []) { int i = 0; for (i = 0; i < 8; i++) { lc.setRow(0, i, character[i]); } } void printFont(const byte character[] ) { int i = 0; for (i = 0; i < 8; i++) { lc.setRow(0, i, flipByte(character [i])); } } byte flipByte(byte c) { char r = 0; for (byte i = 0; i < 8; i++) { r <<= 1; r |= c & 1; c >>= 1; } return r; } void handleRoot() { server.send(200, "text/html", webpage_html); String data = server.arg(0); if (server.argName(0) == "matrix") { displayMatrix(data); last_matrix = data; Serial.println("received data and updated the matrix"); showSaved = false; } if (server.argName(0) == "intensity") { lc.setIntensity(0, data.toInt()); // Set the brightness to maximum value 0-15 Serial.print("updated intensity to "); Serial.println(data); } if (server.argName(0) == "text") { Serial.println("scrolling text: " + data); int d = map(server.arg(1).toInt(), 1, 10, 200, 20); scrollText(data, d); displayMatrix(last_matrix); } if (server.argName(0) == "save") { Serial.println("saving matrix"); for (int u = 0; u < 8; u++) { // for every row, construct 1 byte byte row = 0; for (int i = 0; i < 8; i++) { bitWrite(row, 7 - i, last_matrix.charAt(8 * u + i) - 48); } // Serial.println(row); EEPROM.write(eeprom_addr + u, row); } EEPROM.commit(); } if (server.argName(0) == "load") { Serial.println("loading matrix"); displaySaved(); showSaved = true; } } void displayMatrix(String t) { for (int i = 0; i < 64; i++) { lc.setLed(0, i / 8, i % 8, t.charAt(i) - 48); } } void displaySaved() { last_matrix = ""; byte a[8]; for (int u = 0; u < 8; u++) { a[u] = EEPROM.read(eeprom_addr + u); for (int i = 0; i < 8; i++) { last_matrix += bitRead(a[u], 7 - i); } } printByte(a); } void scrollText(String t, int s) { // text and speed int l = t.length() + 1; // store length t = " " + t + " "; // add space before and after for (int i = 0; i <= l * 8; i++) { // index of moving window over 2 chars int this_frame[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // define as int holding 2 chars (2x byte) for (int u = 0; u < 8; u++) { // for each row int left = (int) flipByte(font[t.charAt(i / 8)] [u]); // left char int right = (int) flipByte(font[t.charAt(i / 8 + 1)] [u]); // right char this_frame[u] = (left << 8) | right; // combine chars to 16 bits this_frame[u] = this_frame[u] << i % 8; // move window to very left this_frame[u] = this_frame[u] >> 8; // move result to very right this_frame[u] = this_frame[u] & 0x00FF; // mask result to byte on right } printInt(this_frame); delay(s); } } void printDigits(int digits) { Serial.print(":"); if (digits < 10) Serial.print('0'); Serial.print(digits); } Subscribe and Download code After a successful upload, open the Serial Monitor at a baud rate of 152000. Press the “EN/RST” button on the ESP8266 board Demo: Subscribe and Download code

  • Bluetooth Controlled Home Automation with Voice Announcement using Android App

    In this tutorial to learn the Arduino based Home Automation will enable the user to use a Home Automation System based on Bluetooth Connectivity. The user commands over Android Mobile will be obtained by Mobile Bluetooth. The Microcontroller has an interface with this Bluetooth. The system status is displayed through the LCD display, along with the voice. Bluetooth Home Automation system, for controlling all your electrical appliances by using Android application. The system works only with associated anroid app. Circuit Diagram Components Required 1) Arduino Uno R3 2) Bluetooth HC-05 3) 4 channel Relay module 4) Speaker 5) DFPlayer 6)Memory card 16gb- 1 no 7)Push button - 3 nos 8)Resistor 1k - 1 no Refer blog for more details: https://www.dofbot.com/post/arduino-based-mp3-player-using-df-player-mini DFPlayer Mini The DFPlayer Mini MP3 Player For Arduino is a small and low price MP3 module with an simplified output directly to the speaker. The module can be used as a stand alone module with attached battery, speaker and push buttons or used in combination with an Arduino UNO or any other with RX/TX capabilities. Installing Library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. DFRobotDFPlayerMini.h : you need to Download and install the DFPlayer library. LiquidCrystal_I2C.h : you need to Download and install the LCD display library. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe Demo Download Android app: https://drive.google.com/file/d/1i-m1AoQHRarkoygGHmCFvb2VEVlIlSUo/view?usp=sharing

  • Arduino based gesture Home Automation using APDS-9960

    In this tutorial to learn the Arduino UNO Rev 3 based Gesture Home Automation using APDS 9960, will enable the user to use a Home Automation System using by hand for gesture. The gesture sensor sense the hand direction for Right to Left, Left to Right, Up to Down, Down to Up, Near to Rar, Far to Near. Arduino has an interface with APDS-9960 and 4 channel relay, These gesture commands to control the relay. The relay for controlling LED light by using HAND GESTURE. The output status is displayed through the LCD display. Circuit diagram Components Required Arduino Uno - 1 no APDS-9960 Gesture sensor- 1no APDS9960 sensor The APDS9960 sensor is a multi function sensor widely used in smart phones to provide a number of functions. The first use is recognition of swiping gestures as up, down, left or right depending on the movement of a user’s finger over the screen. This sensor also provides proximity sensing which is used to detect when the phone is placed near the ear thereby disabling the touchscreen while attending to a call. The ambient light and RGB color detection feature is used to adjust the brightness and color balance of the phone’s backlight depending on lighting conditions. There are six header pin connections namely; VL – This an optional power supply for the IR LED. It is used when the PS jumper is removed and should have a voltage of 3.0 – 4.5V DC. GND – Connection to ground of a microcontroller. VCC – Power supply connected to 3.3V of the microcontroller. SDA – I2C Data line. SCL – I2C Clock line. INT – Interrupt output active LOW. Output is open-collector so requires pull-up resistor and is connected to an interrupt input of a microcontroller when used. The breakout board also has two solder jumper pads. PS – This solder jumper comes closed by default and is used to connect the power supplies of the sensor and IR LED together therefore you only need to supply power to the VCC pin. However, if the jumper is open, you have to provide separate power supplies for VCC (2.4 – 3.6V) and VL (3.0 – 4.5V). I2C PU – This is a 3-way solder jumper used to connect the I2C 10K pull-up resistors to the SDA and SCL line on the board circuits. The jumper is also closed by default but in case you want to use external pull-up resistors then you can open it. APDS-9960 module Datasheet Installing Library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Arduino_APDS9960.h : you need to Download and install the Gesture library. LiquidCrystal_I2C.h : you need to Download and install the LCD display library. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe Demo

  • IoT Cloud Web Server Based Vibration Monitor and Email Notification using Vibration Sensor

    To make a simple Vibration monitoring device using SW-420 vibration sensor module, IOT Cloud (myDevices Cayenne), Web Server and LCD interface. This Vibration Sensor can be used to detect vibration from any angle. There is an on-board potentiometer to adjust the threshold of vibration. It outputs logic HIGH when this module not triggered while logic Low when triggered. here to used Earthquake application. The main objective of project is to work on the real-time earthquake detector sensor network, and design such a low-cost real-time earthquake detector monitoring system that can be easily used throughout the country or world. So that’s why I decided to work on this project and make our own monitoring system for the earthquake based on the wifi module, vibration sensor, and IoT platform. On the other hand, Cayenne is an IoT cloud platform that provides several cloud services, such as: Data visualization IoT cloud Alerts Scheduling Events We will focus our attention on data visualization and on the IoT cloud services. Circuit diagram Components Required Vibration sensor SW-420 - 1 no Node MCU ESP8266 12E - 1 no LCD 16x2 with I2C- 1 no refer previous post for more detail: https://www.dofbot.com/post/earth-quake-monitoring-and-email-notification-using-vibration-sensor NodeMCU NodeMCU ESP8266-12E MCU is a development board with one analogue and many general-purpose input output (GPIO) pins. It has 4MB flash memory, and can operate at a default clock frequency of 80MHz. In this project, digital pin D0 of NodeMCU is used to read Data of Vibration Sensor. Cayenne Cayenne IoT Platform accelerates the development of IoT-based solutions, including quick design, prototyping and other commercialized projects. It is a drag-and-drop IoT project builder that can help developers build complete, ready-to-use IoT solutions with little to no coding. Cayenne IoT Platform contains a vast catalogue of certified IoT-ready devices and connectivity options. This allows users to easily add any device to the library utilizing MQTT API. All devices in Cayenne are interoperable and benefit from features such as rules engine, asset tracking, remote monitoring and control, and tools to visualize real-time and historical data. MQTT is a lightweight messaging protocol for sensors and mobile devices. Vibration Sensor SW420 Vibration Sensor Module comes with SW-420 vibration sensor, integrated with adjustable sensitivity via on board potentiometer. There are also LED indicators for power and the digital output status on board. It has a simple and straight forward 3-pin interface, VCC, GND and the DO (digital output). It supports 3.3V or 5V power. The DO pin will be LOW when there is no vibration, and indicator LED will lit up NodeMCU programming with Arduino IDE You need Arduino IDE software to program NodeMCU. Steps for adding NodeMCU ESP8266 board and library to Arduino IDE are given below. Open Arduino IDE. Go to File menu and select Preferences. Copy this package and paste in Additional Boards Manager URL. Go to Tools and select Boards Manager. Type esp8266 in search box and press Enter. Install the latest version. From Tools menu, select NodeMCU 1.0 (ESP-12E module) board. Select Include Library from Sketch menu. Download the library from this link. Click on Add ZIP Library and add Cayenne-MQTT-ESP-master zip file, or directly copy the folder (Cayenne-MQTT-ESP-master) and paste it in Libraries folder of Arduino IDE. Configure Wifi setting: Follow the Steps. Open wifi setting in mobile Select "Earth quake" device After Connected device without internet, open Webpage Enter IP 192.168.4.1, after loading Select Wifi Configure. Confirm Switch On Your router, Select Your router Enter your Wifi credentials SSID, Password. After entered your credentials, the ESP8266 connected to the router. now ESP 8266 IP address displayed in LCD display. Hardware interfacing with Cayenne IoT platform To interface the circuit with the IoT platform, open this link on any browser. Click on Add new and then Device/Widget in Settings, Add New Device here and select Generic ESP8266 for in this project. Configure device Generic ESP8266, MQTT username, password and client ID from Create App Paste these respective details under username, password and client ID in Arduino source code , along with your Wi-Fi name and password. After successfully compiling and uploading the code to NodeMCU, You will see ESP8266 connected to Wi-Fi. After the connection is established, the previous page is automatically updated on Cayenne. A new dashboard opens in the browser. Cayenne generates an ID and a device icon for your device. Vibration dashboard for ESp8266. Cayenne new trigger creation and add recipient. Trigger ran stasus Triggeer OFF when button to OFF state. Email Notification when channel reached threshold condition. Subscribe

  • IoT Cloud and Web Server Based Water Level Controller

    Here to build a water level monitoring and controller based on Internet of things. In this Water level monitoring using myDevices Cayenne(IOT cloud), Fusion chart(Web Server) in HTML page and 4 line LCD display. The real time Liquid level and Motor ON/OFF Status can be monitored via internet and data stored in Cloud. The IOT system uses non-contact method (ultrasonic sensor based) for measuring liquid level up to 400cm. Measuring water level is same as measuring distance of liquid surfaces, the ultrasonic transducer outputs a train of ultrasonic bursts at 40 KHz which will hit the water surface and reflect back to the sensor. The time taken between sent and received ultrasonic waves are calculated by a micro controller such as ESP8266 12E. The measured distance in cm is converted in to percentage. Components Required HC SR04- Ultrasonic sensor - 1 no 20x4-I2C- LCD display - 1 no ESP8266 12e- NodeMCU - 1 no Push Button Switch - 1 no Relay 5V,1 channel - 1 no Transistor SL100 - 1 no Resistor 2K, 1K - 1 no Circuit diagram Refer Previous Post for More details: https://www.dofbot.com/post/iot-water-level-controller-using-ultrasonic Subscribe and Download code. Configure Wifi setting: Follow the Steps. Open wifi setting in mobile Select "Smart level" device After Connected device without internet, open Webpage Enter IP 192.168.4.1, after loading Select Wifi Configure. Confirm Switch On Your router, Select Your router Enter your Wifi credentials SSID, Password. After entered your credentials, the ESP8266 connected to the router. now ESP 8266 IP address displayed in LCD display. Tank height: How change to Tank height?. first Restart ESP8266 Board using "rst" button. after restarting Press Push button connected in NodeMCU pin D0 and Hold for 5 seconds. Now Tank Height is set in cm and displayed in LCD display. Tank height value stored in EEPROM, so After Power off condition the value is retained.Note: When setting the Tank height, tank shall be empty otherwise reading goes wrongly. Web server: Open Browser and Enter IP address displayed in the LCD. Example: 192.168.0.100. IoT Cloud (My devices .com) Login Credential and select device "smart Level" and get result and customize your self. IoT Cloud (My devices .com) Data stored in Cloud server, the real time data available in graph format. LCD Display. 4 line 20 chracter LCD display used in this project. Line 1. Tank height in cm Line 2. IP address for Web Server- ESP8266 Line 3. Water Level in %.. Line 4. Pump Motor ON/OFF status. Installing the Arduino_Library LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe

  • IoT Cloud Web server Based Garbage Monitoring System(Optional Email, Mobile notification)

    Here to make the Internet of Things an IoT based garbage bin level monitoring system. In this level monitoring using myDevices Cayenne, canvas gauge in HTML page and LCD. The real time garbage fill level can be monitored via internet. The IOT system uses non-contact method (ultrasonic sensor based) for measuring garbage level and it can detect solid, semi-solid and liquid waste level up to 20cm and capable of 400cm. Price: https://www.dofbot.com/product-page/iot-cloud-web-server-based-garbage-monitoring-system One of the main concerns with our environment has been solid waste management which impacts the health and environment of our society. The detection, monitoring and management of wastes is one of the primary problems of the present era. The traditional way of manually monitoring the wastes in waste bins is a cumbersome process and utilizes more human effort, time and cost which can easily be avoided with our present technologies. This is our solution, a method in which waste management is automated. This is our IoT Garbage Monitoring system, an innovative way that will help to keep the cities clean and healthy. Follow on to see how you could make an impact to help clean your community, home or even surroundings, taking us a step closer to a better way of living. Components Required HC SR04- Ultrasonic sensor - 1 no 20x4-I2C- LCD display - 1 no ESP8266 12e- NodeMCU - 1 no Push Button Switch - 1 no Circuit diagram Refer Previous Post for More details: https://www.dofbot.com/post/iot-cloud-smart-garbage-monitoring-system-with-email-sms-notification Configure Wifi setting: Follow the Steps. Open wifi setting in mobile Select "Garbage Bin" device After Connected device without internet, open Webpage Enter IP 192.168.4.1, after loading Select Wifi Configure(No scan) Confirm Switch On Your router, Select Your router Enter your Wifi credentials SSID, Password. After entered your credentials, the ESP8266 connected to the router. now ESP 8266 IP address displayed in LCD display. Bin height: How change to Bin height?. first Restart ESP8266 Board using "rst" button. after restarting Press Push button connected in NodeMCU pin D0 and Hold for 5 seconds. Now Bin Height is set in cm and displayed in LCD display. Bin height value stored in EEPROM, so After Power off condition the value is retained. Note: When setting the Bin height, bin shall be empty otherwise reading goes wrongly. Web server: Open Browser and Enter IP address displayed in the LCD. Example: 192.168.0.100. IoT Cloud (My devices .com) Login Credential and select device "smart Bin" and get result and customize your self. IoT Cloud (My devices .com) Data stored in Cloud server The real time data available in graph format. IoT Cloud (My devices .com) Email and Mobile notification available in User menu tab, Triggers and alerts. IoT Cloud (My devices .com) Enter new trigger and add threshold value, recipients email, mobile number for notification. when reaching Threshold limit, cayenne server send the Notification alert to recipients. LCD Display. 4 line 20 chracter LCD display used in this project. Line 1. Project name Line 2. IP address for Web Server- ESP8266 Line 3. Bin height in cm. Line 4. Waste level full status in Percentage format. Installing the Arduino_Library LiquidCrystal_I2C.h : you need to Downloadand install the LiquidCrystal_I2C library. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code. Download code Code for arduino Interface with LCD and ultrasonic sensor. #include LiquidCrystal_I2C lcd(0x27,20,4); #include Ultrasonic ultrasonic(D5,D6); int distance; int buttonState = 0; int percentage; float Level,TankHeight; void setup() { Serial.begin(115200); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); distance = ultrasonic.read(); TankHeight = distance; } delay(1000); } { lcd.clear(); lcd.setCursor(0,0); lcd.print("Bin Height Set at cm"); lcd.setCursor(0,1); lcd.print(" "); lcd.print(TankHeight); delay(2000); lcd.clear(); lcd.setCursor(0,0); lcd.print("SMART GARBAGE SYSTEM"); lcd.setCursor(0,2); lcd.print("Bin Height Cm:"); lcd.setCursor(15,2); lcd.print(TankHeight); } Level = distance/TankHeight; } void loop() { distance = ultrasonic.read(); Serial.print("Distance in CM : "); Serial.println(distance); percentage = ((1-(distance/TankHeight))*100); lcd.setCursor(0,3); lcd.print("Waste Full %:"); lcd.print(percentage); lcd.print(" "); delay(1000); } Subscribe

  • Internet Weather Forecast

    Here to learn how to make an IOT based internet weather station with OLED. The ESP8266 can access the internet and gets weather data from www.openweathermap.org that provide Free/Paid weather information for many cities over the world. In this project to show how to get weather data from the internet and print it on OLED display. Circuit Diagram Components Required 0.96 OLED 4wire Module - 1no Node MCU ESP8266 12E Dev Module- 1 no Refer Weather station on before: https://www.dofbot.com/post/internet-weather-station Open weather map Internet weather station To get weather data, first we’ve to sign up for a free account in order to get an API key which is important in this project. Hourly forecast is available for 4days Forecast weather data for 96 timestamps JSON and XML formats Included in the Developer, Professional and Enterprise subscription plans Once you sign in to your account (of course after the free registration), you’ll be directed to member area, go to API keys and you’ll find your API key as shown in the following image: Replace CITY by with the city you want weather data for, and YOUR_API_KEY with your API key which is shown above and replace API key in the arduino code. For example the weather in Chennai, URL and API key. URL like https://openweathermap.org/city/1264527 String OPEN_WEATHER_MAP_LOCATION_ID = "1264527"; // for chennai Pick a language code from this list i below. // Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el, // English - en, Persian (Farsi) - fa, Finnish - fi, French - fr, Galician - gl, // Croatian - hr, Hungarian - hu, Italian - it, Japanese - ja, Korean - kr, // Latvian - la, Lithuanian - lt, Macedonian - mk, Dutch - nl, Polish - pl, // Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk, // Slovenian - sl, Spanish - es, Turkish - tr, Ukrainian - ua, Vietnamese - vi, // Chinese Simplified - zh_cn, Chinese Traditional - zh_tw. String OPEN_WEATHER_MAP_LANGUAGE = "en"; Hourly forecast is available for 4days const uint8_t MAX_FORECASTS = 4; Installing Library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Download SSD1306Wire.h Library , we need to use this library for SSD1306 OLED display Download JsonListener.h_Library , we need to use this library for json-streaming-parser-master Download misc Library , we need to use this library for weather After installing the required libraries, copy the following code to your Arduino IDE. arduino code Subscribe and Download code #include #include #include #include // time #include // time() ctime() #include // struct timeval #include // settimeofday_cb() #include "SSD1306Wire.h" #include "OLEDDisplayUi.h" #include "Wire.h" #include "OpenWeatherMapCurrent.h" #include "OpenWeatherMapForecast.h" #include "WeatherStationFonts.h" #include "WeatherStationImages.h" #include #include #include WiFiClient client; // WIFI const char* WIFI_SSID = "TP-Link_3200";// your SSID const char* WIFI_PWD = "95001121379884265554";//your wifi password #define TZ 5 // (utc+) TZ in hours India chennai time setting// your area #define DST_MN 30 // use 60mn for summer time in some countries'' // Setup const int UPDATE_INTERVAL_SECS = 20 * 60; // Update every 20 minutes // Display Settings const int I2C_DISPLAY_ADDRESS = 0x3c; #if defined(ESP8266) const int SDA_PIN = 5; const int SDC_PIN = 4; #else const int SDA_PIN = 5; //D3; const int SDC_PIN = 4; //D4; #endif // OpenWeatherMap Settings // Sign up here to get an API key: // https://docs.thingpulse.com/how-tos/openweathermap-key/ String OPEN_WEATHER_MAP_APP_ID = "add82e4e24d449f3a522f06621a3aaeb"; String OPEN_WEATHER_MAP_LOCATION_ID = "1264527"; // for chennai // Pick a language code from this list: // Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el, // English - en, Persian (Farsi) - fa, Finnish - fi, French - fr, Galician - gl, // Croatian - hr, Hungarian - hu, Italian - it, Japanese - ja, Korean - kr, // Latvian - la, Lithuanian - lt, Macedonian - mk, Dutch - nl, Polish - pl, // Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk, // Slovenian - sl, Spanish - es, Turkish - tr, Ukrainian - ua, Vietnamese - vi, // Chinese Simplified - zh_cn, Chinese Traditional - zh_tw. String OPEN_WEATHER_MAP_LANGUAGE = "en"; const uint8_t MAX_FORECASTS = 4; const boolean IS_METRIC = true; // Adjust according to your language const String WDAY_NAMES[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}; const String MONTH_NAMES[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; // Initialize the oled display for address 0x3c // sda-pin=14 and sdc-pin=12 SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN); OLEDDisplayUi ui( &display ); OpenWeatherMapCurrentData currentWeather; OpenWeatherMapCurrent currentWeatherClient; OpenWeatherMapForecastData forecasts[MAX_FORECASTS]; OpenWeatherMapForecast forecastClient; #define TZ_MN ((TZ)*60) #define TZ_SEC ((TZ)*3600) #define DST_SEC ((DST_MN)*60) time_t now; // flag changed in the ticker function every 10 minutes bool readyForWeatherUpdate = false; String lastUpdate = "--"; long timeSinceLastWUpdate = 0; //declaring prototypes void drawProgress(OLEDDisplay *display, int percentage, String label); void updateData(OLEDDisplay *display); void drawDateTime(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawCurrentWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawForecast(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawForecastDetails(OLEDDisplay *display, int x, int y, int dayIndex); void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state); void setReadyForWeatherUpdate(); // Add frames // this array keeps function pointers to all frames // frames are the single views that slide from right to left FrameCallback frames[] = { drawDateTime, drawCurrentWeather, drawForecast }; int numberOfFrames = 3; OverlayCallback overlays[] = { drawHeaderOverlay }; int numberOfOverlays = 1; void setup() { Serial.begin(115200); delay(1000); Serial.println("connected?... :)"); delay(1000); Serial.println(); Serial.println(); // initialize display display.init(); display.clear(); display.display(); //display.flipScreenVertically(); display.setFont(ArialMT_Plain_10); display.setTextAlignment(TEXT_ALIGN_CENTER); display.setContrast(255); WiFi.begin(WIFI_SSID, WIFI_PWD); int counter = 0; while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); display.clear(); display.drawString(64, 10, "Connecting to WiFi"); display.drawXbm(46, 30, 8, 8, counter % 3 == 0 ? activeSymbole : inactiveSymbole); display.drawXbm(60, 30, 8, 8, counter % 3 == 1 ? activeSymbole : inactiveSymbole); display.drawXbm(74, 30, 8, 8, counter % 3 == 2 ? activeSymbole : inactiveSymbole); display.display(); counter++; } // Get time from network time service configTime(TZ_SEC, DST_SEC, "pool.ntp.org"); ui.setTargetFPS(30); ui.setActiveSymbol(activeSymbole); ui.setInactiveSymbol(inactiveSymbole); // You can change this to // TOP, LEFT, BOTTOM, RIGHT ui.setIndicatorPosition(BOTTOM); // Defines where the first frame is located in the bar. ui.setIndicatorDirection(LEFT_RIGHT); // You can change the transition that is used // SLIDE_LEFT, SLIDE_RIGHT, SLIDE_TOP, SLIDE_DOWN ui.setFrameAnimation(SLIDE_LEFT); ui.setFrames(frames, numberOfFrames); ui.setOverlays(overlays, numberOfOverlays); // Inital UI takes care of initalising the display too. ui.init(); Serial.println(""); updateData(&display); } void loop() { if (millis() - timeSinceLastWUpdate > (1000L*UPDATE_INTERVAL_SECS)) { setReadyForWeatherUpdate(); timeSinceLastWUpdate = millis(); } if (readyForWeatherUpdate && ui.getUiState()->frameState == FIXED) { updateData(&display); } int remainingTimeBudget = ui.update(); if (remainingTimeBudget > 0) { // You can do some work here // Don't do stuff if you are below your // time budget. delay(remainingTimeBudget); } } void drawProgress(OLEDDisplay *display, int percentage, String label) { display->clear(); display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(ArialMT_Plain_10); display->drawString(64, 10, label); display->drawProgressBar(2, 28, 124, 10, percentage); display->display(); } void updateData(OLEDDisplay *display) { drawProgress(display, 10, "Updating time..."); drawProgress(display, 30, "Updating weather..."); currentWeatherClient.setMetric(IS_METRIC); currentWeatherClient.setLanguage(OPEN_WEATHER_MAP_LANGUAGE); currentWeatherClient.updateCurrentById(&currentWeather, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION_ID); drawProgress(display, 50, "Updating forecasts..."); forecastClient.setMetric(IS_METRIC); forecastClient.setLanguage(OPEN_WEATHER_MAP_LANGUAGE); uint8_t allowedHours[] = {12}; forecastClient.setAllowedHours(allowedHours, sizeof(allowedHours)); forecastClient.updateForecastsById(forecasts, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION_ID, MAX_FORECASTS); readyForWeatherUpdate = false; drawProgress(display, 100, "Done..."); delay(1000); } void drawDateTime(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { now = time(nullptr); struct tm* timeInfo; timeInfo = localtime(&now); char buff[16]; display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(ArialMT_Plain_10); String date = WDAY_NAMES[timeInfo->tm_wday]; sprintf_P(buff, PSTR("%s, %02d/%02d/%04d"), WDAY_NAMES[timeInfo->tm_wday].c_str(), timeInfo->tm_mday, timeInfo->tm_mon+1, timeInfo->tm_year + 1900); display->drawString(64 + x, 5 + y, String(buff)); display->setFont(ArialMT_Plain_24); sprintf_P(buff, PSTR("%02d:%02d:%02d"), timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec); display->drawString(64 + x, 15 + y, String(buff)); display->setTextAlignment(TEXT_ALIGN_LEFT); } void drawCurrentWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { display->setFont(ArialMT_Plain_10); display->setTextAlignment(TEXT_ALIGN_CENTER); display->drawString(64 + x, 38 + y, currentWeather.description); display->setFont(ArialMT_Plain_24); display->setTextAlignment(TEXT_ALIGN_LEFT); String temp = String(currentWeather.temp, 1) + (IS_METRIC ? "°C" : "°F"); display->drawString(60 + x, 5 + y, temp); display->setFont(Meteocons_Plain_36); display->setTextAlignment(TEXT_ALIGN_CENTER); display->drawString(32 + x, 0 + y, currentWeather.iconMeteoCon); } void drawForecast(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { drawForecastDetails(display, x, y, 0); drawForecastDetails(display, x + 44, y, 1); drawForecastDetails(display, x + 88, y, 2); } void drawForecastDetails(OLEDDisplay *display, int x, int y, int dayIndex) { time_t observationTimestamp = forecasts[dayIndex].observationTime; struct tm* timeInfo; timeInfo = localtime(&observationTimestamp); display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(ArialMT_Plain_10); display->drawString(x + 20, y, WDAY_NAMES[timeInfo->tm_wday]); display->setFont(Meteocons_Plain_21); display->drawString(x + 20, y + 12, forecasts[dayIndex].iconMeteoCon); String temp = String(forecasts[dayIndex].temp, 0) + (IS_METRIC ? "°C" : "°F"); display->setFont(ArialMT_Plain_10); display->drawString(x + 20, y + 34, temp); display->setTextAlignment(TEXT_ALIGN_LEFT); } void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) { now = time(nullptr); struct tm* timeInfo; timeInfo = localtime(&now); char buff[14]; sprintf_P(buff, PSTR("%02d:%02d"), timeInfo->tm_hour, timeInfo->tm_min); display->setColor(WHITE); display->setFont(ArialMT_Plain_10); display->setTextAlignment(TEXT_ALIGN_LEFT); display->drawString(0, 54, String(buff)); display->setTextAlignment(TEXT_ALIGN_RIGHT); String temp = String(currentWeather.temp, 1) + (IS_METRIC ? "°C" : "°F"); display->drawString(128, 54, temp); display->drawHorizontalLine(0, 52, 128); } void setReadyForWeatherUpdate() { Serial.println("Setting readyForUpdate to true"); readyForWeatherUpdate = true; } After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the ESP8266 board. Now it should print its weather data. Demo Subscribe

  • NodeMCU World Clock

    In this tutorial, we will see how to make NodeMCU based World Clock using OLED display. Here, you don’t need Real Time Clock Module and time will be updated through wifi. we have added world’s 4 popular cities, you can add more if you want. Purchase : https://www.dofbot.com/product-page/nodemcu-based-world-clock Circuit Diagram Components Required 0.96 OLED 4wire Module - 1no Node MCU ESP8266 12E Dev Module- 1 no Oled Display This 0.96” I2C OLED Display is an OLED monochrome 128×64 dot matrix display module with I2C Interface. It is perfect when you need an ultra-small display. Comparing to LCD, OLED screens are way more competitive, which has a number of advantages such as high brightness, self-emission, high contrast ratio, slim outline, wide viewing angle, wide temperature range, and low power consumption. It is compatible with any 3.3V-5V microcontroller, such as Arduino. Pin Definition 1.GND: Power ground 2.VCC: Power positive 3.SCL: Clock wire 4.SDA: Data wire. Specifications Size: 0.96 inch Resolution: 128 x 64 Controlling Chip: SSH1106 Driving Voltage: 3.3-5V Operating Temperature: -40~70 celsius Interface Type: IIC Light Color: White Data Sheet Download Installing Library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Download SSD1306Wire.h Library , we need to use this library for SSD1306 OLED display Download JsonListener.h_Library , we need to use this library for json-streaming-parser-master Download misc Library , we need to use this library for weather After installing the required libraries, copy the following code to your Arduino IDE. arduino code #include #include #include #include #include #include #include #include #include #include "icons.h" #include "fonts.h" const char* WIFI_SSID = "TP-Link_3200"; const char* WIFI_PWD = "95001121379884265554"; // Setup const int UPDATE_INTERVAL_SECS = 10 * 60; // Update every 10 minutes // Display Settings const int I2C_DISPLAY_ADDRESS = 0x3C; const int SDA_PIN = D2; const int SDC_PIN = D1; // TimeClient settings // Initialize the oled display for address 0x3c // sda-pin=14 and sdc-pin=12 SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN); OLEDDisplayUi ui ( &display ); /*************************** * End Settings **************************/ String timeZoneIds [] = {"America/New_York", "Europe/London", "Europe/Paris", "Australia/Sydney"}; WorldClockClient worldClockClient("de", "CH", "E, dd. MMMMM yyyy", 4, timeZoneIds); // flag changed in the ticker function every 10 minutes bool readyForUpdate = false; String lastUpdate = "--"; Ticker ticker; void updateData(OLEDDisplay *display) { drawProgress(display, 50, "Updating Time..."); worldClockClient.updateTime(); drawProgress(display, 100, "Done..."); readyForUpdate = false; delay(1000); } void drawProgress(OLEDDisplay *display, int percentage, String label) { display->clear(); display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(ArialMT_Plain_10); display->drawString(64, 10, label); display->drawProgressBar(10, 28, 108, 12, percentage); display->display(); } void drawClock(OLEDDisplay *display, int x, int y, int timeZoneIndex, String city, const uint8_t* icon) { display->setTextAlignment(TEXT_ALIGN_LEFT); display->setFont(ArialMT_Plain_10); display->drawString(x + 60, y + 5, city); display->setFont(Crushed_Plain_36); display->drawXbm(x, y, 60, 60, icon); display->drawString(x + 60, y + 15, worldClockClient.getHours(timeZoneIndex) + ":" + worldClockClient.getMinutes(timeZoneIndex)); } void drawFrame1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { drawClock(display, x, y, 0, "New York", new_york_bits); } void drawFrame2(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { drawClock(display, x, y, 1, "London", london_bits); } void drawFrame3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { drawClock(display, x, y, 2, "Paris", paris_bits); } void drawFrame4(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { drawClock(display, x, y, 3, "Sydney", sydney_bits); } void setReadyForWeatherUpdate() { Serial.println("Setting readyForUpdate to true"); readyForUpdate = true; } // this array keeps function pointers to all frames // frames are the single views that slide from right to left FrameCallback frames[] = { drawFrame1, drawFrame2, drawFrame3, drawFrame4}; int numberOfFrames = 4; void setup() { Serial.begin(115200); Serial.println(); Serial.println(); // initialize dispaly display.init(); display.clear(); display.display(); //display.flipScreenVertically(); display.setFont(ArialMT_Plain_10); display.setTextAlignment(TEXT_ALIGN_CENTER); display.setContrast(255); WiFi.begin(WIFI_SSID, WIFI_PWD); int counter = 0; while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); display.clear(); display.drawString(64, 10, "Connecting to WiFi"); display.drawXbm(46, 30, 8, 8, counter % 3 == 0 ? activeSymbol : inactiveSymbol); display.drawXbm(60, 30, 8, 8, counter % 3 == 1 ? activeSymbol : inactiveSymbol); display.drawXbm(74, 30, 8, 8, counter % 3 == 2 ? activeSymbol : inactiveSymbol); display.display(); counter++; } ui.setTargetFPS(30); // You can change this to // TOP, LEFT, BOTTOM, RIGHT ui.setIndicatorPosition(BOTTOM); // Defines where the first frame is located in the bar. ui.setIndicatorDirection(LEFT_RIGHT); // You can change the transition that is used // SLIDE_LEFT, SLIDE_RIGHT, SLIDE_TOP, SLIDE_DOWN ui.setFrameAnimation(SLIDE_LEFT); // Add frames ui.setFrames(frames, numberOfFrames); // Inital UI takes care of initalising the display too. ui.init(); Serial.println(""); updateData(&display); ticker.attach(UPDATE_INTERVAL_SECS, setReadyForWeatherUpdate); } void loop() { if (readyForUpdate && ui.getUiState()->frameState == FIXED) { updateData(&display); } int remainingTimeBudget = ui.update(); if (remainingTimeBudget > 0) { // You can do some work here // Don't do stuff if you are below your // time budget. delay(remainingTimeBudget); } } Subscribe After a successful upload, open the Serial Monitor at a baud rate of 115200. Press the “EN/RST” button on the ESP8266 board. Now it should print its IP address. Demo Subscribe

bottom of page