Saturday 26 November 2016

Internet of Things using ESP8266

Internet of Things using ESP8266

ESP8266 is the serial WiFi module which can be interfaced to the Microcontroller using UART.
In my Earlier post i have given configuration steps of wifi module you can refer it 
Wifi Module though operates at 3.3V but Tx and Rx pins operates at TTL level.ARM Cortex M3 based controller operates at CMOS level hence a level-translator is  required. CD4050 ic can be used as level translator for this Tx of Microcontroller must be given as input to CD4050 and o/p of CD4050 must be connected to Rx of esp8266.
Tx of esp8266 can be connected to Rx through 10K resistor.


Internet of Things : Connectivity of things sensors connected to controller can independently convey information to the controller based on which necessary action can be taken. If same information is transferred to a webserver which can host that data, user can have access to that data from any location over internet.



To achieve Internet of things an IOT cloud is required there are so many free IOT sites that can be used for implementing IOT. Here i will show one site https://thingspeak.com

1) Create an account in https://thingspeak.com

2)Create New Channel in Thingspeak on success it will assign a unique channel id
   provide name and description of IOT leave others fields in default mode.
3) Go to API keys: these keys are essential for updating data on server.
4) you can test by adding sample data to the created field on site
open browser and type 
https://api.thingspeak.com/update?key=API_KEY&filed1=6
replace API_KEY with actual key that you will get in your channel and press enter
if you check in your channel you can find a sample value of 6 will be added to graph1 with Date& Time.

5) Using esp8266 establish TCP connection with the thingspeak server (184.106.153.149)

List of AT command you have to pass to esp8266 using ARM Cortex M3 based controller
you can use UART program to pass commands consider uartStr ("string"); is the function to push AT commands on Tx Line of Microcontroller. Assume communication baudrate as 9600

List of commands you should pass after each command give a delay of 100 to 1000milli seconds

1) uartstr("AT\r\n"); //note \r\n are must for passing commands to esp8266
it will respond with OK

2)uartstr("AT+CWLAP\r\n"); // will list available Access points

3)uartstr("AT+CWMODE=3\r\n"); //Both SERVER and Access point

4)uartstr("AT+CIPMUX=1\r\n"); //to allow multiple connections  for communication

5)uartstr("AT+CWJAP=\"name\",\"password\"\r\n"); //connect with Internet provider access point or wifi  router, where name should be name of access point or wifi router and password should be relevant password

6)uartstr("AT+CIPSTART=4,\"TCP\",\"184.106.153.149\",80\r\n"); //for establishing TCP connection with thingspeak site
you should get response of OK Linked
7)uartstr("AT+CIPSEND=4,44\r\n"); //command to send data on channel4 of size 44bytes
as response you will get ' >' 
8)uartstr("GET /update?key=API_KEY&field1=6\r\n");//note replace API_KEY with your channel API_KEY this will update field1 with 6 

9) uartstr("AT+CIPCLOSE\r\n"); //for closing connection with server

   
    download code

Sunday 30 October 2016

USB Boot Loader (Device-Firmware-Upgrade) for STM32F103C8T6

USB Boot Loader (Device-Firmware-Upgrade) for                                                  STM32F103C8T6

STM32F103C8T6 is most popular cheap and best micro-controller based on ARM-Cortex-M3 core
It is also called as minimum development board or Bluepill it can be used to do mini projects.
from ST official website you can get datasheet and software for this board.Key features of this board 
it got multiple serial communication protocols like
1) USART   2) USB     3)SPI     4)I2C     5)CAN
also has 7-channel DMA support with moderate on chip memory of RAM-20KB, FLASH-64KB
by default it has USART bootloader.
To program it through USART ISP one should set two yellow jumpers in above diagram in following position
Boot0-High
Boot1-Low

For programming this device either you can use ST-Link or USB to TTL Serial Converter 



It also has Micro USB port but by default it can be used only to supply power to board. Here i will show how to add secondary bootloader to STM32F103C8T6 (bulepill) board so that you can use same USB cable to power up as well as to program board at the expense of loss of  few KB  flash. First 12KB of flash will be occupied by this secondary boot loader.

Softwares that are required to add DFU support to STM32F103C8T6 
1) STM FlashLoader- Download from STsite   
2) STM USBdfuse - Download from STsite
note you should register to download from ST which is simple process (free)
3) IDE i will use Keil uv , you can get it from here  select STM32F1xx pack
4) STM DFU Firmware.hex - Download
Initially Install first three softwares  after installation you may find STMicrocontroller
 softwares in this path C:\Program Files (x86)\STMicroelectronics\Software
