Featured – Blog eTechPath https://blog.etechpath.com Tue, 03 Jan 2023 12:41:13 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.4 https://blog.etechpath.com/wp-content/uploads/2017/08/BrandLogo12-150x150.png Featured – Blog eTechPath https://blog.etechpath.com 32 32 How to interface DHT11 DHT22 Temperature sensor with Raspberry Pi https://blog.etechpath.com/how-to-interface-dht11-dht22-temperature-sensor-with-raspberry-pi/ https://blog.etechpath.com/how-to-interface-dht11-dht22-temperature-sensor-with-raspberry-pi/#respond Sun, 21 Nov 2021 21:37:39 +0000 https://blog.etechpath.com/?p=541 About:
In this tutorial i will explain how to interface and program DHT11/22 temperature sensor with Raspberry Pi. I have used adafruit python library to program these sensors in python shell.




Things you will need:
Raspberry Pi (any model will work)
DHT11 or DHT22
4k7 Resistor




Circuit Diagram:

Circuit diagram

Python Code:

#!/usr/bin/python
# Name: DHT11/DHT22Interfacing Temperature sensor with raspberry Pi
# Author: Pranay Sawarkar
# Website: www.etechpath.com
# Copyright: Creative Common

import Adafruit_DHT

# sensor = Adafruit_DHT.DHT22
sensor = Adafruit_DHT.DHT11


# Sensor connected to Raspberry Pi GPIO4.
pin = 4

humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)

if humidity is not None and temperature is not None:
    print('Temperature={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature, humidity))
else:
    print('Failed to capture reading. Please Try again!')

 




Steps:

  1. Connect your temperature sensor to GPIO4 of your raspberry pi  and don’t forget to connect 4k7 pull up resistor between vcc and data output pin. You can use any 4k7 to 10k range resistor for pull up purpose.
  2. Power on your raspberry pi and open terminal.
  3. First we will download and install adafruit library for DHT sensors,
    sudo apt-get update
    git clone https://github.com/adafruit/Adafruit_Python_DHT.git
  4. Install python essential files. (if you are using it for first time)
    sudo apt-get install build-essential python-dev
    sudo python setup.py install
  5. Now your raspberry pi is ready to run the adafruit dht python program,
  6. Copy main python code at home directory in a empty file and name it as dht.py (or download ready dht.py file from download section and copy it to your raspberry pi home directory).
  7. Now you can use bellow command to check the sensor data by running this python program from your raspbery pi terminal,
    sudo python dht.py

    You will get output like this,



 

]]>
https://blog.etechpath.com/how-to-interface-dht11-dht22-temperature-sensor-with-raspberry-pi/feed/ 0
How to interface RFID read/write module RFID-RC522 with Arduino and read RFID tags with it. https://blog.etechpath.com/how-to-interface-rfid-readwrite-module-rfid-rc522-with-arduino-and-read-rfid-tags-with-it/ https://blog.etechpath.com/how-to-interface-rfid-readwrite-module-rfid-rc522-with-arduino-and-read-rfid-tags-with-it/#comments Sat, 19 May 2018 04:16:00 +0000 https://blog.etechpath.com/?p=591 About:

In this project i will explain how to interface MFRC522 based RFID read/write module RC522 with Arduino (arduino uno in my case). The example code is designed to read RFID tag unique number and identify the desired tag among’s them. A piezo buzzer and neopixel is also used in this project for visual and audible indication. Serial port is also programmed to view output in arduino IDE serial monitor.




Components: 

  1. RFID-RC522 13.56MHz read/write module           
  2. Arduino Uno           
  3. Neopixel           
  4. Piezo Buzzer       





Circuit Diagram:






Description:

    • RFID-RC522: This RFID module is designed to work on 3.3v (voltage level 2.5v to 3.3v). So, do not connect this module to arduino’s 5.0v supply. Other that power supply, connect all SPI interface pins to arduino as shown in the circuit diagram or refer bellow table.
      .
      RFID Pins     Arduino Pins
         SDA           10
         SCK           13
         MOSI          11
         MISO          12
         IRQ           NC
         GND           GND
         RST           8
         3.3v          3.3v

 

    • NeoPixel: Neopixel can work on both 5.0v or 3.3v. But 5.0v is better option to drive neopixel to obtain maximum brightness (in this project i have connected it with 3.3v for ease of circuit). So, connect neopixel power and ground with arduino and connect data line to arduino pin 5 as shown in the circuit diagram.                                                    Note: Here in this project i am using 12 pixels neopixel ring. You will need to update the code for number of pixel used, if you are using different that 12 pixels.

 

  • Piezo Buzzer: Pay attention while connecting piezo buzzer to your arduino, in my case i am using buzzer witch is specially designed for arduino and consumes safe current from arduino pin without frying it out. Arduino (ATmega168P – ATmega328P) IO pin can supply maximum 40ma per pin. So you need to check your piezo buzzer data sheet before connecting it with arduino, if it suppose to consume more current than the maximum limit then its a good choice to add one resistor in series with the buzzer.
    Let’s suppose if buzzer datasheet details are as bellow,
    Operating voltage: 5.0V
    Coil resistance: 50ΩThen, using Ohms law,
    V = IR
    5v = I x 50Ω
    I = 0.100Atheoretically we can see, this buzzer coil will consume 100mA current from arduino pin which probably can fry your arduino IO pin if you connect it without any current limiting resistance. So we need to reduce this current using current limiting resistance.

    As i mentioned above, arduino can supply 40mA maximum current per IO pin, but we will calculate our limiting resistance value according to 20mA limit to stay within safe condition.

    Again, using Ohms law,
    V = IR
    R = 5v/20mA
    R = 250Ω

    The buzzer coil already stated 50Ω resistance, so we will need to add 200Ω resistance in series with buzzer coil resistance which becomes 250Ω in total that exactly we want.





Code:

/* 
 *  Project: Interfacing MFRC522 based RFID Module RC522 with Arudino Uno 
 *  Author: Pranay Sawarkar
 *  Website: www.etechpath.com
 *  MFRC522 Library : https://github.com/ljos/MFRC522 
*/

#include <MFRC522.h>
#include <SPI.h>
#include <Adafruit_NeoPixel.h>
#define led_pin 5
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, led_pin, NEO_GRB + NEO_KHZ800);
#define SDAPIN 10 
#define RESETPIN 8 
#define Buzzer 3 

//variables to store data
byte FoundTag; 
byte ReadTag; 
byte TagData[MAX_LEN]; 
byte TagSerialNumber[5]; 
byte GoodTagSerialNumber[5] = {0x4C, 0x3B, 0xA0, 0x59}; //Good Tag Number (may different in your case)

MFRC522 nfc(SDAPIN, RESETPIN);

