วันอังคารที่ 23 พฤษภาคม พ.ศ. 2560

mq-02 detect smoke and alert to mobile app

mq-02 detect smoke and alert to mobile app



mq-02  detect smoke and alert to mobile app ,then the sound level from buzzer and the brightness from led 10mm depend on the level of volt which receive value from map funciton of arudino , the arduino reading from MQ2 sensor  respectively

mobile app receive value form bluetooth,display a sensor value if a  value more than a threshold value then sound and vibration with red color of  text box.you can take picture for a hazard place.

thanks for watchiing.

link aia file, apk file , ino file
https://drive.google.com/folderview?id=0BzjoxIwEMrM-NE9aWnotdGFuZVU&usp=sharing

ai2 block image
https://drive.google.com/file/d/0BzjoxIwEMrM-MEx2TGxSODFPdDg/view?usp=sharing

credit
http://www.arduinoall.com/product/274/passive-buzzer
http://ai2.appinventor.mit.edu/     

วันจันทร์ที่ 22 พฤษภาคม พ.ศ. 2560

ESP8266-12F w/ WebConfig and Control Page , display and Alarm Sound on ...



ESP8266-12F w/ WebConfig  and Control Page + PIR Motion (HC-SR501) , display and Alarm Sound on the Web Browser(PC, Mobile)

Demonstration(Short example clip , what it can do)
***Sorry, Details of Code and Hardware Wire will be shown as soon,Thanks


***ESP8266-12F + PIR Motion (HC-SR501) , display and Alarm Sound on the Web Browser(PC, Mobile)

***Sorry, Details of Code and Hardware Wire will be shown as soon,Thanks

- Alarm Security with Pir Sensor (HC-SR501)
Display and send audio detection via web browser (here using Google Chrome Version 58.0.3029.110 (64-bit))
-WebConfig for setting ssid,pwd , select fixed ip or dynamic ip given from the router
-Timer system for on/off the motion detect system and  on/off the electric device via the relays. (it has 2 relays )
-display temperature in Celceius degree.
-can setting the timer via the web or the OLED + Keypad4x4
-can to apply for other for related fields.

***Main Devices List
-ESP8266-12E, ESP8266-12F  + PCB Adaptor for esp8266-12e
-Alarm Security with Pir Sensor (HC-SR501)
-DS3231 RTC module
-OLED 0.96"  128x64px
-Matrix Keypad4x4
-PCF8574AT IO expender x 2
-Active Buzzer 5vdc
-Relays 2 channel with opto-isolate
-2 LED 5mm
-NPN 2N2222 x 2
-NPN BC547  x 2
- R, C

**Related Clip
-Assemble parts together and flashing fw. Esp8266-12e,12f + PCB ADAPTER + XC6206P Regulator
https://youtu.be/GJLV1nkl-UU

-Timer system with nodeMCU (Turn on/off the power by setting the timer) , 2 periods timer / an relay
https://youtu.be/JHD-qtlMAlQ

-nodeMCU v2 +Keypad 4x4 + PCF8574AT( io expender), use 2 wires only.
https://youtu.be/lDhUqzp4410

คลิปทดสอบตัวอย่างสั้นๆ  Alarm Security with Pir Sensor
- ระบบตรวจจับความเคลื่อนไหว PIR Motion Sensor Module (HC-SR501) + ESP8266-12F(esp-12f) แสดงผลและส่งเสียงการตรวจจับ ผ่านหน้า Web browser (ในที่นี้ ใช้ Google Chrome Version 58.0.3029.110 (64-bit))
- web config สำหรับ กำหนดค่า ssid,pwd เลือกโหมด รับ ip หรือ fix ip addr
- ตั้งเวลา on/off สำหรับ motion detect และหรือควบคุมอุปกรณ์ไฟฟ้าอื่นๆผ่านรีเลย์สวิทย์
-แสดงผล อุณหภูมิ
-สามารถตั้งเวลา Timer system ผ่านทางเวป หรือ ผ่านทาง จอ OLED+Keypad4x4
-ฟังกชั่นอื่นๆ เช่น เปิดปิดหน้าจอ OLED , on/off ,DateTime,Timer system อื่นๆ ผ่านทาง OLED+Keypad
-สามารถนำไปประยุกต์การใช้งานอื่นๆได้ตามสมควร
**รายละเอียด Code และ Hardware Wire จะทำมาแสดงในไม่ช้า ขอบคุณครับ

