top of page

Search Results

143 items found for ""

  • Security Password Protected Door Access with EEPROM

    Here to learn How to Make an password protected Door Opening System Using Arduino, LCD, servo, Push button, LED and Matrix keypad. The Red LED using for Door opening indication and Push button used emergency bypass for secured password protected door opening in case of you forget the password. The password storing in Arduino EEPROM and you can change the password any time and values stored in EEPROM. When the power of the Arduino the EEPROM remember the previously stored password. Circuit Diagram Components Required Arduino Nano - 1 no LCD 16x2 with I²C module - 1no 4x4 Matrix keypad - 1no Red LED - 1 no Servo mini SG90 - 1 no Push Button - 1no 10k resistor- 1no Servo motor A servo motor is an electric device used for precise control of angular rotation. It is used in applications that demand precise control over motion, like in case of control of a robotic arm. The rotation angle of the servo motor is controlled by applying a PWM signal to it. By varying the width of the PWM signal, we can change the rotation angle and direction of the motor. Wire Configuration: Brown - Ground wire connected to the ground of system Red - Powers the motor typically +5V is used Orange - PWM signal is given in through this wire to drive the motor Servo SG90 Data Sheet 4x4 keypad module 4x4 keypad will have eight terminals. In them four are rows of matrix and four are columns of matrix. These 8 pins are driven out from 16 buttons present in the module. Those 16 alphanumeric digits on the module surface are the 16 buttons arranged in matrix formation. Using keypad module is little tricky. As 16 keys are connected in matrix formation the module is a little complex to use. The module gives only 8 pins as a way for interacting with 16 buttons. We are going to explain how to use the keypad module in a simple way step by step: Consider we have connected the keypad module to a microcontroller. Step1: first set all rows to output and set them at +5v. Next set all columns as input to sense the high logic. Now consider a button is pressed on keypad. And that key is at 2nd column and 3rd row. With the button being pressed the current flows as shown in figure. With that a voltage of +5v appears at terminal c2. Since the column pins are set as inputs, the controller can sense c2 going high. The controller can be programmed to remember that c2 going high and the button pressed is in c2 column. Step2: next set all columns to output and set them at +5v. Next set all rows as input to sense the high logic. Since the key pressed is at 2nd column and 3rd row. The current flows as shown below. With that current flow a positive voltage of +5v appears at r3 pin. Since all rows are set as inputs, the controller can sense +5v at r3 pin. The controller can be programmed to remember the key being pressed at third row of keypad matrix. From previous step, we have known the column number of key pressed and now we know row number. With that we can match the key being pressed. We can take the key input provided by this way for 4x4 keypad module. 4x4 keypad 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. Keypad.h : you need to Download and install the keypad library. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. After installing the required libraries, copy the following code to your Arduino IDE. Arduino Code #include #include #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display #include Servo myservo; #define LEDindicator A3 //Door Open/close LED indicator #define BypassSwitch A2 //Push Button for emergency bypass int pos = 0; // variable to store the servo position const byte numRows= 4; //number of rows on the keypad const byte numCols= 4; //number of columns on the keypad char keymap[numRows][numCols]= { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'} }; char keypressed; char code[]= {'1','2','3','4'}; //The default password char code_buff1[sizeof(code)]; //Where the new password is stored char code_buff2[sizeof(code)]; //Where the new password is stored again short a=0,i=0,s=0,j=0; //Variables byte rowPins[numRows] = {8,9,10,11}; //Rows 0 to 3 byte colPins[numCols]= {2,3,4,5}; //Columns 0 to 3 Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols); void setup() { Serial.begin(9600); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.setCursor(0,0); lcd.print("ACCESS PROTECTED"); lcd.setCursor(0,1); lcd.print("ENTER *(PW)0 "); myservo.attach(7); // attaches the servo on pin 9 to the servo object pinMode(LEDindicator,OUTPUT); pinMode(BypassSwitch,INPUT); for(i=0 ; i= 90; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15 ms for the servo to reach the position } // delay(3000); //Opens for 3s you can change digitalWrite(LEDindicator,LOW); lcd.clear(); lcd.setCursor(0,0); lcd.print("ACCESS PROTECTED"); lcd.setCursor(0,1); lcd.print("ENTER *(PW)0 "); } } void GetCode(){ //Getting code sequence i=0; //All variables set to 0 a=0; j=0; while(keypressed != '0'){ //The user press 0 to confirm the code otherwise he can keep typing keypressed = myKeypad.getKey(); if(keypressed != NO_KEY && keypressed != '0' ){ //If the char typed isn't 0 and neither "nothing" lcd.setCursor(j,1); //This to write "*" on the LCD whenever a key is pressed it's position is controlled by j lcd.print("*"); j++; if(keypressed == code[i]&& i= 90; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15 ms for the servo to reach the position } digitalWrite(LEDindicator,LOW); } Subscribe and Download code with EEPROM Demo Video Subscribe and Download code in case of forget password to erase EEPROM values in address (without EEPROM).

  • Bluetooth Controlled Door Lock/Unlock with EEPROM

    Here to learn How to Make an Bluetooth controlled Door Opening and closing System Using Arduino, LCD, servo, LED and android application. The Servo Motor to control door open and close through bluetooth using android application. The Red/Green (Bi colour) LED using for Door Lock/Unlock indication and LCD display 16x2 using for Door open/close status. The Door locked/unlocked information number storing in Arduino EEPROM at every time of door Open/close. When the power of the Arduino the EEPROM remember the previously stored number and maintaining the door lock/unlock status. Circuit Diagram Components Required Arduino Nano - 1 no Bluetooth module HC-05 - 1no Bi color LED (CA) - 1 no Servo mini SG90 - 1 no Servo motor A servo motor is an electric device used for precise control of angular rotation. It is used in applications that demand precise control over motion, like in case of control of a robotic arm. The rotation angle of the servo motor is controlled by applying a PWM signal to it. By varying the width of the PWM signal, we can change the rotation angle and direction of the motor. Wire Configuration: Brown - Ground wire connected to the ground of system Red - Powers the motor typically +5V is used Orange - PWM signal is given in through this wire to drive the motor Servo SG90 Data Sheet 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, 1.Key/EN: It is used to bring Bluetooth module in AT commands mode. If Key/EN pin is set to high, then this module will work in command mode. Otherwise by default it is in data mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in data mode. HC-05 module has two modes, Data mode: Exchange of data between devices. Command mode: It uses AT commands which are used to change setting of HC-05. To send these commands to module serial (USART) port is used. 2. VCC: Connect 5 V or 3.3 V to this Pin. 3. GND: Ground Pin of module. 4. TXD: Transmit Serial data (wirelessly received data by Bluetooth module transmitted out serially on TXD pin) 5. RXD: Receive data serially (received data will be transmitted wirelessly by Bluetooth module). 6. State: It tells whether module is connected or not. 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 Default Communication: Slave Default Mode: Data Mode Data Mode Baud Rate: 9600, 8, N, 1 Command Mode Baud Rate: 38400, 8, N, 1 Default firmware: LINVOR Download 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. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. After installing the required libraries, copy the following code to your Arduino IDE. Arduino Code #include #include Servo myservo; #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display int RedLED = 4; int GreenLED = 5; void setup() { Serial.begin(9600); pinMode(RedLED, OUTPUT); pinMode(GreenLED, OUTPUT); pinMode(RedLED, HIGH); pinMode(GreenLED, HIGH); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); // setup code here myservo.attach(7); if(EEPROM.read(0) == 1) // Reads the EEPROM value stored. { myservo.write(90); // Rotates the servo to 90 for lock delay(200); } else if(EEPROM.read(0) == 2)// Reads the EEPROM value stored. { myservo.write(180); // Rotates the servo to 180 for open delay(200); } lcd.setCursor(0,0); lcd.print("BLUETOOTH ACCESS"); } void loop() { // put your main code here, to run repeatedly: if(Serial.available() > 0) { char data; data = Serial.read(); // The variable data is used to store the value sent by the Android app switch(data) { case '1': if(EEPROM.read(0) == 1) { EEPROM.write(0, 2); // Writes the number 2 to address 0 on the EEPROM. Serial.println((EEPROM.read(0))); for(int a = 90; a <= 180; a++) // Rotates the servo to the unlocked position { pinMode(RedLED, LOW); pinMode(GreenLED, HIGH); myservo.write(a); delay(15); lcd.setCursor(0,1); lcd.print("DOOR OPEN "); } } else if(EEPROM.read(0) == 2) { EEPROM.write(0, 1); // Writes the number 1 to address 0 on the EEPROM. Serial.println((EEPROM.read(0))); for(int x = 180; x >= 90; x--) // Rotates the servo to the locked position { pinMode(RedLED, HIGH); pinMode(GreenLED, LOW); myservo.write(x); delay(15); lcd.setCursor(0,1); lcd.print("DOOR CLOSED"); } } break; } } } Subscribe and Download code. Demo: 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.

  • IR Remote Controlled 4 channel relay

    In this Project TSOP1738 IR receiver to control a relay board using Arduino nano and LCD. The LCD to display the relay ON/OFF status of 4 channel relay board. The relay module is used to automate them the electrical appliances. Components required TSOP 1738 IR receiver - 1no Arduino Nano - 1 no LCD1602 with I²C - 1no IR remote (HM23) - 1no 4 Channel Relay Module (HW316)- 1no Circuit diagram 4 Channel Relay Module The four-channel relay module contains four 5V relays and the associated switching and isolating components, which makes interfacing with a microcontroller or sensor easy with minimum components and connections. The contacts on each relay are specified for 250VAC and 30VDC and 10A in each case, as marked on the body of the relays. Internal circuit Each relay on the board has the same circuit, and the input ground is common to all four channels. The driver circuit for this relay module is slightly different compared to traditional relay driving circuits since there is an optional additional layer of isolation. When the jumper is shorted, the relay and the input share the same VCC, and when it is open, a separate power supply must be provided to the JD-VCC jumper to power the relay coil and optocoupler output. The inputs for this module are active low, meaning that the relay is activated when the signal on the input header is low. This is because the indicator LED and the input of the optocoupler are connected in series to the VCC pin on one end, so the other end must be connected to the ground to enable the current flow. The optocouplers used here are the PCF817, which is a common optocoupler and can also be found in through-hole packaging. How To Use The Four-Channel Relay Module The four-channel can be used to switch multiple loads at the same time since there are four relays on the same module. This is useful in creating a central hub from where multiple remote loads can be powered. It is useful for tasks like home automation where the module can be placed in the main switchboard and can be connected to loads in other parts of the house and can be controlled from a central location using a microcontroller. In this diagram, four separate loads (represented by lightbulbs) have been connected to the NO terminals of the relay. The live wire has been connected to the common terminal of each relay. When the relays are activated, the load is connected to the live wire and is powered. This setup can be reversed by connecting the load to the NC terminal that keeps it powered on till the relay is activated. Download DATASHEET TSOP1738(SM0038) The TSOP sensor has the ability to read the output signals from home remotes like TV remote, Home theatre remote, AC remote etc. All these remotes will work with a frequency of 38kHz and this IC can pick up any IR signals process them and provide the output on pin 3. So if you are looking for a sensor to analyse, re-create or duplicate the functions of a remote then this IC will be the perfect choice for you. Also keep in mind that this series TSOP-1738 will receive only 38Khz IR signals. All remotes in India will operate in 38Khz, kindly ensure if it is the same in your country. The TSOP-1738 is an IR Receiver Sensor, which can be used to receive IR signals of 38Khz. The sensor operates on 5V and consumes around 5mA to operate. Normally the signal pin (pin 3) IC is connected to a microcontroller to analyse the IR signal received. Installing Library Infrared receiver: you need to download and install the IR library. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C 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. Refer IR decoder project for IR remote code .https://www.dofbot.com/post/ir-decoder-with-data-acquisition-tool Arduino Code #include int IRPIN = 2; IRrecv irrecv(IRPIN); decode_results results; #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display int Relay1 = 6; //Relay1 int Relay2 = 7; //Relay2 int Relay3 = 8; //Relay3 int Relay4 = 9; //Relay4 int LED = 13; //LED indiacator int STATE1 = 0; //Indicates state of Relay1 (OFFboard LED) int STATE2 =0; //Indicates state of Relay2 (OFFboard LED) int STATE3 = 0; //Indicates state of Relay3 (OFFboard LED) int STATE4 =0; //Indicates state of Relay4 (OFFboard LED) int STATE5 =0; //Indicates state of Relay1 to 5 (OFFboard LED) void setup() { Serial.begin(9600); Serial.println("Enabling IRin"); irrecv.enableIRIn(); //Starts receiving Serial.println("Enabled IRin"); pinMode(Relay1, OUTPUT); pinMode(Relay2, OUTPUT); pinMode(Relay3, OUTPUT); pinMode(Relay4, OUTPUT); pinMode(Relay1, HIGH); //Turns Relay1 OFFby default pinMode(Relay2, HIGH); //Turns Relay2 OFFby default pinMode(Relay3, HIGH); //Turns Relay3 OFFby default pinMode(Relay4, HIGH); //Turns Relay4 OFFby default pinMode(LED, OUTPUT); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.setCursor(0,0); lcd.print(" INFRARED HOME "); lcd.setCursor(0,1); lcd.print("AUTOMATION"); delay(1000); lcd.clear(); lcd.setCursor(0,0); lcd.print("RL1 RL2 RL3 RL4"); lcd.setCursor(0,1); lcd.print("ON ON ON ON "); } void loop() { if(irrecv.decode(&results)) { digitalWrite(LED, HIGH); //turn LED ON delay(250); digitalWrite(LED, LOW); //turn LED OFF Serial.println(results.value, HEX); irrecv.resume(); if(results.value==0x1FE50AF) // IR code case1 { if(STATE1 == 0) //If state is 0, relay 1 OFF { digitalWrite(Relay1, HIGH); //turn OFF Relay1 STATE1 = 1; lcd.setCursor(0,1); lcd.print("OFF"); } else if(STATE1 == 1) //If state is 1, relay 1 ON { digitalWrite(Relay1,LOW); //turn ON Relay1 STATE1 = 0; lcd.setCursor(0,1); lcd.print("ON "); } } if(results.value==0x1FED827) // IR code case2 { if(STATE2 == 0) //If state is 0, relay 2 OFF { digitalWrite(Relay2, HIGH); //turn OFF Relay2 STATE2 = 1; lcd.setCursor(4,1); lcd.print("OFF"); } else if(STATE2 == 1) //If state is 1, relay 2 ON { digitalWrite(Relay2,LOW); //turn ON Relay2 STATE2 = 0; lcd.setCursor(4,1); lcd.print("ON "); } } if(results.value==0x1FEF807) // IR code case3 { if(STATE3 == 0) //If state is 0, relay 3 OFF { digitalWrite(Relay3, HIGH); //turn OFF Relay3 STATE3 = 1; lcd.setCursor(8,1); lcd.print("OFF"); } else if(STATE3 == 1) //If state is 1, relay 3 ON { digitalWrite(Relay3,LOW); //turn ON Relay3 STATE3 = 0; lcd.setCursor(8,1); lcd.print("ON "); } } if(results.value==0x1FE30CF) // IR code case3 { if(STATE4 == 0) //If state is 0, relay 4 OFF { digitalWrite(Relay4, HIGH); //turn OFF Relay4 STATE4 = 1; lcd.setCursor(12,1); lcd.print("OFF"); } else if(STATE4 == 1) //If state is 1, relay 4 ON { digitalWrite(Relay4,LOW); //turn ON Relay4 STATE4 = 0; lcd.setCursor(12,1); lcd.print("ON "); } } irrecv.resume(); //Ready to receive next data } } Subscribe and Download code. Serial monitor After a successful upload, open the Serial Monitor at a baud rate of 9600. see the IR decoder received code result on Serial monitor. Demo

  • IR Decoder with Data Acquisition tool

    Here to learn TSOP1738 IR receiver to build an IR Remote Decoder using Arduino nano and LCD. The LCD to display the decoded code – the number for pressed button on IR remote. The hex code for every button will be logged to Microsoft Excel Sheet from the PLX-DAQ release 2. Components required TSOP 1738 IR receiver - 1no Arduino Nano - 1 no LCD1602 with I²C - 1no Circuit diagram TSOP1738(SM0038) The TSOP sensor has the ability to read the output signals from home remotes like TV remote, Home theatre remote, AC remote etc. All these remotes will work with a frequency of 38kHz and this IC can pick up any IR signals process them and provide the output on pin 3. So if you are looking for a sensor to analyse, re-create or duplicate the functions of a remote then this IC will be the perfect choice for you. Also keep in mind that this series TSOP-1738 will receive only 38Khz IR signals. All remotes in India will operate in 38Khz, kindly ensure if it is the same in your country. The TSOP-1738 is an IR Receiver Sensor, which can be used to receive IR signals of 38Khz. The sensor operates on 5V and consumes around 5mA to operate. Normally the signal pin (pin 3) IC is connected to a microcontroller to analyse the IR signal received. TSOP1738 Pin Configuration Pin Number Pin Name Description 1 Ground Connected to the Ground of circuit 2 Vcc Typically connect to +5V, maximum of 6V can be given 3 Signal The signal pin gives out the sequence based on the IR signal detected Download DATASHEET PLX-DAQ PLX-DAQ is a Parallax microcontroller data acquisition add-on tool for Microsoft Excel and acquires up to 26 channels of data from any Parallax microcontrollers and drops the numbers into columns as they arrive. PLX-DAQ provides easy spreadsheet analysis of data collected in the field, laboratory analysis of sensors and real-time equipment monitoring. Any of microcontrollers connected to any sensor and the serial port of a PC can now send data directly into Excel. PLX-DAQ has the following features: Plot or graph data as it arrives in real-time using Microsoft Excel Record up to 26 columns of data Mark data with real-time (hh:mm:ss) or seconds since reset Read/Write any cell on a worksheet Read/Set any of 4 checkboxes on control the interface Example code for the BS2, SX (SX/B) and Propeller available Baud rates up to 128K Supports Com1-15 Download PLX-DAQ Installing Library Infrared receiver: you need to download and install the IR library. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C 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. Arduino Code #include int IRPIN = 2; IRrecv irrecv(IRPIN); decode_results result; int RemoteButton = 0; #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { Serial.begin(9600); Serial.println("Enabling IRin"); irrecv.enableIRIn(); Serial.println("Enabled IRin"); Initialize_streamer(); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.setCursor(0,0); lcd.print("INFRARED DECODER"); } void loop() { if (irrecv.decode(&result)) { RemoteButton = RemoteButton+1; Serial.print("Value: "); Serial.println(result.value, HEX); lcd.setCursor(0,1); lcd.print("Received: "); lcd.setCursor(9,1); lcd.print(result.value, HEX); Write_streamer(); irrecv.resume(); } delay(500); } void Initialize_streamer() { Serial.println("CLEARDATA"); //clears up any data left from previous projects Serial.println("LABEL,Hex Code, RemoteButton"); //always write LABEL, to indicate it as first line } void Write_streamer() { Serial.print("DATA"); //always write "DATA" to Indicate the following as Data Serial.print(","); //Move to next column using a "," Serial.print(result.value, HEX); //Store date on Excel Serial.print(","); //Move to next column using a "," Serial.print(RemoteButton); //Store date on Excel Serial.print(","); //Move to next column using a "," Serial.println(); //End of Row move to next row } Subscribe and Download code. Now open the ‘PLX-DAQ spreadsheet’ file from the Desktop/Laptop. If macros are disabled on your Excel, then Click on Options->Enable the content -> Finish -> OK to Enable the Macros. Subscribe and Download PLX-DAQ . Subscribe and Download EXCEL Demo

  • 9999second timer using Rotary encoder

    In this tutorial we will see how to create a adjustable timer using rotary encoder and buzzer for Timer end with the Arduino board and the TM1637 display. Components required Arduino Nano - 1 no TM1637 module - 1 no Toggle switch - 1 no 5V/3.3V Power module - 1 no Buzzer - 1 no Circuit diagram TM1637 TM1637 seven segment modules is a ready made multiplexed seven segment display with 4 digits. The driver IC is TM1637; It has 4pin control there are GND, VCC, DIO, CLK. only two signal lines can make MCU control four Digit 7-segments LED can be used to display decimal, letters and so on. The 7segment LED Display has common anode type. TM1637 4-Digit 7-Segment Display Specifications Operating voltage 3.3 – 5 V Current draw-80 mA Operating temperature-10 – 80 °C Interfacing TM1637 with the arduino: So the first thing you want to do is connect the clock pin to any pin on the Arduino. CLK clock pin of the TM1637 with the digital pin 3 of the arduno. DIO pin of the TM1637 with digital pin 2 of the arduino. VCC of the TM1637 with the 3.3V of the Power module. Gnd of the TM1637 with the ground of the Power module. Installing Library 7segment: you need to Download and install the TM1637 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. Refer Counter project for testing of TM1637 module. https://www.dofbot.com/post/up-down-counter-using-7segment-display Arduino Code // include libraries #include #include // Module connection pins (Digital Pins) #define CLK 2 #define DIO 3 TM1637Display display(CLK, DIO); byte D1=0;// seconds s byte D2=0;// Second x 10 byte D3=0;// Second x 100 byte D4=0;// Second x 1000 int counter=0; int n=0; #define Toggle 5 //Toggle Switch D5 #define Buzzer 9 // Buzzer #define RotSW 11 // Rotary Encoder #define RotdtB 12 //Rotary Encoder "B" #define RotclkA 10 //Rotary Encoder "A" void setup() { pinMode(Toggle, INPUT_PULLUP);//Toggle Switch pinMode(RotclkA, INPUT_PULLUP);//Rotary Encoder CLK pinMode(RotSW, INPUT_PULLUP);// Rotary Encoder SW pinMode(RotdtB, INPUT_PULLUP);//Rotary Encoder DT pinMode(Buzzer,OUTPUT );//Buzzer display.setBrightness(7); display.showNumberDec(0, true); delay(1000); display.clear(); delay(1000); display.showNumberDec(0, true); digitalWrite((Buzzer), HIGH); delay(1000); digitalWrite((Buzzer), LOW); } void loop() { // set timer // set s. do{ D1= SCounter(); //display.clear(); display.showNumberDec(D1); //Display the n value; delay(250); }while(digitalRead(RotSW)==HIGH);//Push to Rotary delay(250); counter=0; // set Second x 10 display.showNumberDec(D1,true,2,2);//Display D1 do{ D2= SCounter(); n=D2*10+D1; //display.clear(); display.showNumberDec(n , true,2,2); //Display the n value; delay(250); }while(digitalRead(RotSW)==HIGH);//Push to Rotary delay(250); counter=0; // set Second x 100 do{ D3= SCounter(); n=D3*100+D2*10+D1; //display.clear(); display.showNumberDec(n , true, 3, 1); //Display the n value; delay(250); }while(digitalRead(RotSW)==HIGH);//Push to Rotary delay(250); counter=0; // set Second x 1000 do{ D4= SCounter(); n=D4*1000+D3*100+D2*10+D1; //display.clear(); display.showNumberDec(n , true, 4,0); //Display the n value; delay(250); }while(digitalRead(RotSW)==HIGH);//Push to Rotary delay(250); counter=0; //Out of set routine n=D4*1000+D3*100+D2*10+D1;//compute "n" if(n!=0){ do{//Repeat set value n=D4*1000+D3*100+D2*10+D1;//compute "n" //display set "n" display.showNumberDec(n); while(0==digitalRead(RotSW));//Push Rotary to start while(1==digitalRead(RotSW)); delay(50); do{// decrease time //display current "n" display.showNumberDec(n); while(millis() % 1000 != 0);//time base, 1second n=n-1; }while(n!=0); display.showNumberDec(n);//display n=0 digitalWrite(Buzzer,HIGH);// start beep delay(1000); digitalWrite(Buzzer,LOW); // stop beep }while(digitalRead(Toggle)==LOW);//"Toggle" to GND D1=0; D2=0; D3=0; D4=0; } } byte SCounter(){ // Rotary encoder routine while(digitalRead(RotSW) &digitalRead(RotdtB) & digitalRead(RotclkA)==1); if(digitalRead(RotSW)==0){ return counter; } switch(digitalRead(RotclkA)) { case HIGH: while(digitalRead(RotclkA)==0); while(digitalRead(RotdtB)==0); counter ++; counter=counter%10; break; case LOW: while(digitalRead(RotdtB)==0); while(digitalRead(RotclkA)==0); counter --; if(counter==-1){ counter=9;//left begin with 9 } counter=abs(counter)%10; break; } return counter; } Subscribe and Download code. Demo:

  • Simple Kitchen timer using 7segment display & Arduino

    In this tutorial we will see how to create a Timer start, UP/Down setting using push button and buzzer for Timer end with the Arduino board and the TM1637 display Components required Arduino Nano - 1 no TM1637 module - 1 no Push Button switch - 3 no 5V/3.3V Power module - 1 no Buzzer - 1 no Circuit diagram TM1637 TM1637 seven segment modules is a ready made multiplexed seven segment display with 4 digits. The driver IC is TM1637; It has 4pin control there are GND, VCC, DIO, CLK. only two signal lines can make MCU control four Digit 7-segments LED can be used to display decimal, letters and so on. The 7segment LED Display has common anode type. TM1637 4-Digit 7-Segment Display Specifications Operating voltage 3.3 – 5 V Current draw-80 mA Operating temperature-10 – 80 °C Interfacing TM1637 with the arduino: So the first thing you want to do is connect the clock pin to any pin on the Arduino. CLK clock pin of the TM1637 with the digital pin 3 of the arduno. DIO pin of the TM1637 with digital pin 2 of the arduino. VCC of the TM1637 with the 3.3V of the Power module. Gnd of the TM1637 with the ground of the Power module. Installing Library 7segment: you need to Download and install the TM1637 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. Refer Counter project for testing of TM1637 module. https://www.dofbot.com/post/up-down-counter-using-7segment-display Arduino Code #include // Define the connections pins for display #define CLK 2 #define DIO 3 // Define other pin connections #define UP_BUTTON 8 #define DOWN_BUTTON 9 #define START_BUTTON 4 #define BUZZER 5 int duration; // Duration in seconds // Create display object of type TM1637Display: TM1637Display display = TM1637Display(CLK, DIO); // Set the individual segments for the word displays: const uint8_t seg_end[] = { SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E SEG_C | SEG_E | SEG_G, // n SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d 0x00 // All off }; const uint8_t seg_go[] = { SEG_A | SEG_C | SEG_D | SEG_F | SEG_G, // s SEG_D | SEG_E | SEG_F | SEG_G, // t 0x00, // All off 0x00 // All off }; void setup() { pinMode(UP_BUTTON, INPUT_PULLUP); pinMode(DOWN_BUTTON, INPUT_PULLUP); pinMode(START_BUTTON, INPUT_PULLUP); pinMode(BUZZER, OUTPUT); duration = 10; // Default to 10 seconds display.setBrightness(5); // 0 to 7 change if required ShowTime(duration); } void loop() { // Function will checks for time change buttons and only return // when start button pressed WaitForStart(); // Start the duration timer TimeDuration(); } void WaitForStart(){ // Check for button presses every 0.15 seconds while (digitalRead(START_BUTTON) == HIGH){ // Check if up or down has been pressed //if time > 60 then increment by 10 seconds if (digitalRead(UP_BUTTON) == LOW){ if (duration < 60){ duration++; } else{ duration += 10; } ShowTime(duration); } if (digitalRead(DOWN_BUTTON) == LOW){ if (duration > 60){ duration -= 10; } else{ duration--; } ShowTime(duration); } delay(150); } // Start button has been pressed tone(BUZZER, 1500, 100); display.clear(); display.setSegments(seg_go); } void TimeDuration(){ // While loop will continue until time up unsigned long startTime = millis(); unsigned long timer = 1000ul * duration; // Repeatedly check if time is up while ((millis() - startTime) <= timer){ // Calculate time elapsed in seconds int elapsed = int((millis() - startTime)/1000); // Only start to display countdown after 3 seconds if ((millis() - startTime) > 3000){ ShowTime(duration - elapsed); } } // Time up tone(BUZZER, 500, 5000); display.clear(); display.setSegments(seg_end); // Wait 5 seconds and reset display delay(5000); // Show duration for next player ShowTime(duration); } void ShowTime(int value){ static int lastTime; // Update the display if time has changed if (lastTime != value) { lastTime = value; int iMinutes = value / 60; int iSeconds = value - (iMinutes * 60); // Show on 4 digit display uint16_t number = iMinutes * 100 + iSeconds; display.showNumberDecEx(number, 0b01000000, true, 4, 0); } } Subscribe and Download code. Demo

  • UP/DOWN counter using 7segment Display

    In this tutorial, you will learn how you can test TM1637 4-digit 7-segment display and Counter function with adjusting time delay. Components required Arduino Nano - 1 no TM1637 module - 1 no Push Button switch - 2 no 5V/3.3V Power module - 1 no Circuit diagram TM1637 TM1637 seven segment modules is a ready made multiplexed seven segment display with 4 digits. The driver IC is TM1637; It has 4pin control there are GND, VCC, DIO, CLK. only two signal lines can make MCU control four Digit 7-segments LED can be used to display decimal, letters and so on. The 7segment LED Display has common anode type. TM1637 4-Digit 7-Segment Display Specifications Operating voltage 3.3 – 5 V Current draw-80 mA Operating temperature-10 – 80 °C Interfacing TM1637 with the arduino: So the first thing you want to do is connect the clock pin to any pin on the Arduino. CLK clock pin of the TM1637 with the digital pin 3 of the arduno. DIO pin of the TM1637 with digital pin 2 of the arduino. VCC of the TM1637 with the 5V of the arduino. Gnd of the TM1637 with the ground of the arduino. Counter In this example we use the TM1637 display module to make a simple counter with two push buttons. The setup is as shown below where the buttons are connected to pin 8 and 9 of Arduino nano. This example shows the commonest basic functions of the TM1637Display.h library which are; setBrightness(): for setting the brightness of the display. There are seven levels of brightness therefore the value can be in 0x0a to 0x0f. showNumberDec(): this is the most used function and it is for displaying decimal number digits. This function can take four arguments that is, showNumberDec (int num, bool leading_zero, uint8_t length, uint8_t pos), the first argument is the number to be displayed, the second is determining leading zeros and can either be true or false, the third argument is the number of digits to be displayed and the last argument is for selecting the position where the number to be displayed should begin from. For example display.showNumberDec(25,false,2,1) displays the number 25 without leading zeros on the second and third digit Installing Library 7segment: you need to Download and install the TM1637 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. Arduino Code First testing the TM1637 display check. #include #include // Module connection pins (Digital Pins) #define CLK 2 #define DIO 3 // The amount of time (in milliseconds) between tests #define TEST_DELAY 500 const uint8_t SEG_DONE[] = { SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d SEG_D | SEG_C | SEG_F | SEG_E | SEG_G, // b SEG_C | SEG_D | SEG_E | SEG_G, // O SEG_D | SEG_E | SEG_F | SEG_G, // t }; TM1637Display display(CLK, DIO); void setup() { } void loop() { int k; uint8_t data[] = { 0xff, 0xff, 0xff, 0xff }; uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 }; display.setBrightness(0x0f); // All segments on display.setSegments(data); delay(TEST_DELAY); // Selectively set different digits data[0] = display.encodeDigit(0); data[1] = display.encodeDigit(1); data[2] = display.encodeDigit(2); data[3] = display.encodeDigit(3); display.setSegments(data); delay(TEST_DELAY); /* for(k = 3; k >= 0; k--) { display.setSegments(data, 1, k); delay(TEST_DELAY); } */ display.clear(); display.setSegments(data+2, 2, 2); delay(TEST_DELAY); display.clear(); display.setSegments(data+2, 2, 1); delay(TEST_DELAY); display.clear(); display.setSegments(data+1, 3, 1); delay(TEST_DELAY); // Show decimal numbers with/without leading zeros display.showNumberDec(0, false); // Expect: ___0 delay(TEST_DELAY); display.showNumberDec(0, true); // Expect: 0000 delay(TEST_DELAY); display.showNumberDec(1, false); // Expect: ___1 delay(TEST_DELAY); display.showNumberDec(1, true); // Expect: 0001 delay(TEST_DELAY); display.showNumberDec(301, false); // Expect: _301 delay(TEST_DELAY); display.showNumberDec(301, true); // Expect: 0301 delay(TEST_DELAY); display.clear(); display.showNumberDec(14, false, 2, 1); // Expect: _14_ delay(TEST_DELAY); display.clear(); display.showNumberDec(4, true, 2, 2); // Expect: __04 delay(TEST_DELAY); display.showNumberDec(-1, false); // Expect: __-1 delay(TEST_DELAY); display.showNumberDec(-12); // Expect: _-12 delay(TEST_DELAY); display.showNumberDec(-999); // Expect: -999 delay(TEST_DELAY); display.clear(); display.showNumberDec(-5, false, 3, 0); // Expect: _-5_ delay(TEST_DELAY); display.showNumberHexEx(0xf1af); // Expect: f1Af delay(TEST_DELAY); display.showNumberHexEx(0x2c); // Expect: __2C delay(TEST_DELAY); display.showNumberHexEx(0xd1, 0, true); // Expect: 00d1 delay(TEST_DELAY); display.clear(); display.showNumberHexEx(0xd1, 0, true, 2); // Expect: d1__ delay(TEST_DELAY); // Run through all the dots for(k=0; k <= 4; k++) { display.showNumberDecEx(0, (0x80 >> k), true); delay(TEST_DELAY); } // Brightness Test for(k = 0; k < 4; k++) data[k] = 0xff; for(k = 0; k < 7; k++) { display.setBrightness(k); display.setSegments(data); delay(TEST_DELAY); } // On/Off test for(k = 0; k < 4; k++) { display.setBrightness(7, false); // Turn off display.setSegments(data); delay(TEST_DELAY); display.setBrightness(7, true); // Turn on display.setSegments(data); delay(TEST_DELAY); } // Done! display.setSegments(SEG_DONE); while(1); } Subscribe and Download code. Next UP/DOWN Counter code #include #define UP 8 #define DOWN 9 const int CLK = 2; //Set the CLK pin connection to the display const int DIO = 3; //Set the DIO pin connection to the display const uint8_t blank[] = {0x00, 0x00, 0x00,0x00}; TM1637Display display(CLK, DIO); //set up the 4-Digit Display. int num = 0; // The amount of time (in milliseconds) between counter #define COUNTER_DELAY 1000 void setup() { pinMode(UP, INPUT_PULLUP); pinMode(DOWN, INPUT_PULLUP); display.setBrightness(0x0f); //set the diplay to brightness display.setSegments(blank);//clear display } void loop() { display.showNumberDec(num, true, 4, 0); delay(COUNTER_DELAY); if( digitalRead(UP) ) { // if the UP button is presses num++; // increment 'num' if(num > 9999) num = 0; } if( digitalRead(DOWN) ) { // if the DOWN button is presses num--; // decrement 'num' if(num < 0) num = 9999; } } Subscribe and Download code. Demo

  • Temperature indicator using 7segment display & Arduino Nano

    In this tutorial, you will learn how you can test TM1637 4-digit 7-segment displays with Arduino and Temperature sensor DHT11 interface. Components required Arduino Nano - 1 no TM1637 module - 1 no DHT 11 - 1 no 5V/3.3V Power module - 1 no Circuit diagram TM1637 TM1637 seven segment modules is a ready made multiplexed seven segment display with 4 digits. The driver IC is TM1637; It has 4pin control there are GND, VCC, DIO, CLK. only two signal lines can make MCU control four Digit 7-segments LED can be used to display decimal, letters and so on. The 7segment LED Display has common anode type. TM1637 4-Digit 7-Segment Display Specifications Operating voltage 3.3 – 5 V Current draw-80 mA Operating temperature-10 – 80 °C Interfacing TM1637 with the arduino: So the first thing you want to do is connect the clock pin to any pin on the Arduino. CLK clock pin of the TM1637 with the digital pin 3 of the arduno. DIO pin of the TM1637 with digital pin 2 of the arduino. VCC of the TM1637 with the 5V of the arduino. Gnd of the TM1637 with the ground of the arduino. DHT11 Connecting DHT11/DHT22/AM2302 sensor to Arduino nano is fairly simple. Connect VCC pin on the sensor to the 3.3V pin on the Arduino nano and ground to ground. Also connect Data pin on the sensor to D5 pin of the Arduino nano. Installing Library 7segment: you need to Download and install the TM1637 library. Temperature sensor: you need to Download and install the DHT11 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. Arduino Code First testing the TM1637 display check. #include #include // Module connection pins (Digital Pins) #define CLK 2 #define DIO 3 // The amount of time (in milliseconds) between tests #define TEST_DELAY 500 const uint8_t SEG_DONE[] = { SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d SEG_D | SEG_C | SEG_F | SEG_E | SEG_G, // b SEG_C | SEG_D | SEG_E | SEG_G, // O SEG_D | SEG_E | SEG_F | SEG_G, // t }; TM1637Display display(CLK, DIO); void setup() { } void loop() { int k; uint8_t data[] = { 0xff, 0xff, 0xff, 0xff }; uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 }; display.setBrightness(0x0f); // All segments on display.setSegments(data); delay(TEST_DELAY); // Selectively set different digits data[0] = display.encodeDigit(0); data[1] = display.encodeDigit(1); data[2] = display.encodeDigit(2); data[3] = display.encodeDigit(3); display.setSegments(data); delay(TEST_DELAY); /* for(k = 3; k >= 0; k--) { display.setSegments(data, 1, k); delay(TEST_DELAY); } */ display.clear(); display.setSegments(data+2, 2, 2); delay(TEST_DELAY); display.clear(); display.setSegments(data+2, 2, 1); delay(TEST_DELAY); display.clear(); display.setSegments(data+1, 3, 1); delay(TEST_DELAY); // Show decimal numbers with/without leading zeros display.showNumberDec(0, false); // Expect: ___0 delay(TEST_DELAY); display.showNumberDec(0, true); // Expect: 0000 delay(TEST_DELAY); display.showNumberDec(1, false); // Expect: ___1 delay(TEST_DELAY); display.showNumberDec(1, true); // Expect: 0001 delay(TEST_DELAY); display.showNumberDec(301, false); // Expect: _301 delay(TEST_DELAY); display.showNumberDec(301, true); // Expect: 0301 delay(TEST_DELAY); display.clear(); display.showNumberDec(14, false, 2, 1); // Expect: _14_ delay(TEST_DELAY); display.clear(); display.showNumberDec(4, true, 2, 2); // Expect: __04 delay(TEST_DELAY); display.showNumberDec(-1, false); // Expect: __-1 delay(TEST_DELAY); display.showNumberDec(-12); // Expect: _-12 delay(TEST_DELAY); display.showNumberDec(-999); // Expect: -999 delay(TEST_DELAY); display.clear(); display.showNumberDec(-5, false, 3, 0); // Expect: _-5_ delay(TEST_DELAY); display.showNumberHexEx(0xf1af); // Expect: f1Af delay(TEST_DELAY); display.showNumberHexEx(0x2c); // Expect: __2C delay(TEST_DELAY); display.showNumberHexEx(0xd1, 0, true); // Expect: 00d1 delay(TEST_DELAY); display.clear(); display.showNumberHexEx(0xd1, 0, true, 2); // Expect: d1__ delay(TEST_DELAY); // Run through all the dots for(k=0; k <= 4; k++) { display.showNumberDecEx(0, (0x80 >> k), true); delay(TEST_DELAY); } // Brightness Test for(k = 0; k < 4; k++) data[k] = 0xff; for(k = 0; k < 7; k++) { display.setBrightness(k); display.setSegments(data); delay(TEST_DELAY); } // On/Off test for(k = 0; k < 4; k++) { display.setBrightness(7, false); // Turn off display.setSegments(data); delay(TEST_DELAY); display.setBrightness(7, true); // Turn on display.setSegments(data); delay(TEST_DELAY); } // Done! display.setSegments(SEG_DONE); while(1); } Subscribe and Download code. Next Temperature indication // Include the libraries #include #include #include // Define the connections pins #define CLK 2 #define DIO 3 #define DHTPIN 5 // Create variable int temperature_celsius; int temperature_fahrenheit; // Create °C symbol const uint8_t celsius[] = { SEG_A | SEG_B | SEG_F | SEG_G, // Circle SEG_A | SEG_D | SEG_E | SEG_F // C }; // Create °F symbol const uint8_t fahrenheit[] = { SEG_A | SEG_B | SEG_F | SEG_G, // Circle SEG_A | SEG_E | SEG_F | SEG_G // F }; #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302) // Create display object of type TM1637Display TM1637Display display = TM1637Display(CLK, DIO); // Create dht object of type DHT: DHT dht = DHT(DHTPIN, DHTTYPE); void setup() { // Set the display brightness (0-7) display.setBrightness(5); // Clear the display display.clear(); // Setup sensor dht.begin(); } void loop() { // Read the temperature as Celsius and Fahrenheit temperature_celsius = dht.readTemperature(); temperature_fahrenheit = dht.readTemperature(true); // Display the temperature in celsius format display.showNumberDec(temperature_celsius, false, 2, 0); display.setSegments(celsius, 2, 2); delay(1000); // Display the temperature in fahrenheit format display.showNumberDec(temperature_fahrenheit, false, 2, 0); display.setSegments(fahrenheit, 2, 2); delay(1000); } Subscribe and Download code. Demo

  • Random data Sending & Receiving Using NRF24L01 Wireless Transceiver

    In this tutorial to learn sending and receiving random data from NRF24L01 Wireless Transceiver using Arduino nano. we will learn how to make Radio Frequency wireless communication using the nRF24L01+PA transceiver module is designed to operate in 2.4 GHz worldwide ISM frequency band and uses GFSK modulation for data transmission. The data transfer rate can be one of 250kbps, 1Mbps and 2Mbps. The NRF24L01 module is a low-cost ultra-low power, bi-directional transceiver module. The module can achieve data rates as high as 2Mbits! and uses a high-speed SPI interface in order to communicate with the Arduino and IOT. Components required Transmitter: Arduino Nano - 1 no LCD1602 with I²C - 1no nRF24L01+PA- 1no 3.3V breakup module -1no Receiver: Arduino Nano - 1 no LCD1602 with I²C - 1no nRF24L01+PA- 1no 3.3V breakup module -1no Circuit diagram The diagram shows the detail connections of NRF24L01module with Arduino. Connect VCC of NRF24L01 module to Arduino Nano’s 3V3 pin Connect GND of NRF24L01 module to Arduino Nano’s GND pin Connect CE of NRF24L01 module to Arduino Nano’s Digital Pin 7 Connect CSN of NRF24L01 module to Arduino Nano’s Digital Pin 8 Connect SCK of NRF24L01 module to Arduino Nano’s Digital Pin 13 Connect MOS of NRF24L01 module to Arduino Nano’s Digital Pin 11 Connect MISO of NRF24L01 module to Arduino Nano’s Digital 12 NRF24L01 Wireless RF Module Refer blog for more detail: https://www.dofbot.com/post/nrf24l01-wireless-temperature-monitor-with-bluetooth Transmitter Circuit: The transmitter circuit side consists of an Arduino Nano, nRF24L01+PA module and 1602 LCD with I2C module. Arduino generate random data and sends it to the nRF24L01 Transmitter. Then the nRF transmitter circuit transmits the data into the air. Receiver Circuit: The receiver circuit side consists of an Arduino Nano, nRF24L01+PA module and 1602 LCD with I2C module. The nRF module receives the random data from the transmitter and sends it to LCD display through Arduino. Installing Library NRF24L01: you need to Download and install the RF library. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C 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. Arduino Code Transmitter Code #include "nRF24L01.h" //NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24 #include "RF24.h" #include "SPI.h" #include LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x3F for a 16 chars and 2 line display int SentMessage[1] = {000}; // Used to store value before being sent through the NRF24L01 RF24 radio(7, 8); // NRF24L01 used SPI pins + Pin 9 and 10 on the NANO const byte address[6] = "00001"; void setup(void) { lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("Initializing"); lcd.setCursor(0, 1); lcd.print("Transmitter"); delay(2000); radio.begin(); // Start the NRF24L01 // Max power radio.setPALevel( RF24_PA_MAX ) ; // Min speed (for better range I presume) radio.setDataRate( RF24_250KBPS ) ; // 8 bits CRC radio.setCRCLength( RF24_CRC_8 ) ; // increase the delay between retries & # of retries radio.setRetries(15, 15); radio.setAutoAck(false); radio.openWritingPipe(address); radio.setPALevel(RF24_PA_MIN); radio.stopListening(); } void loop(void) { int num ; num = random(0, 100); SentMessage[0] = num; DataToLcd((String) SentMessage[0], 0); radio.write(SentMessage, 1); // Send value through NRF24L01 delay(1000); } void DataToLcd(String message1, int delayValue) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("NRF Transmitter"); lcd.setCursor(0, 1); lcd.print("Sending data:"); lcd.setCursor(13, 1); lcd.print(message1); delay(delayValue); } Subscribe and Download code. Transmitter Receiver Code #include "nRF24L01.h" //NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24 #include "RF24.h" #include "SPI.h" #include LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x3F for a 16 chars and 2 line display int SentMessage[1] = {000}; // Used to store value before being sent through the NRF24L01 RF24 radio(7, 8); // NRF24L01 used SPI pins + Pin 9 and 10 on the NANO const byte address[6] = "00001"; void setup(void) { lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("Initializing"); lcd.setCursor(0, 1); lcd.print("Transmitter"); delay(2000); radio.begin(); // Start the NRF24L01 // Max power radio.setPALevel( RF24_PA_MAX ) ; // Min speed (for better range I presume) radio.setDataRate( RF24_250KBPS ) ; // 8 bits CRC radio.setCRCLength( RF24_CRC_8 ) ; // increase the delay between retries & # of retries radio.setRetries(15, 15); radio.setAutoAck(false); radio.openWritingPipe(address); radio.setPALevel(RF24_PA_MIN); radio.stopListening(); } void loop(void) { int num ; num = random(0, 100); SentMessage[0] = num; DataToLcd((String) SentMessage[0], 0); radio.write(SentMessage, 1); // Send value through NRF24L01 delay(1000); } void DataToLcd(String message1, int delayValue) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("NRF Transmitter"); lcd.setCursor(0, 1); lcd.print("Sending data:"); lcd.setCursor(13, 1); lcd.print(message1); delay(delayValue); } Subscribe and Download code. Receiver Demo Code description we need to include the basic SPI and the newly installed RF24 libraries and create an RF24 object. The two arguments here are the CSN and CE pins. RF24 radio(7, 8); // CE, CSN Next we need to create a byte array which will represent the address, or the so called pipe through which the two modules will communicate. const byte address[6] = "00001"; We can change the value of this address to any 5 letter string and this enables to choose to which receiver we will talk, so in our case we will have the same address at both the receiver and the transmitter.

  • nRF24L01 Wireless Temperature Monitor with Bluetooth

    In this tutorial, we will learn how to make Radio Frequency wireless communication using the nRF24L01+PA transceiver module that operates on 2.4 - 2.5 GHz (ISM band) with range 1000m distance. An arduino based wireless communication and interface DHT 11 temperature Monitor. The transmitter circuit side consists of an Arduino Nano, nRF24L01+PA module and DHT11 Temperature sensor. Arduino gets data from the DHT11 sensor and sends it to the nRF24L01 Transmitter. Then the nRF transmitter circuit transmits the data into the air. The receiver circuit side consists of an Arduino Nano, nRF24L01+PA module, 1602 LCD with I2C module and Bluetooth HC-05. The nRF module receives the data from the transmitter and sends it to Arduino. An arduino send data to Bluetooth. Components required Transmitter: Arduino Nano - 1 no DHT 11 - 1 no nRF24L01+PA- 1no Receiver: Arduino Nano - 1 no Bluetooth HC-05 - 1 no LCD1602 with I²C - 1no nRF24L01+PA- 1no Circuit diagram Transmitter Circuit: Receiver Circuit: NRF24L01 Wireless RF Module The NRF24L01 module is the latest in RF modules. This module uses the 2.4GHz transceiver from Nordic Semiconductor, the NRF24L01+. This transceiver IC operates in the 2.4GHz band and has many new features! Take all the coolness of the 2.4GHz NRF24L01+PA+LNA SMA Wireless Transceiver Antenna and add some extra pipelines, buffers, and an auto-retransmit feature. This board features a reverse polarized SMA connector for maximum RF range. And there is PA and LNA circuit on board, with the external antenna it can reach long distance than the one without these parts. This module comes with the 2.4G antenna (2DB), with a 250Kbps transmission rate on open-air it can reach the 800-1K meters communication distance. Circuit Diagram for nRF24L01 PA You can easily add it with your own MCU/ARM/PIC/AVR/STM32 system! What’s more, this nRF24L01+ module is designed with the Power amplifier and SMA antenna This allowed you to use the wireless communication up to 1000 meters! (No barrier) Features : It uses 2.4GHz global open ISM band, with license-free. Transmit power is greater than +20 dBm. Support six-channel data reception. 2Mbit/s speed makes high-quality VoIP possible Multi-frequency points: 125 frequency points meet the needs of multi-point communications and frequency hopping. Low cost: integrated with high-speed signal processing parts associated with RF protocol, such as: automatically re-send lost packets and generate acknowledge signal; SPI interface facilitates the communication with MCU I/O port. Facilitate the development for customers, without development RF part. Software programming is fully compatible with NRF24L01 modules. The PA stands for Power Amplifier. It merely boosts the power of the signal being transmitted from the nRF24L01+ chip. Whereas, LNA stands for Low-Noise Amplifier. The function of the LNA is to take the extremely weak and uncertain signal from the antenna (usually on the order of microvolts or under -100 dBm) and amplify it to a more useful level (usually about 0.5 to 1V) The low-noise amplifier (LNA) of the receive path and the power amplifier (PA) of the transmit path connect to the antenna via a duplexer, which separates the two signals and prevents the relatively powerful PA output from overloading the sensitive LNA input. RF Channel Frequency The nRF24L01+ transceiver module transmits and receives data on a certain frequency called Channel. Also in order for two or more transceiver modules to communicate with each other, they need to be on the same channel. This channel could be any frequency in the 2.4 GHz ISM band or to be more precise, it could be between 2.400 to 2.525 GHz (2400 to 2525 MHz). Each channel occupies a bandwidth of less than 1MHz. This gives us 125 possible channels with 1MHz spacing. So, the module can use 125 different channels which give a possibility to have a network of 125 independently working modems in one place. ie The channel occupies a bandwidth of less than 1MHz at 250kbps and 1Mbps air data rate. However at 2Mbps air data rate, 2MHz bandwidth is occupied (wider than the resolution of RF channel frequency setting). So, to ensure non-overlapping channels and reduce cross-talk in 2Mbps mode, you need to keep 2MHz spacing between two channels. nRF24L01+ Multiceiver Network The nRF24L01+ provides a feature called Multiceiver. It’s an abbreviation for Multiple Transmitters Single Receiver. In which each RF channel is logically divided into 6 parallel data channels called Data Pipes. In other words, a data pipe is a logical channel in the physical RF Channel. Each data pipe has its own physical address (Data Pipe Address) and can be configured. The primary receiver acting as a hub receiver collecting information from 6 different transmitter nodes simultaneously. The hub receiver can stop listening any time and acts as a transmitter. But this can only be done one pipe/node at a time. Arduino Nano We have a complete understanding of how nRF24L01+ transceiver module works, we can begin hooking it up to our Arduino Nano Connect VCC pin on the module to 3.3V on the Arduino and GND pin to ground. The pins CSN and CE can be connected to any digital pin on the Arduino. In our case, it’s connected to digital pin#7 and #8 respectively. Now we are remaining with the pins that are used for SPI communication. As nRF24L01+ transceiver module require a lot of data transfer, they will give the best performance when connected up to the hardware SPI pins on a microcontroller. The hardware SPI pins are much faster than ‘bit-banging’ the interface code using another set of pins. Note that each Arduino Board has different SPI pins which should be connected accordingly. For Arduino boards such as the UNO/Nano V3.0 those pins are digital 13 (SCK), 12 (MISO) and 11 (MOSI). 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. DHT11: you need to Download and install the DHT11 library. Adafruit Unified Sensor Download and install the sensor library. Adafruit BusIO Download and install the signal library. NRF24L01: you need to Download and install the RF library. After installing the required libraries, copy the following code to your Arduino IDE. Arduino Code Transmitter Code #include #include #include #include "DHT.h" const byte address[6] = "00001"; #define DHTPIN 2 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); RF24 radio(7, 8); // CN and CSN pins of nrf struct MyData { byte h; byte t; }; MyData data; void setup() { Serial.begin(9600); dht.begin(); radio.begin(); radio.setAutoAck(false); radio.setDataRate(RF24_250KBPS); radio.openWritingPipe(address); radio.setPALevel(RF24_PA_MIN); radio.stopListening(); } void loop() { data.h = dht.readHumidity(); data.t = dht.readTemperature(); if (isnan(data.h) || isnan(data.t)){ Serial.println(F("Failed to read from DHT sensor!")); return; } Serial.print("Humidity: "); Serial.print(data.h); Serial.print("Temperature: "); Serial.print(data.t); radio.write(&data, sizeof(MyData)); delay(1000); } Subscribe and Download code. Transmitter Receiver Code #include #include #include #include #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display const byte address[6] = "00001"; RF24 radio(7, 8); // CN and CSN pins of nrf struct MyData { byte h; byte t; }; MyData data; void setup() { Serial.begin(9600); radio.begin(); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); radio.setAutoAck(false); radio.setDataRate(RF24_250KBPS); radio.openReadingPipe(0, address); radio.setPALevel(RF24_PA_MIN); radio.startListening(); //lcd.println("Receiver "); } void ReceiveData() { if ( radio.available() ) { radio.read(&data, sizeof(MyData)); } } void loop() { ReceiveData(); // Serial.print("Humidity: "); lcd.setCursor(0,0); lcd.print("HUMIDITY:"); lcd.print(data.h); lcd.print("%"); lcd.setCursor(0,1); //Serial.print("Temperature: "); // Serial.print(\n); lcd.print("TEMPERATURE:"); lcd.print(data.t); lcd.print((char)223); lcd.print("C"); Serial.print(data.h); Serial.print(":"); Serial.print(data.t); Serial.print("\n"); delay(5000); } Subscribe and Download code. Receiver Amcharts Here to used amChart Gauge for Temperature and Humididty data visualization. Refer below demo HTML code for Gauges. https://www.amcharts.com/demos/#gauges 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 Android App

  • Water Level Controller for Multiple Tanks

    Learn here to create Arduino Based Water Level controller with bluetooth. We’ll use the HC SR04 ultrasonic to measure tank level, Bluetooth send water level percentage and Pump motor ON/OFF status data to android application for HTML Java script Tank Gauge display. Components required Arduino Nano - 1 no HC SR04 - 3 no Bluetooth HC-05 - 1 no Jumper wires Circuit diagram Refer to project Water level controller with Real time data logger for more detail. https://www.dofbot.com/post/water-level-controller-with-real-time-data-logger-and-bluetooth Installing 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. Arduino Code: #include Ultrasonic ultrasonic1(2, 3); Ultrasonic ultrasonic2(4, 5); Ultrasonic ultrasonic3(8, 9); // Tank T1 int T1distance; int T1Lowlevel = 20; // Tank1 Pump ON - T1Percentage 20% you can change the value as per your need int T1Highlevel = 70; // Tank 1Pump OFF - T1Percentage 70% you can change the value as per your need int T1TankHeight = 22; // Tank1 Manually enter Tank height in cm float T1Percentage,T1Math; #define T1MOTORPIN 6 // Tank 1 Pump relay ///// // Tank T2 int T2distance; int T2Lowlevel = 20; // Tank 2 Pump ON - T1Percentage 20% you can change the value as per your need int T2Highlevel = 70; // Tank 2 Pump OFF - T1Percentage 70% you can change the value as per your need int T2TankHeight = 18; // Tank 2 Manually enter Tank height in cm float T2Percentage,T2Math; #define T2MOTORPIN 7 // Tank 2 Pump relay ///// // Tank T3 int T3distance; int T3Lowlevel = 20; // Tank 3 Pump ON - T1Percentage 20% you can change the value as per your need int T3Highlevel = 70; // Tank 3 Pump OFF - T1Percentage 70% you can change the value as per your need int T3TankHeight = 15; // Tank 3 Manually enter Tank height in cm float T3Percentage,T3Math; #define T3MOTORPIN 10 // Tank 3 Pump relay //// String Data; void setup() { Serial.begin(9600); Serial.setTimeout(100); pinMode(T1MOTORPIN,OUTPUT);// Relay pin as output pin pinMode(T2MOTORPIN,OUTPUT);// Relay pin as output pin pinMode(T3MOTORPIN,OUTPUT);// Relay pin as output pin // digitalWrite(MOTORPIN,LOW); // unslash Start Up Turn off the relay condition // digitalWrite(MOTORPIN,High); //unslash Start Up Turn ON the relay condition delay(1000); } void loop() { // Tank 1 loop T1distance = ultrasonic1.read(); T1Math = T1TankHeight-T1distance; T1Percentage = (T1Math/T1TankHeight)*100; if ((T1Percentage >= 0) && (T1Percentage <= 100)) if(T1Percentage <= T1Lowlevel) // Relay ON when reached Low Level point {digitalWrite(T1MOTORPIN,HIGH);} if(T1Percentage >= T1Highlevel) // Relay OFF when reached High Level point {digitalWrite(T1MOTORPIN,LOW);} // end // Tank 2 loop T2distance = ultrasonic2.read(); T2Math = T2TankHeight-T2distance; T2Percentage = (T2Math/T2TankHeight)*100; if ((T2Percentage >= 0) && (T2Percentage <= 100)) if(T2Percentage <= T2Lowlevel) // Relay ON when reached Low Level point {digitalWrite(T2MOTORPIN,HIGH);} if(T2Percentage >= T2Highlevel) // Relay OFF when reached High Level point {digitalWrite(T2MOTORPIN,LOW);} // end // Tank 3 loop T3distance = ultrasonic3.read(); T3Math = T3TankHeight-T3distance; T3Percentage = (T3Math/T3TankHeight)*100; if ((T3Percentage >= 0) && (T3Percentage <= 100)) if(T3Percentage <= T3Lowlevel) // Relay ON when reached Low Level point {digitalWrite(T3MOTORPIN,HIGH);} if(T3Percentage >= T3Highlevel) // Relay OFF when reached High Level point {digitalWrite(T3MOTORPIN,LOW);} // end Data = (String)T1Percentage+":"+(String)T2Percentage+":"+(String)T3Percentage+ ":"+(String)(digitalRead(T1MOTORPIN))+":"+(String)(digitalRead(T2MOTORPIN))+":"+(String)(digitalRead(T3MOTORPIN)); Serial.println(Data); delay(5000); } Subscribe and Download code. Serial Monitor After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and see the Tank percentage and Pump ON/OFF status for each tanks in 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. Here to used amChart for Tank Level data visualization. https://www.amcharts.com/ HTML code for Multiple tanks, referf below.

  • Water Level Controller with Real time Data Logger and Bluetooth

    Learn here to create Arduino Based Water Level controller with RTC data logger. We’ll use the HC SR04 ultrasonic to measure tank level, the real time clock (RTC) module to take time stamps and the SD card module to save the water storage in liter, water filled in percentage and Pump motor ON/OFF status on the SD card, and Bluetooth send water level data to android application for HTML Java script Tank Gauge display. Components required Arduino Nano - 1 no Micro SD card Module - 1no Memory Card 16GB (16GB used in this Project)- 1no HC SR04 - 1 no DS1307 RTC I²Cmodule - 1 no Bluetooth HC-05 - 1 no Jumper wires Circuit diagram HC-SR04 HC-SR04 Ultrasonic sensor is a 4 pin module, whose pin names are Vcc, Trigger, Echo and Ground respectively. This sensor is a very popular sensor used in many applications where measuring distance or sensing objects are required. The module has two eyes like projects in the front which forms the Ultrasonic transmitter and Receiver. The sensor works with the simple high school formula that Distance = Speed × Time This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. VCC (Power) to Arduino Nano 5V Trig (Trigger) to Arduino Nano D2 Pin Echo (Receive) to Arduino Nano D3 Pin GND (Ground) to Arduino Nano GND Pin. Refer more Data sheet Download Refer to project Real time Temperature data logger for more detail. https://www.dofbot.com/post/real-time-temperature-data-logger-with-bluetooth The Arduino Nano board The Arduino Nano board provides more or less the same functionality of the Arduino Duemilanove but in a more compact design. Comparing to the Arduino Duemilanove board, the Arduino Nano board lack a DC power jack and has a mini-USB connector instead of a standard USB. Technical specifications of the Arduino Nano board The technical specifications of the Arduino Nano board are as follows: Microcontroller ATmega328 Operating Voltage (logic level): 5 V Input Voltage (recommended): 7-12 V Input Voltage (limits): 6-20 V Digital I/O Pins : 14 (of which 6 provide PWM output) Analog Input Pins: 8 DC Current per I/O Pin: 40 mA Flash Memory 32 KB (ATmega328) of which 2 KB used by bootloader SRAM: 2 KB (ATmega328) EEPROM: 1 KB (ATmega328) Clock Speed: 16 MHz Dimensions: 0.73" x 1.70" Powering the Arduino Nano The Arduino Nano can be powered via the Mini-B USB connection, 6-20V unregulated external power supply (pin 30), or 5V regulated external power supply (pin 27). The power source is automatically selected to the highest voltage source. Programming the Arduino Nano board The Arduino Nano can be programmed using the free Arduino software (download). Select "Arduino Diecimila, Duemilanove, or Nano w/ ATmega168" or "Arduino Duemilanove or Nano w/ ATmega328" from the Tools > Board menu. The ATmega328 microcontroller on the Arduino Nano board comes preburned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header. Cylinder Volume Calculator Vertical cylinder shaped tank is the area, A, of the circular end times the height, h. Volume=A.h A = πr² where r is the radius which is equal to d/2. d is diameter of Cylinder. Therefore, Volume = πr²h Rectangle shaped tank is length times width times height. Therefore, Volume = lwh A sphere of diameter d split in half and separated by a cylinder of diameter d Where r = d/2. Therefore, Volume = (4/3)πr³ Installing arduino Library Download Ultrasonic library , we need to use this library. DS1307: you need to Download and install the RTC 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. Arduino Code: // include the SD library: #include // Include SPI library (needed for the SD card) #include // Include SD library #include // for the RTC #include Ultrasonic ultrasonic(2, 3); int distance; int Lowlevel = 20; // Pump ON - Percentage 20% you can change the value as per your need int Highlevel = 70; // Pump OFF - Percentage 70% you can change the value as per your need File dataFile; int TankHeight = 17; // Manually enter Tank height in cm // Cylinder Tank volume V = πr2h, where h= 30cm, r = 15cm // Rectancle Tank volume V = lwh, where h= 17cm, w = 14cm, l= 17cm; Volume = 4 .03 liters int TotalVolume = 4; // mini tank Volume = 4 .03 liters int Volume; float Percentage,math; // Real Time Clock RTC_DS1307 rtc; #define MOTORPIN 8 // Pump relay String Data; void setup() { Serial.begin(9600); pinMode(MOTORPIN,OUTPUT);// Relay pin as output pin // setup for the RTC while(!Serial); // for Leonardo/Micro/Zero if(! rtc.begin()) { Serial.println("Couldn't find RTC"); while (1); } else { // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); } if(! rtc.isrunning()) { Serial.println("RTC is NOT running!"); } while (!Serial); // wait for serial port to connect. Needed for native USB port only Serial.print("Initializing SD card..."); if (!SD.begin()) { Serial.println("initialization failed!"); while (1); } Serial.println("initialization done."); delay(2000); } void loop() { // Wait a few seconds between measurements. delay(2000); distance = ultrasonic.read(); math = TankHeight-distance; Percentage = (math/TankHeight)*100; // Volume = (TotalVolume/100)*Percentage; if ((Percentage >= 0) && (Percentage <= 100)) if(Percentage <= Lowlevel) // Relay ON when reached Low Level point {digitalWrite(MOTORPIN,HIGH);} if(Percentage >= Highlevel) // Relay OFF when reached High Level point {digitalWrite(MOTORPIN,LOW);} dataFile = SD.open("LevelLog.txt", FILE_WRITE); DateTime now = rtc.now(); if (dataFile) { // Serial.print("Tank Level: "); Data = (String)TotalVolume + ":" + (String)Percentage+ ":"+ (String)(digitalRead(MOTORPIN)); Serial.println(Data); delay(1000); dataFile.print(now.year(), DEC); dataFile.print('/'); dataFile.print(now.month(), DEC); dataFile.print('/'); dataFile.print(now.day(), DEC); dataFile.print(','); dataFile.print(now.hour(), DEC); dataFile.print(':'); dataFile.print(now.minute(), DEC); dataFile.print(':'); dataFile.print(now.second(), DEC); dataFile.print(","); dataFile.print(F("Tank Level: ")); dataFile.print(Percentage); dataFile.print(F("Pump Status ")); dataFile.print(digitalRead(MOTORPIN)); dataFile.close(); } // if the file didn't open, print an error: else Serial.println("error opening LevelLog.txt"); } Subscribe and Download code. Serial Monitor After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and see the Temerature, Humidity and Heat index vaule in Serial monitor at every 15 second. SD Card First Power off the arduino nano and remove SD card from module and connect to the PC using SD card reader. The SD card contains LEVELLOG.txt file, the txt file have water level percentage and Pump status with Time stamp. HTML JS Code Here to used amChart Gauge for Tank Level and Storage data visualization. For code https://www.amcharts.com/ HTML code for Sphere 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

bottom of page