Friday, March 6, 2015

Arduino + ESP8266 WiFi Web Server


Arduino + ESP8266 WiFi Web Server
ใช้ Arduino กับ ESP8266 ทำเป็น WiFi Web Server ควบคุมอุปกรณ์ต่างๆ
Arduino and ESP8266 WiFi Module to make Web Server for Web based Control Relay Output or other devices.



System Diagram


Hardware
1.Arduino MEGA Board ( or compatible board )
2.ESP8266 WiFi Module
3,Relay Board
4.LCD Display ( Option )


Wiring Diagram

Arduino Pin19  ( RX1 )  to ESP8266 pin UTXD
Arduino Pin18  ( TX1 )  to ESP8266 pin URXD


ESP8266 Pin Out



Procedure to make Web Server


Check Communication and Reset ESP8266 WiFi Module

use  AT+RST


Set Station Mode ( Mode 1)

use  AT+CWMODE=1


Connect WiFi Network

use AT+CWJAP="ssid","password" 


Set Multi point Mode

use AT+CIPMUX=1


Start Server and Set Port

use AT+CIPSERVER=1,port


Check Your IP Address

use AT+CIFSR 


Close All Socket

use AT+CIPCLOSE=0








AT Command Example Test to make TCP/IP Server 












Arduino ESP8266 WiFi  Web Server Example Code








My Website
email : info@softpowergroup.net   Tel .081-6452400

Saturday, February 14, 2015

WiFi Module ESP8266 AT-Command Test




WiFi Module ESP8266 AT-Command Test

ทดสอบการใช้งาน ESP 8266 wifi module ด้วย AT-Command

ESP8266 is Serial Port WiFi Module. It is very low cost.
Then we can use for many Application for Home Automation or IOT.


How to Test
You should use AT-Command to Test Module First.
So,you will know how to use At-Command and step to use ( set mode ,connect wifi, make server )


Hardware for test
You must have USB to RS-232 Converter ( I've one but I can't found it )
So,I decide to use Arduino board as USB to RS-232 Converter by remove MCU out form board.