void setup() 
{
pinMode(Buzzer, OUTPUT); 
digitalWrite(Buzzer, LOW);
SPI.begin();
Serial.begin(115200);

//NEO Pixel LED strip setup
strip.begin();
strip.show();

// Start searching RFID Module
Serial.println("Searching for RFID Reader");
nfc.begin();
byte version = nfc.getFirmwareVersion(); // store the reader version in variable

// If can not find RFID Module 
if (! version) { 
Serial.print("Failed to search RC522 board, please check the hardware.");
while(1); //Wait until a RFID Module is found
}

// If found, print the information of detected RFID Module in serial monitor.
Serial.print("RC522 Module Found ");
Serial.println();
Serial.print("Firmware version: 0x");
Serial.println(version, HEX);
Serial.println();
}

//NeoPixel LED animation script 
void colorWipe(uint32_t c, uint8_t wait) 
{
  for(uint16_t i=0; i<strip.numPixels(); i++) 
  {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void loop() {

//Searching for RFID Tag indication.
colorWipe(strip.Color(0, 0, 255), 50); // Blue
colorWipe(strip.Color(0, 0, 0), 50); //OFF

//Detecting good Tag
String GoodTag="False";
FoundTag = nfc.requestTag(MF1_REQIDL, TagData);

if (FoundTag == MI_OK) {
delay(200);

ReadTag = nfc.antiCollision(TagData);
memcpy(TagSerialNumber, TagData, 4);

Serial.println("Tag detected.");
Serial.print("Serial Number: ");
// Loop for printing serial number in serial monitor
for (int i = 0; i < 4; i++) {
Serial.print(TagSerialNumber[i], HEX);
Serial.print(", ");
}
Serial.println("");
Serial.println();


// Check the detected tag number is matching with good tag number or not.
for(int i=0; i < 4; i++){
if (GoodTagSerialNumber[i] != TagSerialNumber[i]) 
{
break; // if not equal, then break out of the "for" loop
}
if (i == 3) { // if we made it to 4 loops then the Tag Serial numbers are matching
GoodTag="TRUE";
} 
}
if (GoodTag == "TRUE"){
Serial.println("TAG Matched ... !");
Serial.println();
//Tag matching indication
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 0), 50); // OFF
//loop for buzzer tone
for (int y = 0; y < 3; y++){
digitalWrite (Buzzer, HIGH) ;
delay (50) ; 
digitalWrite (Buzzer, LOW) ;
delay (50) ;
}
delay(500);
}
else {
Serial.println("TAG does not Matched .....!");
Serial.println();
//Tag not matching indication
colorWipe(strip.Color(255, 0, 0), 50); // RED
colorWipe(strip.Color(0, 0, 0), 50); // OFF
//loop for buzzer tone
for (int y = 0; y < 3; y++){
digitalWrite (Buzzer, HIGH) ;
delay (300) ;
digitalWrite (Buzzer, LOW) ;
delay (400) ;
}
delay(500); 
}
}
}





Working video:





Downloads:

MFRC522 IC datasheet

Circuit Digram

Code.ino


]]>
https://blog.etechpath.com/how-to-interface-rfid-readwrite-module-rfid-rc522-with-arduino-and-read-rfid-tags-with-it/feed/ 1
How to Control MAX7219 LED Matrix with ESP8266 WiFi Module https://blog.etechpath.com/how-to-control-max7219-led-matrix-with-esp8266-wifi-module/ https://blog.etechpath.com/how-to-control-max7219-led-matrix-with-esp8266-wifi-module/#comments Sat, 02 Dec 2017 00:40:20 +0000 https://blog.etechpath.com/?p=496 About this Project:
In this project we will learn how to interfacing ESP8266 module with MAX7219 matrix display to scrolling text message from web user interface. We will use Arduino IDE to program ESP module in this project. I am using MajicDesigns MD_MAX72xx library for running this project, also the code is very similar to included example in the library with some improvements in web user interface html code.




Components:

  1. MAX7219 8×8 LED Matrix
  2. ESP8266 Node MCU
  3. USB Cable for programming and power

Circuit Diagram:

Steps: 

      1. Connect the circuit as shown above.
      2. Install Arduino IDE form arduino website. After that install ESP8266 board and library in Arduino IDE.
      3. Download and install MD_MAX7219 Library from download section for driving MAX7219 matrix. For using this library you will need to edit MAX72xx.h file for configure the type of LED matrix you are using. In this project we are using FC-16 Chinese module.
      4. Download code ino file from download section and open it with Arduino IDE.
      5. You will need to edit WiFi network SSID and Password inside your code before flashing it in ESP module.
        const char* ssid = "your SSID";                   // edit your wifi SSID here
        const char* password = "your Password";            // edit your wifi password here
      6. Select board to NodeMCU and flash the code in ESP module.
      7. Power up the circuit and you will see IP address of your ESP module allocated by your WiFi network on Matrix display. (watch video)



    1. Now open that IP address in any browser connected in same network. And you will see web user interface to enter text.
    2. For detailed procedure of configuring WiFi module with your home network and using web interface, please watch embedded YouTube video linked at the bottom of this page.

Code:

//Link: https://blog.etechpath.com

#include <ESP8266WiFi.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define	PRINT_CALLBACK	0
#define DEBUG 0
#define LED_HEARTBEAT 0

#if DEBUG
#define	PRINT(s, v)	{ Serial.print(F(s)); Serial.print(v); }
#define PRINTS(s)   { Serial.print(F(s)); }
#else
#define	PRINT(s, v)
#define PRINTS(s)
#endif

#if LED_HEARTBEAT
#define HB_LED  D2
#define HB_LED_TIME 500 // in milliseconds
#endif

#define	MAX_DEVICES	4

#define	CLK_PIN		D5 // or SCK
#define	DATA_PIN	D7 // or MOSI
#define	CS_PIN		D8 // or SS

// SPI hardware interface
//MD_MAX72XX mx = MD_MAX72XX(CS_PIN, MAX_DEVICES);
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW  //edit this as per your LED matrix hardware type
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Arbitrary pins
//MD_MAX72XX mx = MD_MAX72XX(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// WiFi login parameters - network name and password
const char* ssid = "your SSID";                   // edit your wifi SSID here
const char* password = "your Password";            // edit your wifi password here

// WiFi Server object and parameters
WiFiServer server(80);

// Global message buffers shared by Wifi and Scrolling functions
const uint8_t MESG_SIZE = 255;
const uint8_t CHAR_SPACING = 1;
const uint8_t SCROLL_DELAY = 75;

char curMessage[MESG_SIZE];
char newMessage[MESG_SIZE];
bool newMessageAvailable = false;