credit:
http://www.instructables.com/id/PIR-Motion-Sensor-Tutorial/







วันเสาร์ที่ 20 พฤษภาคม พ.ศ. 2560

knowledge,technic, how to play audio file from link of dropbox, workaround for play audio in chrome browser of mobile when page loaded

how to play audio file from link of dropbox

1.upload your audio file as 'mp3 or ogg' to dropbox
2.open share on it
3.copy link as  
  hhttps://www.dropbox.com/s/0m8xqg47gxmf325/Alarm1.mp3?dl=0

 *** change dl=0 to dl=1 for play online stream

  https://www.dropbox.com/s/0m8xqg47gxmf325/Alarm1.mp3?dl=1

in code html

<!DOCTYPE html>
<html onclick="play()">
<head>
</head>
<body>
<audio id="sound" src="https://www.dropbox.com/s/0m8xqg47gxmf325/Alarm1.mp3?dl=1"></audio>
<script>
var audiofile= document.getElementById('sound');
function play(){audiofile.play();}
</script>
</body>
</html>

how to play audio when page loaded in chrome browser of mobile
1.
<script>
var AlarmS=2;  //global var
</script>
<body onloadeddata='AlarmS=0;play_s();'>

2.

<span class='chk'><input  type='checkbox' class='chk' id='chk_Alsnd' onclick=\"func_AlarmSoundOn();\" disabled>Alarm Sound<button type='button' onclick='var PreA=AlarmS;AlarmS=1;play_s();AlarmS=PreA;'>listen!</button></span>



3.

 function func_AlarmSoundOn() {
    var x =  document.getElementById('chk_Alsnd');
    if (x.checked==true){
AlarmS=0;
        play_s();
}else{
   AlarmS=2;
}

}

4..

function play_s(){
var au= document.getElementById('sound');
switch(AlarmS)
{
case 0:
au.volume=0.0;
au.play();
au.pause;
AlarmS=1;
break;
case 1:
au.volume=1.0;
au.play();
break;
default:
break;
}

}


//--------the following code  is example  ------------------
//          this code not use jquery due to it must  run in local wifi (not internet connected)
//          and limit of flash memory not more space
//------------------------------------------------------------------


<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<style>
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}

li {
    float: left;
}

li a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
cursor:pointer;
}

li a:hover:not(.active) {
    background-color: #111;
}

.active {
    background-color: #4CAF50;
}

div.card {
  display:inline-block;
  width: 250px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  text-align: center;
}

.chk {
 display:inline-block;
}

div.header {
    color: white;
    padding: 10px;
    font-size: 40px;
}

.button_card {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
width: 100px;
}

</style>


<script>
var AlarmS=2;
function loadDoc(url, cFunction,iid) {
setClassActiveA(iid);
  var xhttp;
  xhttp=new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      cFunction(this);
    }
  };
  xhttp.open('GET', url, true);
  xhttp.send();
}
function myFunction(xhttp) {
  document.getElementById('area1').innerHTML = xhttp.responseText;
}

function setClassActiveA(iid) {
     var myNodelist = document.getElementsByTagName('a');
    var i;
    for (i = 0; i < myNodelist.length; i++) {
        myNodelist[i].setAttribute('class', 'noactive'); 
    }
document.getElementById(iid).setAttribute('class', 'active');
}


function loadDocBtnClick(url, cFunction,myid) {
  var xhttp;
  xhttp=new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      cFunction(this,myid);
    }
  };
  xhttp.open('GET', url, true);
  xhttp.send();
}
function myFunction_btn(xhttp,myid) {
   document.getElementById(myid).innerHTML = xhttp.responseText;

}



</script>

</head>

<body onloadeddata='AlarmS=0;play_s();'>