just go to Flash Loader Demo folder and pin STMFlashLoaderDemo.exe to task bar
similarly go to DfuSe v3.05 folder -> Bin folder  and pin DfuFileMgr.exe and DfuSe Demo.exe to Taskbar. 
Then open  STM FlashLoader to flash controller with STM DFU Firmware.hex
Initially this has to be done through USART0 
pins PA9-Tx of board must be connected to Rx of USB to Serial Converter
pins PA10-Rx of board must be connected to Tx of USB to Serial Converter
and by keeping Boot0 high Boot1 low press reset 
open FlashLoader.exe
you should get this kind of info on screen
Press reset button on board  and click on next  
you should get response like this
If you get no response from device
Troubleshoot: then click on ok and change echo to echo mode press reset and click next again you will get no response. This time revert it to echo disabled and press reset on board and immediately click next you will get above mentioned response.
   then click next

It will recognize STM32F103C8T6 as medium density device click next

check Download to device and click on open  menu to select DFU.hex
click next.
you should get response as Download operation finished successfully then click on close.
now change boot0 position to logic 0 .
Go to C:\Program Files (x86)\STMicroelectronics\Software 
DfuSe v3.05 folder and click on drivers based on Processor type 64 or 32bit and Windows type go to appropriate Drivers folder and install drivers.

Since it is secondary bootloader entrypoint is based on PB9 pin when you connect USB to system make sure that PB9 kept floating If it is connected to ground DFU drivers will be skipped and application code will be executed.


open DFUse Demo you should see Internal flash of 64KB 
Since Secondary bootloader takes 12KB you have to follow few modifications in application code

System_stm32f10x.c change VECT_TAB_OFFSET to  0x3000

under options for target change IROM from 0x8000000 to 0x8003000 

also check Linker option use memory layout from target dialog
thats it click on to generate hex 

and open DFU file manager to convert Hex to DFU file



then click on generate .dfu file
save with some name and extension as .dfu it will give success message

then use Dfuse demo to upload code in to flash



check on Verify after download and Optimize Upgrade duration
you should get verify successful then click reset so that application code will be executed
 that's it you can do program by using same usb cable


  Programming Tutorial can be followed from here

NOTE: DFU.hex is password protected whoever wants it can post their email id under comments section. 

Indonesia -done
Ukraine-done
Russia-done
Czech republic-done
Argentina-done
I am glad that I could interact with people of these countries.Hopefully I could help somemore in future.

Wednesday 26 October 2016

Interactive Voice Response system

Interactive Voice Response System (Automation using GSM-DTMF Decoder)

Old is Gold, Old model GSM phones(2 quantity) can be used to make this simple automation project.
Modules required:
Old Model GSM phones (2)
DTMF Decoder Module(1)
Microcontroller(1)
Voice Record and Playback module(1)

 In old mobile phones each key is associated with two frequencies those frequencies can be decoded by using DTMF Decoder. Also to guide user Voice record and playback module is required

1) Old Model GSM phone:
Old Model phone must be configure with following settings
 - Settings->Keypad Tone->set it to maximum value
- Settings-> Enhancement Setting-> set Auto Answer option on headset

2) Voice Record and Playback module:
In this project i used APR33A3 which has 8 channels and can record audio of 1.2Mins duration
record some voice in each channel like instructions
 - Press 1 to turn on Light
 - Press 2 to turn off Light
 etc there is toggle switch to select record/playback mode
while recording select record mode and also each channel is provided with press button
hold particular channel press button to record voice
then change toggle switch to playback mode
and give active low signal to previously recorded channel then you can get recorded voice

3) Interface DTMF Decoder APR33A3 modules to Microcontroller as shown


Call to Mobile phone which is conected to DTMF decoder then automatically it will lift the
call that will activate APR33A3 module that will guide user accordingly  press particular key in
your mobile phone that will be decoded by DTMF decoder. based on that microcontroller has to controll electrical appliances.





download code-here

Saturday 9 July 2016

Notice Board Display using ESP8266

Notice Board Display using Wi-Fi


Wi-Fi(Wireless-Fidelity) is a Wireless communication protocol part of IEEE 802.11 standard
Wi-Fi is commonly used to create ad-hoc  network by creating access point.Unlike Bluetooth Many wifi devices can connect to same access point. ESP8266 is a Serial Wi-Fi module.
It has eight pins starting from 
Row-1
Top right (1) Vcc(3.3v) level sensitive  
Top left (2) Rx 
Row-2
 Right(3) Reset - connect it to 3.3v for normal operation
 Left (4) GPIO1 - Can be used as I/O