char WebResponse[] = "HTTP/1.1 200 OK\nContent-Type: text/html\n\n";

char WebPage[] =
"<!DOCTYPE html>" \
"<html>" \
"<head>" \
"<title>eTechPath MAX7219 ESP8266</title>" \
"<style>" \
"html, body" \ 
"{" \
"width: 600px;" \
"height: 400px;" \
"margin: 0px;" \
"border: 0px;" \
"padding: 10px;" \
"background-color: white;" \
"}" \
"#container " \
"{" \
"width: 100%;" \
"height: 100%;" \
"margin-left: 200px;" \
"border: solid 2px;" \
"padding: 10px;" \
"background-color: #b3cbf2;" \
"}" \          
"</style>"\
"<script>" \
"strLine = \"\";" \
"function SendText()" \
"{" \
"  nocache = \"/&nocache=\" + Math.random() * 1000000;" \
"  var request = new XMLHttpRequest();" \
"  strLine = \"&MSG=\" + document.getElementById(\"txt_form\").Message.value;" \
"  request.open(\"GET\", strLine + nocache, false);" \
"  request.send(null);" \
"}" \
"</script>" \
"</head>" \
"<body>" \
"<div id=\"container\">"\
"<H1><b>WiFi MAX7219 LED Matrix Display</b></H1>" \ 
"<form id=\"txt_form\" name=\"frmText\">" \
"<label>Msg:<input type=\"text\" name=\"Message\" maxlength=\"255\"></label><br><br>" \
"</form>" \
"<br>" \
"<input type=\"submit\" value=\"Send Text\" onclick=\"SendText()\">" \
"<p><b>Visit Us at</b></p>" \ 
"<a href=\"http://www.eTechPath.com\">www.eTechPath.com</a>" \
"</div>" \
"</body>" \
"</html>";

char *err2Str(wl_status_t code)
{
  switch (code)
  {
  case WL_IDLE_STATUS:    return("IDLE");           break; // WiFi is in process of changing between statuses
  case WL_NO_SSID_AVAIL:  return("NO_SSID_AVAIL");  break; // case configured SSID cannot be reached
  case WL_CONNECTED:      return("CONNECTED");      break; // successful connection is established
  case WL_CONNECT_FAILED: return("CONNECT_FAILED"); break; // password is incorrect
  case WL_DISCONNECTED:   return("CONNECT_FAILED"); break; // module is not configured in station mode
  default: return("??");
  }
}
uint8_t htoi(char c)
{
  c = toupper(c);
  if ((c >= '0') && (c <= '9')) return(c - '0');
  if ((c >= 'A') && (c <= 'F')) return(c - 'A' + 0xa);
  return(0);
}
boolean getText(char *szMesg, char *psz, uint8_t len)
{
  boolean isValid = false;  // text received flag
  char *pStart, *pEnd;      // pointer to start and end of text
  // get pointer to the beginning of the text
  pStart = strstr(szMesg, "/&MSG=");
  if (pStart != NULL)
  {
    pStart += 6;  // skip to start of data
    pEnd = strstr(pStart, "/&");
    if (pEnd != NULL)
    {
      while (pStart != pEnd)
      {
        if ((*pStart == '%') && isdigit(*(pStart+1)))
        {
          // replace %xx hex code with the ASCII character
          char c = 0;
          pStart++;
          c += (htoi(*pStart++) << 4);
          c += htoi(*pStart++);
          *psz++ = c;
        }
        else
          *psz++ = *pStart++;
      }
      *psz = '\0'; // terminate the string
      isValid = true;
    }
  }
  return(isValid);
}
void handleWiFi(void)
{
  static enum { S_IDLE, S_WAIT_CONN, S_READ, S_EXTRACT, S_RESPONSE, S_DISCONN } state = S_IDLE;
  static char szBuf[1024];
  static uint16_t idxBuf = 0;
  static WiFiClient client;
  static uint32_t timeStart;

  switch (state)
  {
  case S_IDLE:   // initialise
    PRINTS("\nS_IDLE");
    idxBuf = 0;
    state = S_WAIT_CONN;
    break;
  case S_WAIT_CONN:   // waiting for connection
    {
      client = server.available();
      if (!client) break;
      if (!client.connected()) break;
#if DEBUG
      char szTxt[20];
      sprintf(szTxt, "%03d:%03d:%03d:%03d", client.remoteIP()[0], client.remoteIP()[1], client.remoteIP()[2], client.remoteIP()[3]);
      PRINT("\nNew client @ ", szTxt);
#endif
      timeStart = millis();
      state = S_READ;
    }
    break;
  case S_READ: // get the first line of data
    PRINTS("\nS_READ");
    while (client.available())
    {
      char c = client.read();
      if ((c == '\r') || (c == '\n'))
      {
        szBuf[idxBuf] = '\0';
        client.flush();
        PRINT("\nRecv: ", szBuf);
        state = S_EXTRACT;
      }
      else
        szBuf[idxBuf++] = (char)c;
    }
    if (millis() - timeStart > 1000)
    {
      PRINTS("\nWait timeout");
      state = S_DISCONN;
    }
    break;
  case S_EXTRACT: // extract data
    PRINTS("\nS_EXTRACT");
    // Extract the string from the message if there is one
    newMessageAvailable = getText(szBuf, newMessage, MESG_SIZE);
    PRINT("\nNew Msg: ", newMessage);
    state = S_RESPONSE;
    break;
  case S_RESPONSE: // send the response to the client
    PRINTS("\nS_RESPONSE");
    // Return the response to the client (web page)
    client.print(WebResponse);
    client.print(WebPage);
    state = S_DISCONN;
    break;
  case S_DISCONN: // disconnect client
    PRINTS("\nS_DISCONN");
    client.flush();
    client.stop();
    state = S_IDLE;
    break;

  default:  state = S_IDLE;
  }
}
void scrollDataSink(uint8_t dev, MD_MAX72XX::transformType_t t, uint8_t col)
// Callback function for data that is being scrolled off the display
{
#if PRINT_CALLBACK
  Serial.print("\n cb ");
  Serial.print(dev);
  Serial.print(' ');
  Serial.print(t);
  Serial.print(' ');
  Serial.println(col);
#endif
}
uint8_t scrollDataSource(uint8_t dev, MD_MAX72XX::transformType_t t)
// Callback function for data that is required for scrolling into the display
{
  static enum { S_IDLE, S_NEXT_CHAR, S_SHOW_CHAR, S_SHOW_SPACE } state = S_IDLE;
  static char		*p;
  static uint16_t	curLen, showLen;
  static uint8_t	cBuf[8];
  uint8_t colData = 0;
  // finite state machine to control what we do on the callback
  switch (state)
  {
  case S_IDLE: // reset the message pointer and check for new message to load
    PRINTS("\nS_IDLE");
    p = curMessage;      // reset the pointer to start of message
    if (newMessageAvailable)  // there is a new message waiting
    {
      strcpy(curMessage, newMessage); // copy it in
      newMessageAvailable = false;
    }
    state = S_NEXT_CHAR;
    break;
  case S_NEXT_CHAR: // Load the next character from the font table
    PRINTS("\nS_NEXT_CHAR");
    if (*p == '\0')
      state = S_IDLE;
    else
    {
      showLen = mx.getChar(*p++, sizeof(cBuf) / sizeof(cBuf[0]), cBuf);
      curLen = 0;
      state = S_SHOW_CHAR;
    }
    break;
  case S_SHOW_CHAR:	// display the next part of the character
    PRINTS("\nS_SHOW_CHAR");
    colData = cBuf[curLen++];
    if (curLen < showLen)
      break;
    // set up the inter character spacing
    showLen = (*p != '\0' ? CHAR_SPACING : (MAX_DEVICES*COL_SIZE)/2);
    curLen = 0;
    state = S_SHOW_SPACE;
    // fall through
  case S_SHOW_SPACE:	// display inter-character spacing (blank column)
    PRINT("\nS_ICSPACE: ", curLen);
    PRINT("/", showLen);
    curLen++;
    if (curLen == showLen)
      state = S_NEXT_CHAR;
    break;
  default:
    state = S_IDLE;
  }
  return(colData);
}
void scrollText(void)
{
  static uint32_t	prevTime = 0;
  // Is it time to scroll the text?
  if (millis() - prevTime >= SCROLL_DELAY)
  {
    mx.transform(MD_MAX72XX::TSL);	// scroll along - the callback will load all the data
    prevTime = millis();			// starting point for next time
  }
}
void setup()
{
#if DEBUG
  Serial.begin(115200);
  PRINTS("\n[MD_MAX72XX WiFi Message Display]\nType a message for the scrolling display from your internet browser");
#endif
#if LED_HEARTBEAT
  pinMode(HB_LED, OUTPUT);
  digitalWrite(HB_LED, LOW);
#endif
  // Display initialisation
  mx.begin();
  mx.setShiftDataInCallback(scrollDataSource);
  mx.setShiftDataOutCallback(scrollDataSink);
  curMessage[0] = newMessage[0] = '\0';
  // Connect to and initialise WiFi network
  PRINT("\nConnecting to ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    PRINT("\n", err2Str(WiFi.status()));
    delay(500);
  }
  PRINTS("\nWiFi connected");
  // Start the server
  server.begin();
  PRINTS("\nServer started");
  // Set up first message as the IP address
  sprintf(curMessage, "%03d:%03d:%03d:%03d", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3]);
  PRINT("\nAssigned IP ", curMessage);
}
void loop()
{
#if LED_HEARTBEAT
  static uint32_t timeLast = 0;
  if (millis() - timeLast >= HB_LED_TIME)
  {
    digitalWrite(HB_LED, digitalRead(HB_LED) == LOW ? HIGH : LOW);
    timeLast = millis();
  }
#endif
  handleWiFi();
  scrollText();
}