ESP8266 WiFi Module use 3.3 V power supply and logic.
So,I use Arduino Duemilanove Board because it can set 3.3V power supply and logic.
(Then don't need the logic converter )

Or If you use Arduino 5V supply board such as Arduino UNO or other.
You need logic converter.



Wiring Diagram


ESP8266 PCB layout and pin out
Top Layer

Arduino Pin 0 (Rx)  to ESP8266 Pin URXD
Arduino Pin 1 (Tx)  to ESP8266 Pin UTXD

3.3 V to ESP8266 Pin CH_PD

and VCC 3.3V , GND



For Arduino 3.3V Power Supply and Logic




For Arduino 5V Power Supply and Logic ( Need logic Converter )


Software to Test
We use Arduino IDE and Serial Monitor to test. It 's work fine.
Set your Module Baud rate and Both NL and CR




use "AT" for check Communication
Response "OK"

use "AT+RST" for Software Reset Module
Response "OK"

use "AT+GMR" for check Firmware Version
Response "Firmware Version xxxxxxx"
Response "OK"

use "AT+CWMODE=1" for Set Mode 1 ( Station )
Response "OK"

use "AT+CWLAP" for check WiFi Network Available 
Response "Network Detail"
Response "OK"


AT+CWLAP
+CWLAP:(2,"NONGHOI_WIFI",-81,"24:a4:3c:70:ec:ae",1)
+CWLAP:(4,"DADADA",-93,"70:62:b8:2c:29:46",1)
+CWLAP:(0,".@  TRUEWIFI",-82,"00:02:6f:c3:29:10",11)
+CWLAP:(4,"3BB_Ruamluck",-69,"ec:cb:30:b5:15:44",2)
+CWLAP:(2,"true_homewifi_905",-92,"00:04:ed:ec:19:05",2)
+CWLAP:(0,"ESP_999686",-30,"1a:fe:34:99:96:86",11)
+CWLAP:(4,"Home_Control",-42,"64:66:b3:53:1a:c2",11)
+CWLAP:(0,"@TRUEWIFI",-79,"cc:5d:4e:b3:5e:00",3)
+CWLAP:(4,"dlink",-81,"cc:b2:55:92:74:a6",5)
+CWLAP:(3,"KONG",-93,"00:25:86:cf:e6:2e",6)
+CWLAP:(0,".@  TRUEWIFI",-92,"00:02:6f:c3:6e:78",7)
+CWLAP:(0,"EnGeniusA23E70_2",-90,"00:02:6f:c3:6e:79",7)
+CWLAP:(4,"NANZY",-68,"90:f6:52:92:0f:ee",9)
+CWLAP:(0,".@  TRUEWIFI",-82,"00:02:6f:bb:77:8c",11)
+CWLAP:(0,"EnGeniusA23E70_2",-81,"00:02:6f:bb:77:8d",11)
+CWLAP:(0,"EnGeniusA23E70_3",-82,"00:02:6f:bb:77:8e",11)
+CWLAP:(0,"@TRUEWIFI",-93,"00:02:6f:c3:29:0c",11)

OK



use AT+CWJAP="ssid","password"  to Connect WiFi Network 
Response "OK"


use AT+CIPMUX=1  set to Multi point Mode
Response "OK"

use AT+CIPSERVER=1,port  to Start Server
Response "OK"

use AT+CIFSR to check your IP Address
Response "IP Address"
Response "OK"

use AT+CIPCLOSE=0 to close all socket


Now You can use the Server.






My Website
http://softpowergroup.net/
email : info@softpowergroup.net   Tel .081-6452400
Google+  https://plus.google.com/+SoftpowergroupNetThailand/

Tuesday, December 30, 2014

Arduino USB Control with Firmata




Control RGB LEDs ( Arduino Uno )



Arduino USB Control with Firmata Library

Arduino Firmata Library is source code to communicate or control Arduino Board with other device.

Firmata is already include in your Arduino IDE.




Firmata Test Program
This "firmata_test" program works with boards running StandardFirmata version 2.2 or higher on standard Baud rate 57600.

For Linux (32 bit)

For Linux (64 bit)

For Mac OS-X

For Windows

Source code
http://www.pjrc.com/teensy/firmata_test/firmata_test_OSL.tgz (unicode compatible, by Orion Lawlor)




We Test on Windows ( see VDO above )

First Program Firmata Code to Arduino Board.

Open Arduino IDE ( we use Arduino 1.0.6 )


Goto File > Examples > Firmata > StandardFirmata




Then Upload to your Arduino Board



Open Firmata Test Program ( we test on Windows )



Connect USB to your Arduino Board then Select port.




Ready To Control




Android USB Control with Firmata







Firmata Command


Methods


begin()
start the library
begin(long)
start the library and override the default baud rate
printVersion()
send the protocol version to the host computer
blinkVersion()
blink the protocol version on pin 13
printFirmwareVersion()
send the firmware name and version to the host computer
setFirmwareVersion(byte major, byte minor)
set the firmware name and version, using the sketch's filename, minus the .pde

Sending Messages

sendAnalog(byte pin, int value)
send an analog message
sendDigitalPorts(byte pin, byte firstPort, byte secondPort)
send digital ports as individual bytes
sendDigitalPortPair(byte pin, int value)
send digital ports as one int
sendSysex(byte command, byte bytec, byte* bytev)
send a command with an arbitrary array of bytes
sendString(const char* string)
send a string to the host computer
sendString(byte command, const char* string)
send a string to the host computer using a custom command type

Receiving Messages

available()
check to see if there are any incoming messages in the buffer
processInput()
process incoming messages from the buffer, sending the data to any registered callback functions
attach(byte command, callbackFunction myFunction)
attach a function to an incoming message type
detach(byte command)
detach a function from an incoming message type

Callback Functions

In order to attach your function to a message type, your function must match the standard callback function. There are currently three types of callback functions in Firmata: generic, string, and sysex.
generic
void callbackFunction(byte pin, int value);
system_reset
void systemResetCallbackFunction(void);
string
void stringCallbackFunction(char *myString);
sysex
void sysexCallbackFunction(byte pin, byte byteCount, byte *arrayPointer);

Message Types

These are the various message types that you can attach functions to.
ANALOG_MESSAGE
the analog value for a single pin
DIGITAL_MESSAGE
8-bits of digital pin data (one port)
REPORT_ANALOG
enable/disable the reporting of analog pin
REPORT_DIGITAL
enable/disable the reporting of a digital port
SET_PIN_MODE
change the pin mode between INPUT/OUTPUT/PWM/etc.
FIRMATA_STRING
C-style strings, uses stringCallbackFunction for the function type
SYSEX_START
generic, arbitrary length messages (via MIDI SysEx protocol), uses sysexCallbackFunction for the function type
SYSTEM_RESET

message to reset firmware to its default state, uses systemResetCallbackFunction for the function type


My Website
http://softpowergroup.net/
email : info@softpowergroup.net   Tel .081-6452400
Google+  https://plus.google.com/+SoftpowergroupNetThailand/

Wednesday, November 19, 2014

Arduino and 128x64 GLCD




Arduino and 128x64 Graphic LCD

Hardware

1.Arduino Board
2.128x64 Graphic LCD Module (controller  KS0108 Chip or Equivalent ) ST7920  SBN6400G , SBN0064G


We use this model http://www.es.co.th/detail.asp?Prod=13502884 from Electronic Source Thailand


Data Sheet http://www.es.co.th/Schemetic/PDF/LCD128G064A.PDF



Wiring Diagram



 GLCD Pinout



Add VR10K to adjust Brightness.




Connect to Arduino



For Arduino Mega
Arduino Pin 22   for  D7
Arduino Pin 23   for  D6
Arduino Pin 24   for  D5
Arduino Pin 25   for  D4
Arduino Pin 26   for  D3
Arduino Pin 27   for  D2
Arduino Pin 28   for  D1
Arduino Pin 29   for  D0
Arduino Pin 33   for  CS1
Arduino Pin 34   for  CS2
Arduino Pin 35   for R/W
Arduino Pin 36   for  RS
Arduino Pin 37   for  EN

Arduino Pin 13  for LCD Back Light Control



Software ( Arduino Library )



Arduino GLCD Library Version3 ( or AVR Controller )

Download https://code.google.com/p/glcd-arduino/downloads/list



GLCD-Arduino has the following features:
  • Support for Arduino 1.x (still works with pre 1.x IDEs)
  • Support for Mega 2560, Sanguino and Teensy boards
  • Easier pin assignment. Any pin can be assigned to any glcd function.
  • Accurate/Consistent font rendering of any font size on any pixel location.
  • User definable text areas
  • Up/Down text scrolling
  • Circle functions
  • Additional example and demo sketches including a diagnostic sketch
  • Fully search-able documentation in HTML format
  • Pins can optionally be assigned by AVR port and bit instead of Arduino pin number.
  • Supports fixed width fonts that provides up to 8 x 21 character display with the supplied system font.
  • CursorTo method to position the cursor to a given font location (fixed width fonts only)
  • DrawBitmap function to display bitmap images stored in Flash memory. A Processing utility is provided in the download to convert a monochrome bitmap file to a header file that stores the image in flash for use by the DrwBitmap method.


Create Font  use GLCD Font Creator 2
Use this program https://code.google.com/p/glcd-arduino/downloads/detail?name=GLCDFontCreator2.zip



How to Create Font in other Language


FONT 8 x 8

FONT 14 x 20


Example in Thai language
I've edit GLCD Font Creator 2 for Thai language only. ( Java Code )






My Website
http://softpowergroup.net/
email : info@softpowergroup.net   Tel .081-6452400
Google+  https://plus.google.com/+SoftpowergroupNetThailand/

Monday, November 3, 2014

Arduino and TFT LCD Display Module



Arduino TFT LCD Display Module Test

Hardware
1.Arduino UNO Board or Compatible
2.TFT LCD 2.2 inch  from Elecfreaks ( Model  TFT01-2.2SP )
http://www.elecfreaks.com/store/22%E2%80%99-tft-lcd-tft0122sp-p-672.html


Description:

TFT LCD module has always been one of the hot products in DIY industry and LCD is basically the necessary products during all projects, at the same time, serial port modules are also the popular ones, because it takes few IO and the usage is simple. This section of the 2.2S-inch TFT LCD serial SPI integrated features of compact, SPI interface, fully compatible with popular LCD5110 interface cable sequence, and will replace the increasingly reducing LCD5110.

Feature:

TFT01_2.2 SP is a 2.2 "SPI TFT LCD Screen Module, 10pins interface, compatible LCD5110 interface. Not just a LCD break but include SD card (2GB),
The LCD in the TFT01 is ILI9341. It's a 240 * 320 (resolution), 2.2S inch TFT LCD screen.The LCD has a wide viewing angle, the contrast is also very suitable.

The display interface is serial, it just needs 5 wires (CS, RS, SCL, SDA, RST) for controlling.
Replace LCD5110, Support direct plug in ElecFreaks Joystick shield, EFCom, Key Pad Shield etc
SDcard use hardware SPI interface (CS / MOSI / MISO / SCK), Not solder pins.
Parameter:

SDO: Serial clock output
LED: 3.3V IO and Power Supply pin
SCL: Serial clock input
SDA / SDI: Serial data input
DC: Data / Command selection
RST: Reset, Low level active
CS: Chip Selection, Low level active
GND: Ground
VDD33: 3.3V Power Supply pin
UTFT Support


Wiring Diagram





TFT Pin SDO<MISO>     Not Used

TFT Pin LED                   To  VCC 3.3V

TFT Pin SDI<MOSI>      To Arduino PIN D9

TFT Pin SCK                   To Arduino PIN D8

TFT Pin D/C                    To Arduino PIN D10

TFT Pin RESET              To Arduino PIN D11

TFT Pin CS                      To Arduino PIN D12

TFT Pin GND                  To Arduino PIN GND

TFT Pin VCC                  To Arduino PIN 3V3


Software

Driver UTFT Library  by Henning Karlsen
http://henningkarlsen.com/electronics/library.php?id=52

his library is the continuation of my ITDB02_Graph, ITDB02_Graph16 and RGB_GLCD libraries for Arduino and chipKit. As the number of supported display modules and controllers started to increase I felt it was time to make a single, universal library as it will be much easier to maintain in the future.


Download Source code



My Website
http://softpowergroup.net/
email : info@softpowergroup.net   Tel .081-6452400
Google+  https://plus.google.com/+SoftpowergroupNetThailand/