<audio id='sound' src='https://www.dropbox.com/s/0m8xqg47gxmf325/Alarm1.mp3?dl=1'></audio>
<ul>
  <li><a class='noactive'  id='home' onclick=\"loadDoc('home',myFunction,this.id);\">Home</a></li>
  <li><a class='noactive'  id='timers' onclick=\"loadDoc('timers',myFunction,this.id);\">Timers</a></li>
  <li><a class='noactive'  id='setting' onclick=\"loadDoc('webconfig',myFunction,this.id);\">Setting</a></li>
  <li><a class='noactive'  id='about' onclick=\"loadDoc('about',myFunction,this.id);\">About</a></li>
</ul>
<span class='chk'><input class='chk' type='checkbox' id='chk_autorefresh' onclick=\"func_autorefresh();\" >Auto Refr./Motion State.
<select id='sel_sec'  onchange='document.getElementById(\"chk_autorefresh\").checked=false;func_autorefresh();'>
<option value='2000'>2s</option>
<option value='3000'>3s</option>
<option value='5000' selected>5s</option> 
<option value='10000'>10s</option> 
<option value='15000'>15s</option> 
<option value='30000'>30s</option> 
<option value='60000'>1m</option>
<option value='300000'>5m</option> 
<option value='600000'>10m</option>  
</select>(4C)</span><span class='chk'><input  type='checkbox' class='chk' id='chk_Alsnd' onclick=\"func_AlarmSoundOn();\" disabled>Alarm Sound<button type='button' onclick='var PreA=AlarmS;AlarmS=1;play_s();AlarmS=PreA;'>listen!</button></span>
<br/><br/>
<div id='area1'>
</div>
<script>
 loadDoc('home',myFunction,'home');

 var vRefresh;
 function func_autorefresh() {
    var opt_selsec = document.getElementById('sel_sec').value;
var y =  document.getElementById('chk_Alsnd');
    var x =  document.getElementById('chk_autorefresh');
    if (x.checked==true){
vRefresh = setInterval(do_Autorefresh ,opt_selsec);
y.disabled=false;
}else{
   y.disabled=true;
clearInterval(vRefresh);
}
}

 function func_AlarmSoundOn() {
    var x =  document.getElementById('chk_Alsnd');
    if (x.checked==true){
AlarmS=0;
        play_s();
}else{
   AlarmS=2;
}
}

function do_Autorefresh() {
 loadDocBtnClick('ctrl_dev?control=000',motion_detected,'msg_motion');
}

function motion_detected(xhttp,myid) {
var myJSON=JSON.parse(xhttp.responseText);
document.getElementById('t1').innerHTML =myJSON.t1;
document.getElementById('info_motion').innerHTML =myJSON.info_motion;
document.getElementById('info_relay').innerHTML =myJSON.info_relay;
document.getElementById('info_line').innerHTML =myJSON.info_line;

var x = document.getElementById(myid);
var y = document.getElementById('motion_msg_card');
    if(myJSON.msg_motion=='0')
{
x.innerHTML = '...';
x.style.color = 'black';
y.style.backgroundColor = 'white';
}
else
{
x.innerHTML = myJSON.msg_motion.replace(/-/g,\":\");
x.style.color = 'black';
y.style.backgroundColor = 'red';
play_s();
}
}

function play_s(){
var au= document.getElementById('sound');
switch(AlarmS)
{
case 0:
au.volume=0.0;
au.play();
au.pause;
AlarmS=1;
break;
case 1:
au.volume=1.0;
au.play();
break;
default:
break;
}
}


function SaveTimer(mychanel) {
var t1on,t1off,t2on,t2off,mystr;
switch(mychanel)
{
case 1:
    {
  t1on=document.getElementById('ch1timer1on').value;
  t1off=document.getElementById('ch1timer1off').value;
  t2on=document.getElementById('ch1timer2on').value;
  t2off=document.getElementById('ch1timer2off').value;
  t1enable=document.getElementById('ch1timer1enable').checked; 
       t2enable=document.getElementById('ch1timer2enable').checked;       
break;
}
case 2:
{
  t1on=document.getElementById('ch2timer1on').value;
  t1off=document.getElementById('ch2timer1off').value;
  t2on=document.getElementById('ch2timer2on').value;
  t2off=document.getElementById('ch2timer2off').value; 
  t1enable=document.getElementById('ch2timer1enable').checked; 
       t2enable=document.getElementById('ch2timer2enable').checked;    
break;
}
}
mystr='ch=' + mychanel + '&t1on=' + t1on + '&t1off=' + t1off + '&t2on=' + t2on + '&t2off=' + t2off  + '&t1enable=' + t1enable + '&t2enable=' + t2enable;

document.getElementById('info').innerHTML = 'processing...';
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById('info').innerHTML = 'processing...OK!';
 alert(this.responseText);
    }
  };
  xhttp.open('POST', 'save_timer', true);
  xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  xhttp.send(mystr);
}