Downloads:

  1. Arduino IDE
  2. ESP8266 Arduino Library
  3. MajicDesigns MD_MAX7219 Library
  4. Code.ino

Video:

How to solve mirror image and orientation problems of matrix display if you are using old MD_MAX72xx library.

]]>
https://blog.etechpath.com/how-to-control-max7219-led-matrix-with-esp8266-wifi-module/feed/ 34
How to control RGB LED wirelessly using ESP8266 WiFi web interface https://blog.etechpath.com/how-to-control-rgb-led-wirelessly-using-esp8266-wifi-web-interface/ https://blog.etechpath.com/how-to-control-rgb-led-wirelessly-using-esp8266-wifi-web-interface/#comments Tue, 21 Nov 2017 22:59:50 +0000 https://blog.etechpath.com/?p=476 About:

In this project we are going to control 1 watt RGB full color LED diode using WiFi module ESP8266-01. You can use any WiFi enabled device to access web interface to control this RGB LED. Watch video at the bottom of this page.




Things you will need: 

  • 1W RGB LED
  • ESP-01  WiFi module
  • 10Ω Resistance
  • ASM1117 3.3v  (or any 3.3v voltage source)
  • USB to TTL converter (for programming esp-01)
  • Momentary push button (optional)
  • Android / Apple / Windows  Phone or any WiFi enabled Laptop / Desktop (to control RGB LED)

Circuit Diagram for programming ESP-01 : 

esp-01_circuit

Steps :

    1. Connect the circuit on breadboard as shown in above circuit diagram for programming ESP-01 WiFi module. You must use only 3.3v logic setting in TTL device.
    2. In this tutorial we will used Arduino IDE to download code into ESP module. So, install Arduino IDE and add supporting board manager and ESP library into it. (Download links are given in download section)



  1. Download and save source code on your computer and open it up using Arduino IDE.
  2. Connect USB to TTL module to your computer.
  3. Open Arduino IDE – Select board ‘Generic ESP8266 Module’ – Select Port of your TTL device (Here’s How to)
  4. Open downloaded code.ino file into arduino and upload the code into ESP module by pressing upload button.
  5. After uploading, Disconnect the ESP module from USB-TTL module and connect it to RGB LED as shown in bellow diagram.

Circuit Diagram for connecting RGB LED:

Steps: 

    1. Connect the final circuit as shown in above diagram and power it up using 5v battery or wall adapter.
    2. ESP module will boot up and LED light will show fade effect in all three colors at startup.



  1. Then open your device WiFi in discovery mode and you will see a new WiFi access point, named as RGB in discovery list.
  2. Connect that WiFi access point, Open any web browser in that device and open ip address 192.168.1.1 , thats it, you will see a colorful RGB control screen to control your wireless RGB LED.
        Note: Do not feed more than 3.3v to ESP-01 module

Source Code : 

/* RGB web server with ESP8266-01 (ESP-01)
* There are only 2 GPIOs available in ESP-01: 0 and 2
* but RX and TX can also be used as: 3 and 1
* Wiring Circuit 
* 0=Red (GPIO0) D3
* 2=Green (GPIO2) D4
* 3=Blue (GPIO3) Rx
* www.etechpath.com
*/

#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>

const char *ssid = "RGB";
//Uncomment below line if you wish to set a password for ESP wifi network...
// const char *password = "87654321";  

const byte DNS_PORT = 53;
IPAddress apIP(192, 168, 1, 1);   //IP address of your ESP 
DNSServer dnsServer;
ESP8266WebServer webServer(80);