Row-3
 Right(5) CH_PD- connect it to 3.3v for normal operation
 Left(6) GPIO2- Can be used as I/O
Row-4
Right(7) Tx
Left(8) Gnd

Similar to Bluetooth configure Wi-Fi in AT command mode 
using USB-TTL converter 
 CoolTerm software

1. AT - OK
2. AT+CIOBAUD ?
GIVES COMMUNICATION BAUD RATE
3. AT+CIPMUX=1
CONNECT WITH MANY DEVICES
4. AT+CWMODE=3
STATION+ACCESS POINT
5. AT+CIFSR
GIVES DEVICE IP
6.AT+CWSAP="NAME","PASSWORD",5,3
TO CREATE ACCESS POINT
7.AT+CIPSERVER=1,80
START SERVER AT PORT-80




Once Configured through USB to Serial Converter. Connect your Android phone to esp8266 serial over wifi. Then open Telnet app and enter wifi IP and Port number here it is
IP: 192.168.4.1
Port: 80
then click on connect to server


then link will be established you can pass what ever message you want 
if you observe output on coolterm unlike bluetooth it is not a straight forward message along with message you can see some  redundant data like +IPD,0,13:  OK 

 which should be avoided  when you display it on lcd. So clearly from format character ':' indicates beginning of message and use some special char for termination of message in this example i used '#'


store entire message in string and then display it on lcd. In this way you can do this project

Downlode code - Here


Friday 8 July 2016

Projects

Projects

1.Automation using WiFi - Click Here

2.Automation using Bluetooth-   Click Here

3. Notice Board display using Bluetooth  - Click Here

4.Automatic Railway Level crossing Control System - Click Here

5.Gas Sensor Based Automation - Click Here

6. Automation using GSM - Click Here

7. Automatic Irrigation System using Soil Sensor - Click Here

8. Automatic Water-Level Indicator using Water Sensor - Click Here

9. Obstacle Detection using UltraSonic Sensor - Click Here

10. Digital Clock Using Timer - Click Here

11. Digital Thermometer using LM35 - Click Here

12. Speed Control of DC Motor - Click Here

13. Automatic Street Light Control - Click Here

14. Electronic Voting Machine - Click Here

15. Music Generation using Buzzer - Click Here

16. Motion Detection using Accelerometer - Click Here

17. Notice Board Display using GSM - Click Here

18. Notice Board Display using Wi-Fi - Click Here

19. Internet of Things - Click Here

20. Interactive Voice Response System - Click Here

21. Authentication System using RFID - Click Here


Sunday 3 July 2016

Automation using Wi-Fi

Automation using Wi-Fi


Wi-Fi(Wireless-Fidelity) is a Wireless communication protocol part of IEEE 802.11 standard
Wi-Fi is commonly used to create ad-hoc  network by creating access point.Unlike Bluetooth Many wifi devices can connect to same access point. ESP8266 is a Serial Wi-Fi module.
It has eight pins starting from 
Row-1
Top right (1) Vcc(3.3v) level sensitive  
Top left (2) Rx 
Row-2
 Right(3) Reset - connect it to 3.3v for normal operation
 Left (4) GPIO1 - Can be used as I/O
Row-3
 Right(5) CH_PD- connect it to 3.3v for normal operation
 Left(6) GPIO2- Can be used as I/O
Row-4
Right(7) Tx
Left(8) Gnd

Similar to Bluetooth configure Wi-Fi in AT command mode 
using USB-TTL converter 
 CoolTerm software

1. AT - OK
2. AT+CIOBAUD ?
GIVES COMMUNICATION BAUD RATE
3. AT+CIPMUX=1
CONNECT WITH MANY DEVICES
4. AT+CWMODE=3
STATION+ACCESS POINT
5. AT+CIFSR
GIVES DEVICE IP
6.AT+CWSAP="NAME","PASSWORD",5,3
TO CREATE ACCESS POINT
7.AT+CIPSERVER=1,80
START SERVER AT PORT-80







Microcontroller pins cannot drive relay directly hence a driver circuit is required.
Driver should have good current gain. CE or CC configuration is preferred
Relay has 5 terminals 
1. Vdc - 5v
2.Gnd- connect it to  Collector pin of BJT
3. Common - Connect it to AC/DC source
4. NC- Normally close connect it to load1 
5. NO- Normally open connect it to load2

or else connect only one load to any of these two pins (4,5)
so that you can switch only one device at a time.


Download-code