</script>

</body>

</html>

วันจันทร์ที่ 15 พฤษภาคม พ.ศ. 2560

Assemble parts together and flashing fw. Esp8266-12e,12f + PCB ADAPTER +...



Assemble parts together and flashing fw. Esp8266-12e,12f + PCB ADAPTER +
XC6206P Regulator

***sorry , for cc(closed caption ) as soon.

-รวมชุด esp8266-12e,12f เข้ากับ pcb adaptor  (กรณี Vcc=5v ติดตั้ง ldo regulator แปลงเป็น 3.3v) สุดท้ายจะทำการ flash firmware ด้วย

-flash ด้วย
1. ft232rl (usb to ttl) สำหรับ Vcc 3.3v (กรณี esp ไม่มี ldo regulator) และ 5v( esp82266 ที่มี ldo regulator)
2. witty cloud mini nodemcu ใช้ power supply board ของ witty clound มาใช้ flash firmware  ให้กับ esp82266 ที่มี ldo regulator

This clip is about:
-How to flash esp8266 firmware.
-How to flash esp8266 12e.
-Assemble part together  an Esp8266 module ,  PCB ADAPTER and  XC6206P Regulator.
-Flash with usng ft232rl(for Vcc of esp 3.3v /5v).
-Flash with Witty Cloud power supply board(for Vcc of esp 5v).


Note. This adapter  but not soldered or any additional wires for  pin CH_PD ,GPIO15 if you want.
This adapter existed
1. CH_PD is pulled to Vcc by 10k resistor (so module start working after You provide Vcc).
2. GPIO15 is pulled down to GND by 10k resistor.
So to burn new flash image just connect GPIO0 to GND during start.
ref. https://nettigo.eu/products/pcb-adapter-for-esp8266-modules


ref. http://th.element14.com/torex/xc6206p332pr/v-reg-ldo-0-25a-3-3v-smd-sot-89/dp/8796998
TOREX  XC6206P332PR  Fixed LDO Voltage Regulator, 1.8V to 6V, 250mV Dropout, 3.3Vout, 200mAout,

SOT-89-3
 The XC6206P332PR  (linear ,low dropout-regulator)  is a 3-terminal highly precise low power consumption

Positive Voltage Regulator manufactured using CMOS and laser trimming technologies. The XC6206 series

provides large currents with a significantly small dropout voltage. The XC6206 consists of a current limiter circuit, a

driver transistor, a precision reference voltage and an error correction circuit. The series is compatible with low ESR

ceramic capacitors. The current limiter's foldback circuit operates as a short circuit protection as well as the output

current limiter for the output pin. Output voltages are internally by laser trimming technologies. It is selectable in

0.1V increments within a range of 1.2 to 5.0V.


ref. https://nettigo.eu/products/pcb-adapter-for-esp8266-modules
PCB ADAPTER FOR ESP8266 MODULES
Adapter is for ESP8266 -07 and -12. Version
Modules -07 and -12 are in format not ready to plug in breadboard. When You solder module onto this adapter You

plug it directly into breadboard or use standard F-M wires to get access to all GPIO on board.

Adapter has pin CH_PD pulled up to Vcc, so after You supply Vcc, ESP starts without any additional wires.
This adapter makes working with ESP8266 much easier. CH_PD is pulled to Vcc by 10k resistor (so module start

working after You provide Vcc). GPIO15 is pulled down to GND by 10k resistor, so to burn new flash image just

connect GPIO0 to GND during start.

Wrong silkscreen on adapter/module
Depending on production batch some -07 and -12 modules have replaced GPIO4 and GPIO5. Before You solder in