//Webpage html Code
String webpage = ""
"<!DOCTYPE html><html><head><title>RGB control eTechPath.com</title><meta name='mobile-web-app-capable' content='yes' />"
"<meta name='viewport' content='width=device-width' /></head><body style='margin: 0px; padding: 0px;'>"
"<canvas id='colorspace'></canvas>"
"</body>"
"<script type='text/javascript'>"
"(function () {"
" var canvas = document.getElementById('colorspace');"
" var ctx = canvas.getContext('2d');"
" function drawCanvas() {"
" var colours = ctx.createLinearGradient(0, 0, window.innerWidth, 0);"
" for(var i=0; i <= 360; i+=10) {"
" colours.addColorStop(i/360, 'hsl(' + i + ', 100%, 50%)');"
" }"
" ctx.fillStyle = colours;"
" ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);"
" var luminance = ctx.createLinearGradient(0, 0, 0, ctx.canvas.height);"
" luminance.addColorStop(0, '#ffffff');"
" luminance.addColorStop(0.05, '#ffffff');"
" luminance.addColorStop(0.5, 'rgba(0,0,0,0)');"
" luminance.addColorStop(0.95, '#000000');"
" luminance.addColorStop(1, '#000000');"
" ctx.fillStyle = luminance;"
" ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);"
" }"
" var eventLocked = false;"
" function handleEvent(clientX, clientY) {"
" if(eventLocked) {"
" return;"
" }"
" function colourCorrect(v) {"
" return Math.round(1023-(v*v)/64);"
" }"
" var data = ctx.getImageData(clientX, clientY, 1, 1).data;"
" var params = ["
" 'r=' + colourCorrect(data[0]),"
" 'g=' + colourCorrect(data[1]),"
" 'b=' + colourCorrect(data[2])"
" ].join('&');"
" var req = new XMLHttpRequest();"
" req.open('POST', '?' + params, true);"
" req.send();"
" eventLocked = true;"
" req.onreadystatechange = function() {"
" if(req.readyState == 4) {"
" eventLocked = false;"
" }"
" }"
" }"
" canvas.addEventListener('click', function(event) {"
" handleEvent(event.clientX, event.clientY, true);"
" }, false);"
" canvas.addEventListener('touchmove', function(event){"
" handleEvent(event.touches[0].clientX, event.touches[0].clientY);"
"}, false);"
" function resizeCanvas() {"
" canvas.width = window.innerWidth;"
" canvas.height = window.innerHeight;"
" drawCanvas();"
" }"
" window.addEventListener('resize', resizeCanvas, false);"
" resizeCanvas();"
" drawCanvas();"
" document.ontouchmove = function(e) {e.preventDefault()};"
" })();"
"</script></html>";
void handleRoot() 
{
// Serial.println("handle root..");
String red = webServer.arg(0); // read RGB arguments
String green = webServer.arg(1);  // read RGB arguments
String blue = webServer.arg(2);  // read RGB arguments

//for common anode
analogWrite(0, red.toInt());
analogWrite(2, green.toInt());
analogWrite(3, blue.toInt());
//for common cathode
//analogWrite(0,1023 - red.toInt());
//analogWrite(2,1023 - green.toInt());
//analogWrite(3,1023 - blue.toInt());
webServer.send(200, "text/html", webpage);
}
void setup() 
{
pinMode(0, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);

analogWrite(0, 1023);
analogWrite(2, 1023);
analogWrite(3, 1023);
delay(1000);
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP(ssid);
dnsServer.start(DNS_PORT, "rgb", apIP);
webServer.on("/", handleRoot);
webServer.begin();
testRGB();
}
void loop() 
{
dnsServer.processNextRequest();
webServer.handleClient();
}
void testRGB() 
{ 
// fade in and out of Red, Green, Blue
analogWrite(0, 1023); // Red off
analogWrite(2, 1023); // Green off
analogWrite(3, 1023); // Blue off

fade(0); // Red fade effect
fade(2); // Green fade effect
fade(3); // Blue fade effect
}
void fade(int pin) 
{
for (int u = 0; u < 1024; u++) 
{
analogWrite(pin, 1023 - u);
delay(1);
}
for (int u = 0; u < 1024; u++) 
{
analogWrite(pin, u);
delay(1);
}
}

 





Downloads:

  1. Code.ino
  2. Arduino IDE
  3. ESP8266 Board link for IDE board manager
  4. ESP8266 Arduino Library

 

]]>
https://blog.etechpath.com/how-to-control-rgb-led-wirelessly-using-esp8266-wifi-web-interface/feed/ 6
How to use PAM8610 15w+15w amplifier module (Boombox Project) https://blog.etechpath.com/how-to-use-pam8610-15w15w-amplifier-module-boombox-project/ https://blog.etechpath.com/how-to-use-pam8610-15w15w-amplifier-module-boombox-project/#respond Wed, 25 Oct 2017 01:17:19 +0000 https://blog.etechpath.com/?p=450 About:

PAM8610 is a duel channel stereo class D audio amplifier with 15w power output per channel. This chip equipped with 32 steps DC volume control which provides +32db to -75db of frequency range. Known for its low EMI , low noise and high sound quality reproduction.

 

Features :

Working voltage range : 7v to 15v

Protection : over current, thermal and short circuit protection

Provides 15w per channel into 4Ohm load at 12v & 10w per channel into 8Ohm load at 13v.

Provides on chip Mute function.

 

Circuit Diagram :

PAM8610 Boombox



]]>
https://blog.etechpath.com/how-to-use-pam8610-15w15w-amplifier-module-boombox-project/feed/ 0
How to share files between Raspberry Pi & Windows using shared folder. https://blog.etechpath.com/how-to-share-files-between-raspberry-pi-windows-using-shared-folder/ https://blog.etechpath.com/how-to-share-files-between-raspberry-pi-windows-using-shared-folder/#respond Sat, 21 Oct 2017 22:37:03 +0000 https://blog.etechpath.com/?p=435 About:
For sharing files between Raspberry Pi and Windows we need to setup a file server on Raspberry Pi, here in this tutorial we will use SAMBA file server to share files between two different operating systems.

What is SAMBA:

SAMBA is Linux based free tool which is widely used for file sharing in Windows PC, Apple Computers, and Unix-based operating systems. It is re-implementation of SMB/CIFS standard networking protocol and was developed by Andrew Tridgell. This tool is written in C,C++ and Python programming language and licensed under GPLv3.

How to Setup SAMBA in Raspberry Pi

1.Update apt

pi@raspberrypi ~ $ sudo apt update

 

2. Install SAMBA on your raspberry pi,

pi@raspberrypi ~ $ sudo apt-get install samba




(adsbygoogle = window.adsbygoogle || []).push({});

3. After finishing installation, configure SAMBA by editing configuration file /etc/samba/smb.conf

pi@raspberrypi ~ $ sudo nano /etc/samba/smb.conf

In this configuration file, you will need to add the workgroup name of the computer which you are going to connect with the raspberry pi.  To find workgroup name in windows 7 :- Right click on My Computer and enter properties -> Full computer name is your workgroup name (Example =>).

workgroup name
workgroup name
workgroup = MYWORKGROUP
wins support = yes

Replace MYWORKGROUP with your workgroup name. Save & exit the file by pressing ctrl+X , Y, Enter. Change wins support to yes.

 

4. Create shared folder in raspberry pi directory and give read, write & execute permission for this folder to all users.

pi@raspberrypi~ $ mkdir /home/pi/shared
pi@raspberrypi~ $ chmod 777 /home/pi/shared

 

5. Define the behavior  of shared folder. For that purpose we will net to edit configuration file again. /etc/samba/smb.conf

pi@raspberrypi ~ $ sudo nano /etc/samba/smb.conf

Add following lines in this file. Save & exit by pressing ctrl+X, Y, Enter.

[pishare]  
     comment = pi shared folder
     path = /home/pi/shared
     browsable = yes
     guest ok = yes
     writable = yes

 

6. Restart SAMBA,

pi@raspberrypi ~ $ sudo /etc/init.d/samba restart





How to setup shared folder in Windows:

  1. Make sure your computer and raspberry pi connected to same network and configured properly.
  2. Open Network tab on the left side of explorer window.
  3. After searching process, you will see a shared computer named as your raspberry pi hostname.
  4. Open it up and you will find Shared folder inside it which we have just created in raspberry pi.
  5. Now you can start sharing files and taking backup between your raspberry pi and windows computer.
]]>
https://blog.etechpath.com/how-to-share-files-between-raspberry-pi-windows-using-shared-folder/feed/ 0
Bluetooth Controlled 8×8 LED MAX7219 Matrix using Android Phone. https://blog.etechpath.com/bluetooth-controlled-8x8-led-max7219-matrix-using-android-phone/ https://blog.etechpath.com/bluetooth-controlled-8x8-led-max7219-matrix-using-android-phone/#comments Thu, 12 Oct 2017 00:51:25 +0000 https://blog.etechpath.com/?p=416 About:

This project is about moving LED matrix display. In this project we will use MAX7219 8×8 LED module for display, Arduino UNO for brain and Bluetooth serial  module for communication. You will need an Android phone for controlling this display.




Things you will need: 

  1. Arduino UNO.
  2. MAX7219 LED modules – 3Nos.   (You can add many of these for increasing length of display)
  3. HC-05 Serial Bluetooth Module.      (You can use any other similar serial Bluetooth module instead )
  4. Android Phone.

 

Circuit Diagram:

Circuit Diagram

wiring diagram

 

Code :

    /*
          8x8 LED Matrix MAX7219 Scrolling Text
              Android Control via Bluetooth
    */
    #include <MaxMatrix.h>
    #include <SoftwareSerial.h>
    #include <avr/pgmspace.h>
    PROGMEM const unsigned char CH[] = {
      3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
      1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
      3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
      5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
      4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
      5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
      5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
      1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
      3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
      3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
      5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
      5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
      2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
      4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
      2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
      4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
      4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
      3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
      4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
      4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
      4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
      4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
      4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
      4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
      4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
      4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
      2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
      2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
      3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
      3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
      3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
      4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
      5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
      4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
      4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
      4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
      4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
      4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
      4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
      4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
      4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
      3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
      4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
      4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
      4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
      5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
      5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
      4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
      4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
      4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
      4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
      4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
      5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
      4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
      5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
      5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
      5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
      5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
      4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
      2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [
      4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
      2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
      3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
      4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
      2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
      4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a
      4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b
      4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c
      4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d
      4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e
      3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f
      4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g
      4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h
      3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i
      4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j
      4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k
      3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l
      5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m
      4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n
      4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
      4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
      4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
      4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
      4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
      3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
      4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
      5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
      5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
      5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
      4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
      3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
      3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // {
      1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // |
      3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // }
      4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~
    };
    int dIn = 7;   // DIN pin of MAX7219 module
    int clk = 6;   // CLK pin of MAX7219 module
    int cs = 5;    // CS pin of MAX7219 module
    int maxInUse = 2;    // Number of MAX7219's connected
    MaxMatrix m(dIn, cs, clk, maxInUse);
    SoftwareSerial Bluetooth(8, 7); // Bluetooth
    byte buffer[10];
    char incomebyte;
    int scrollSpeed = 100;
    char text[100] = "www.etechpath.com  "; // Initial text message
    int brightness = 15;
    int count = 0;
    char indicator;
    void setup() {
      m.init(); // MAX7219 initialization
      m.setIntensity(brightness); // initial led matrix intensity, 0-15
      Bluetooth.begin(38400); // Default communication rate of the Bluetooth module
    }
    void loop() {
      // Printing the text
      printStringWithShift(text, scrollSpeed);
      
      if (Bluetooth.available()) {   // Checks whether data is comming from the serial port
        indicator = Bluetooth.read();   // Starts reading the serial port, the first byte from the incoming data
        // If we have pressed the "Send" button from the Android App, clear the previous text
        if (indicator == '1') {
          for (int i = 0; i < 100; i++) {
            text[i] = 0;
            m.clear();
          }
          // Read the whole data/string comming from the phone and put it into text[] array.
          while (Bluetooth.available()) {
            incomebyte = Bluetooth.read();
            text[count] = incomebyte;
            count++;
          }
          count = 0;
        }
        // Adjusting the Scrolling Speed
        else if (indicator == '2') {
          String sS = Bluetooth.readString();
          scrollSpeed = 150 - sS.toInt(); // Milliseconds, subtraction because lower value means higher scrolling speed
        }
        // Adjusting the brightness
        else if (indicator == '3') {
          String sB = Bluetooth.readString();
          brightness = sB.toInt();
          m.setIntensity(brightness);
        }
      }
    }
    void printCharWithShift(char c, int shift_speed) {
      if (c < 32) return;
      c -= 32;
      memcpy_P(buffer, CH + 7 * c, 7);
      m.writeSprite(32, 0, buffer);
      m.setColumn(32 + buffer[0], 0);
      for (int i = 0; i < buffer[0] + 1; i++)
      {
        delay(shift_speed);
        m.shiftLeft(false, false);
      }
    }
    void printStringWithShift(char* s, int shift_speed) {
      while (*s != 0) {
        printCharWithShift(*s, shift_speed);
        s++;
      }
    }
    void printString(char* s)
    {
      int col = 0;
      while (*s != 0)
      {
        if (*s < 32) continue;
        char c = *s - 32;
        memcpy_P(buffer, CH + 7 * c, 7);
        m.writeSprite(col, 0, buffer);
        m.setColumn(col + buffer[0], 0);
        col += buffer[0] + 1;
        s++;
      }
    }

 

 

Steps :

  1. Connect MAX7219 LED modules with each other as shown in above wiring diagram.
  2. Connect led modules data pins to arduino data pins and connect source power as shown in circuit diagram.
  3. Now connect HC-05 serial module to RX TX pins of Arduino. Arduino RX to HC-05 TX and arduino TX to HC-05 RX.
  4. Download code into arduino using Arduino IDE.
  5. Download android application from download section and install it in your phone .
  6. Now you can connect your phone with this display using provided application to control matrix display.



Downloads :

  1. Android appliation
  2. MAX7219 Datasheet
  3. MaxMatrix.h


Check this WiFi controlled MAX7219 LED Matrix using ESP-12 NodeMCU module

]]>
https://blog.etechpath.com/bluetooth-controlled-8x8-led-max7219-matrix-using-android-phone/feed/ 1
How to operate home appliances wirelessly using ESP8266 and android phone https://blog.etechpath.com/how-to-operate-home-appliances-wirelessly-using-esp8266-and-android-phone/ https://blog.etechpath.com/how-to-operate-home-appliances-wirelessly-using-esp8266-and-android-phone/#respond Fri, 08 Sep 2017 01:37:04 +0000 https://blog.etechpath.com/?p=236 Required Components: 



  1. NodeMCU or any ESP8266
  2. Relay Module
  3. 128×64 OLED display (Optional)
  4. Android Phone