ESP module check if silkscreen on adapter is correct to avoid errors later. You can take picture of bottom side of

ESP module (there are GPIOs described).

**download the related file such as ino file, image
https://drive.google.com/drive/folders/0BzjoxIwEMrM-QXJzOFJveWVrSDg?usp=sharing

**credit
-https://www.letscontrolit.com/wiki/index.php/Power    // capacitor , reset issue
-https://www.letscontrolit.com/wiki/index.php/Tutorial_Arduino_Firmware_Upload   //set ide for esp8266
-https://nettigo.eu/products/pcb-adapter-for-esp8266-modules
-http://th.element14.com/torex/xc6206p332pr/v-reg-ldo-0-25a-3-3v-smd-sot-89/dp/8796998  //6206p ldo regulator









วันเสาร์ที่ 6 พฤษภาคม พ.ศ. 2560

Inter-Integrated Circuit or I2C Between Two arduinos uno






Inter-Integrated Circuit or I2C Between Two arduinos uno

Working:
when pressed  a tact switch on the sender board(uno) ,then send data to the receiver board(uno) which communicate via I2C
the receiver board(uno) will display the reCceivered data on the LCD.

Arudino uno
sender        -----     receiver
SDA(A4)     -----     SDA(A4)
SCL(A5)      -----    SCL(A5)  
GND            -----     GND ***


*Related clip
- Hardware Serial Communication (rx,tx) Between Two arduinos uno (Sending and Receiving)
https://youtu.be/q0By7XtOcQo
- Software Serial Communication (rx,tx) Between Two arduinos uno (Sending and Receiving)
https://youtu.be/ktNI-Cs0ZTk
-Inter-Integrated Circuit or I2C Between Two arduinos uno
https://youtu.be/jSIeaGtK3Mk

-download arduino sketch ,image
https://drive.google.com/open?id=0BzjoxIwEMrM-bUZKQUJuWkhGQTA

*credit
http://www.instructables.com/id/I2C-between-Arduinos/
https://www.youtube.com/watch?v=yQ15Hi1E7I4&t=5s

วันศุกร์ที่ 5 พฤษภาคม พ.ศ. 2560

Software Serial Communication (rx,tx) Between Two arduinos uno (Sending ...


Software Serial Communication (rx,tx) Between Two arduinos uno (Sending and Receiving)

Working:
when pressed  a tact switch on the sender board(uno) ,then send data to the receiver board(uno) which via the Software serial (tx,rx) communication.
the receiver board(uno) will display the receivered data on the LCD.

Arudino uno
sender  ----- receiver
  tx3      -----    rx2
  rx2       -----    tx3
GND   -------- GND ***


*Related clip
- Hardware Serial Communication (rx,tx) Between Two arduinos uno (Sending and Receiving)
https://youtu.be/q0By7XtOcQo
- Software Serial Communication (rx,tx) Between Two arduinos uno (Sending and Receiving)
https://youtu.be/ktNI-Cs0ZTk

-download arduino sketch ,image
https://drive.google.com/open?id=0BzjoxIwEMrM-aUtCS3JCMGItdjg

credit
http://www.kevindarrah.com/?page_id=1357


วันพฤหัสบดีที่ 4 พฤษภาคม พ.ศ. 2560

Hardware Serial Communication (rx,tx) Between Two arduinos uno (Sending ...



Hardware Serial Communication (rx,tx) Between Two arduinos uno (Sending and Receiving)

Working:
when pressed 'reset'  button on the sender board(uno) ,then send data to the receiver board(uno) which via the hardware serial (tx,rx) communication.
the receiver board(uno) will display the receivered data on the LCD.

Arudino uno
sender  ----- receiver
  tx       -----    rx
  rx       -----    tx
GND   -------- GND ***

Call many topic:
-Arduino to Arduino Serial Communication
-2 arduino communication tx rx
-Arduino Serial Communication
-2 Arduinos Talking How-To Hardware Serial
-Serial Communication Between Two arduinos
-two arduinos serial

-download arduino sketch ,image
https://drive.google.com/open?id=0BzjoxIwEMrM-VU5BQjkyOEMtTFk

credit
http://www.kevindarrah.com/?page_id=1357