Circuit Diagram :

 

Source Code:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <Adafruit_GFX.h>
#include <ESP_Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

 

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

const char* ssid = "xxxxxxx"; //replace xxxxxxx with your wifi ssid
const char* password = "xxxxxxx"; //replace xxxxxxx with your wifi password

ESP8266WebServer server(80);

const int output1 = 14;
const int output2 = 12;
const int output3 = 13;
const int output4 = 15;

boolean device1 = false;
boolean device2 = false;
boolean device3 = false;
boolean device4 = false;

void handleRoot() {
//digitalWrite(led, 1);
//server.send(200, "text/plain", "hello from esp8266!");
//digitalWrite(led, 0);

String cmd;
cmd += "<!DOCTYPE HTML>\r\n";
cmd += "<html>\r\n";
//cmd += "<header><title>ESP8266 Webserver</title><h1>\"ESP8266 Web Server Control\"</h1></header>";
cmd += "<head>";
cmd += "<meta http-equiv='refresh' content='5'/>";
cmd += "</head>";

if(device1){
cmd +=("<br/>Device1 : ON");
}
else{
cmd +=("<br/>Device1 : OFF");
}

if(device2){
cmd +=("<br/>Device2 : ON");
}
else{
cmd +=("<br/>Device2 : OFF");
}

if(device3){
cmd +=("<br/>Device3 : ON");
}
else{
cmd +=("<br/>Device3 : OFF");
}

if(device4){
cmd +=("<br/>Device4 : ON");
}
else{
cmd +=("<br/>Device4 : OFF");
}

cmd += "<html>\r\n";
server.send(200, "text/html", cmd);
}

void handleNotFound(){

String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);

}

void setup(void){
pinMode(output1, OUTPUT);
pinMode(output2, OUTPUT);
pinMode(output3, OUTPUT);
pinMode(output4, OUTPUT);

digitalWrite(output1, LOW);
digitalWrite(output2, LOW);
digitalWrite(output3, LOW);
digitalWrite(output4, LOW);

Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");

 

// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
//display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // initialize with the I2C addr 0x3D (for the 128x64)
display.begin(SSD1306_SWITCHCAPVCC, 0x78>>1); // init done

display.clearDisplay(); // Clear the buffer.

display.setTextSize(2);
display.setTextColor(WHITE);
//display.setTextColor(BLACK, WHITE); // 'inverted' text
display.setCursor(0,0);
display.println(" ESP8266");

display.setTextSize(3); //Size4 = 5 digit , size3 = 7 digits
//display.setTextColor(BLACK, WHITE); // 'inverted' text
display.setTextColor(WHITE);
display.setCursor(0,18);
display.println("Control");

display.setTextSize(1);
display.setTextColor(WHITE);
//display.setTextColor(BLACK, WHITE); // 'inverted' text
display.setCursor(0,52);
display.println("Version 0.1");

display.display();
delay(2000);

display.clearDisplay();

display.setTextSize(2);
display.setTextColor(WHITE);
//display.setTextColor(BLACK, WHITE); // 'inverted' text
display.setCursor(0,0);
display.println("Connecting");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");

display.print(".");
display.display();
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

display.clearDisplay();
display.setTextSize(1); display.setTextColor(WHITE);
display.setCursor(0,0); display.println(ssid);
display.setTextSize(2); display.setTextColor(WHITE);
display.setCursor(0,18); display.println(WiFi.localIP());
//display.setCursor(0,36); display.println(WiFi.localIP());

display.display();

if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}

server.on("/", handleRoot);

server.on("/status1=1", [](){
server.send(200, "text/plain", "device1 = ON");
digitalWrite(output1, HIGH);
device1 = true;
});

server.on("/status1=0", [](){
server.send(200, "text/plain", "device1 = OFF");
digitalWrite(output1, LOW);
device1 = false;
});

server.on("/status2=1", [](){
server.send(200, "text/plain", "device2 = ON");
digitalWrite(output2, HIGH);
device2 = true;
});

server.on("/status2=0", [](){
server.send(200, "text/plain", "device2 = OFF");
digitalWrite(output2, LOW);
device2 = false;
});

server.on("/status3=1", [](){
server.send(200, "text/plain", "device3 = ON");
digitalWrite(output3, HIGH);
device3 = true;
});

server.on("/status3=0", [](){
server.send(200, "text/plain", "device3 = OFF");
digitalWrite(output3, LOW);
device3 = false;
});

server.on("/status4=1", [](){
server.send(200, "text/plain", "device4 = ON");
digitalWrite(output4, HIGH);
device4 = true;
});

server.on("/status4=0", [](){
server.send(200, "text/plain", "device4 = OFF");
digitalWrite(output4, LOW);
device4 = false;
});

server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}

void loop(void){
server.handleClient();
}

Steps:

    1. Build up the circuit as shown in circuit diagram.
    2. Download source code from download section, edit downloaded code and input your home router’s SSID and Password in the code.
      const char* ssid = "xxxxxxx"; //replace xxxxxxx with your wifi ssid
      const char* password = "xxxxxxx"; //replace xxxxxxx with your wifi password
    3. Compile and upload the source code in NodeMCU or any ESP8266 you are using. You can use Arduino IDE to upload the code.



  1. Once your uploading process is completed, power up the circuit and reset the ESP once.
  2. Now ESP will connect to your router and it will show IP address of your ESP in OLED display.
  3. Install android application in your phone and open it, application link is given bellow in download section.
  4. Input IP address shown in OLED display and port i.e 80 in application page and hit connect button.
  5. Now you can operate relay from your phone and can connect any appliances to these relays. (consider relay amps rating )

 

Note: You can not use direct 5v relay in this project, because NodeMCU control output is only 3.3v which is not enough to trigger 5v relay. That is- why we are using relay  module to work on this project.

 



Downloads:

esp8266_relay_control.ino

Android application

Circuit diagram

]]>
https://blog.etechpath.com/how-to-operate-home-appliances-wirelessly-using-esp8266-and-android-phone/feed/ 0
DIY pendrive size WiFi repeater using ESP-01 ESP8266 module. https://blog.etechpath.com/diy-pendrive-size-wifi-repeater-using-esp-01-esp8266-module/ https://blog.etechpath.com/diy-pendrive-size-wifi-repeater-using-esp-01-esp8266-module/#comments Thu, 07 Sep 2017 19:38:19 +0000 https://blog.etechpath.com/?p=214 About:

In this project i am going to explain you how to build your own WiFi repeater to extend your home WiFi signal strength. This device is very easy to make and very handy to use. You can use this device at school, college, office or Cafe to extend the WiFi signal without buying expensive WiFi modems from the market.




Components you will need:

  1. ESP-01 or NodeMCU
  2. ASM1117 3.3V voltage converter IC
  3. Male USB connector
  4. USB-UART adapter for programming ESP-01
  5. Android or iOS phone to configure settings.

Circuit Diagram for Programming ESP-01 : 

esp-01_circuit

 

 

Steps: 

    1. Connect ESP-01 to UART adapter as shown in above diagram.
    2. Download firmware files form the bottom of the page, We will flash these files to ESP-01 using ESP flash tools.
    3. Firmware files are in rar folder, So unrar firmware files first and then open ESP flash download tools.
    4. Browse downloaded firmware files into given location as shown in bellow picture and write down where do you want flash the particular file, i.e select 0x00000.bin file and then write location to flash @0x00000 after that select 0x10000.bin file and locate it to 0x10000. (refer bellow screenshot for example)esp8266_repeater_diy
    5. select COM port and hit START button. (If you dont know how to use flash tool, Check this link on Getting started with ESP8266 to flash ESP-01)
    6. After flashing firmware to esp-01, disconnect the circuit and connect USB male port to ESP-01 as given in bellow circuit diagram.ESP-01_Repeater
    7. Now you can power this circuit using any 5v USB wall adapter. So power up this circuit and follow the further steps for configuring WiFi AP settings.
    8. Download Telnet Client Terminal application in your phone. Download links are given in download section at the bottom of this page.



  1. Power up the circuit, default device will create open access point with name MyAP without any password and default IP will be 192.168.4.1, Open WiFi settings in your phone and connect this open access point.
  2. Open Telnet Client Terminal in your phone and add two fields as IP: 192.168.4.1 and Port: 7777, hit connect button.
  3. If everything is ok, terminal will show connected. write command show and hit enter. It will show the current name and password of device STA and AP as shown in bellow screenshot.
  4. Use these commands to update the username and password of your STA and AP.
  • set ssid XXXXXXXX    (your home router SSID)
  • set password XXXXXXXX   (your home router password)
  • set ap_ssid  XXXXXXXX   (new access point name)
  • set ap_password  XXXXXXXX   (new access point password)
  • save    (save configuration)
  • reset   (reset device)
  • show     (this will show updated setting of your device, i.e your routers and access point  username and password)
  • quit     (terminates current remote session)

You are now done with the repeater configuration, reset the ESP once and it will connect your home router with updated ssid and password at the same time it will create an access point with your new access point name and password.



Downloads:

Firmware

ESP Flash Download Tools v3.4.4

Telnet Client Terminal  (Android) (iOS)

 

]]>
https://blog.etechpath.com/diy-pendrive-size-wifi-repeater-using-esp-01-esp8266-module/feed/ 1
How to program XS3868 audio bluetooth module using USB TTL module https://blog.etechpath.com/how-to-program-xs3868-audio-bluetooth-module-using-usb-ttl-module/ https://blog.etechpath.com/how-to-program-xs3868-audio-bluetooth-module-using-usb-ttl-module/#comments Mon, 04 Sep 2017 22:48:48 +0000 https://blog.etechpath.com/?p=205 About :

XS3868 is based on OVC3860 RF transceiver. OCV3860 is low voltage single chip Bluetooth RF transceiver providing Bluetooth stereo solution. OVC3860 is a 2.4GHz transceiver with Bluetooth V2 baseband and can transfer 20bit high quality audio codec. OVC3860 is fetured with inbuilt power management and support advance lithium ion batteries with switch regulator.




In this project we are going to learn how to program XS3868 audio Bluetooth module using TTL USB module. Here you will learn how to change the costume Bluetooth device name and the security password of XS3868 device.

 

Requirments :

  1. XS3868 module
  2. USB TTL serial module
  3. 3.7v li-ion battery or any 3.6v-4.2v voltage source
  4. LED with 470 Ohm resistor (optional)
  5. Compute (to communicate with the device)

 

Circuit Diagram :

xs3868_bluetooth_UART

 

Steps:

    1. Connect xs3868 with battery then wire its reset terminal with 1.8v output terminal of xs3868.
    2. As shown in diagram connect TX of xs3868 to RX of UART module and RX of xs3868 to TX of UART  module.
    3. At last connect UART module GND terminal to common ground of xs3868.



  1. Download  “OVC3860 RevD Develop” tool from link given bellow at download section.
  2. Connect UART module to your computer USB port and check the COM port number for UART device, if it is other than COM-1 then change it to COM-1 first. [Here’s How To]
  3. Open OVC3860 RevD Develop tool with administrative rights, you will see the window similar as below,OVC3860_RevD_Develop_tool
  4. Now reset xs3868 module from reset pin and you will see the your device connected in tool window with green circle on the top.
  5. Now scroll down to item Local Name and Pincode, this is your Bluetooth name and password.
  6. Change it to desired Bluetooth name and password as you want.
  7. Click Write ALL button in tool and if everything went right, you will get Success message pop up on screen.

 

Download Section:

  1. OVC3860 RevD Development tool
  2. OCV3860 AT-Command Set



]]>
https://blog.etechpath.com/how-to-program-xs3868-audio-bluetooth-module-using-usb-ttl-module/feed/ 5