NODEMCU ESP8266 DHT22 AM2305 DS18B20 Thingspeak

// www.arduinesp.com
//
// Plot DTH11 data on thingspeak.com using an ESP8266
// April 11 2015
// Author: Jeroen Beemster
// Website: www.arduinesp.com
// ใช้กับ กล่อง วัดอุณหภูมิที่บ้าน
// 20-3-2017 ใช้งานครั้งแรก DHT22
// 19-5-2017 เพิ่ม DS18B20
// 18-12-2017 ซ่อมครั้งที่ 1 เปลี่ยน DHT22 เป็น AM2305

#include <DHT.h>
#include <ESP8266WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// replace with your channel’s thingspeak API key,
String apiKey = “WXXXXXXXXX”;
const char* ssid = “AP_xxxx”;
const char* password = “1xxxxxxxx”;

const char* server = “api.thingspeak.com”;
#define DHTPIN1 D1 // d0 dht22 ext
// #define DHTPIN2 D2 // d1 dht22 mushroom
DHT dht1(DHTPIN1,DHT22,15);
// DHT dht2(DHTPIN2,DHT22,15);
#define sensorPin D2 // Data wire is plugged into pin D3 on NodeMCU
OneWire oneWire(sensorPin); // Setup the oneWire Sensor
DallasTemperature DS18B20(&oneWire); // Pass reference to Dallas Temperature.
WiFiClient client;

ADC_MODE(ADC_VCC);
// int vcc;
void setup() {
Serial.begin(115200);
delay(10);
dht1.begin();
//dht2.begin();
WiFi.begin(ssid, password);

Serial.println();
Serial.println();
Serial.print(“Connecting to “);
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.println(“WiFi connected”);

}

void loop() {

float h1 = dht1.readHumidity();
float t1 = dht1.readTemperature();
float vcc = 0.00f;
vcc = ESP.getVcc()/1024.00f;
// uint32_t vcc = ESP.getVcc()/1000.0;
DS18B20.requestTemperatures();
float t2 = DS18B20.getTempCByIndex(0);
//float h2 = 0; // can’t read ds18b20 humidity
//float h2 = dht2.readHumidity();
//float t2 = dht2.readTemperature();
//if (isnan(h1) || isnan(t1) ||isnan(h2) || isnan(t2)) {
if (isnan(h1) || isnan(t1) ) {
Serial.println(“Failed to read from EXT DHT sensor 1 !”);
//return;
t1=0;
h1=0;
}
else if (isnan(t2) ) {
Serial.println(“Failed to read from DS18B20 mushroom sensor 2 !”);
//return;
t2=0;
//h2=0;
}

if (client.connect(server,80)) { // “184.106.153.149” or api.thingspeak.com
String postStr = apiKey;
postStr +=”&field1=”;
postStr += String(t1);
postStr +=”&field2=”;
postStr += String(h1);
postStr +=”&field3=”;
postStr += String(vcc);
postStr +=”&field4=”;
postStr += String(t2);
//postStr +=”&field5=”;
//postStr += String(h2);
postStr += “\r\n\r\n”;

client.print(“POST /update HTTP/1.1\n”);
client.print(“Host: api.thingspeak.com\n”);
client.print(“Connection: close\n”);
client.print(“X-THINGSPEAKAPIKEY: “+apiKey+”\n”);
client.print(“Content-Type: application/x-www-form-urlencoded\n”);
client.print(“Content-Length: “);
client.print(postStr.length());
client.print(“\n\n”);
client.print(postStr);
Serial.print(“Temperature 1: “);
Serial.print(t1);
Serial.print(” C Humidity 1: “);
Serial.print(h1);
Serial.print(” % Voltage : “);
Serial.print(vcc);
Serial.print(” V MushRoom Temperature 2: “);
Serial.print(t2);
Serial.println(” C”);
//Serial.print(” C MushRoom Humidity 2: “);
//Serial.print(h2);
//Serial.println(“% send to Thingspeak”);
}
client.stop();

Serial.println(“Waiting”);
// thingspeak needs minimum 15 sec delay between updates
// delay 1 minitue delay 1000=1sec
Serial.println(“Wifi Disconnect”);
WiFi.disconnect();
//delay(60000);
delay(100);
//โดย 1,000,000 microseconds = 1 second)
//node.dsleep(60 * 1000000)
Serial.println(“”);
Serial.println(“Deep Sleep 5 min”);
// deep sleep 1 min
//ESP.deepSleep(60 * 1000000, WAKE_RF_DEFAULT);
//deep sleep 5 min
ESP.deepSleep(360 * 1000000, WAKE_RF_DEFAULT);
//ESP.deepSleep(5*60 * 1000000);
//node.dsleep(60 * 1000000);
delay(500); // wait for deep sleep to happen
}

Forscan ตอนที่ 2.1 การติดตั้ง ELM327

ปกติ ELM327 ที่ซื้อมา จะมีแผ่น CD Driver มาให้ เพื่อให้ windows ที่ติดตั้งรู้จัก ELM327 โดย แบ่งตาม Chipset USB TTL RS232 ยอดนิยม 2 รุ่นคือ
1. FTDI
2. CH340
โดย forscan จะเน้นให้ไปใช้ chip FTDI เพราะทดสอบแล้ว เสถียรกว่า
สำหรับท่านที่ แผ่นไม่มี หาย แตก สามารถ Download ได้ที่
สำหรับ FTDI
Windows XP,Vista,7,8,10 x32 x64 (32-64Bit)
http://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.26%20WHQL%20Certified.zip

***กรณีที่ไม่รู้ว่า Windows ของเรา x32(32-bits) หรือ x64(64-bits)
win7: คลิ๊กขวา ไอคอน คอมพิวเตอร์(Computer) -> คุณสมบัติ (Properties)
ตรง System Type จะบอกว่า 32-bits หรือ 64-bit
win10:คลิ๊กขวาที่ปุ่ม Start เลือก system***

สำหรับ
CH340
http://www.wch.cn/downfile/5
หรือ
http://www.arduined.eu/files/windows8/CH341SER.zip

การติดตั้ง Driver FTDI
หลังจาก download มาแล้วให้แตกไฟล์ (Extract) ออก ในที่นี้ใช้ winrar

จะได้ไฟล์ดังรูป


คลิ๊กขวาที่  ftdibus.inf กด Install

หากติดตั้งสำเร็จจะขึ้น

คลิ๊กขวาที่  ftdiport.inf กด Install

หากติดตั้งสำเร็จจะขึ้น

การติดตั้ง FTDI ใน youtube
https://www.youtube.com/watch?v=EZMZ0g1My84
เอกสารการติดตั้ง
https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/windows—in-depth
http://www.ftdichip.com/Support/Documents/AppNotes/AN_119_FTDI_Drivers_Installation_Guide_for_Windows7.pdf

การติดตั้ง CH340 Driver


หากไปตรวจใน device manager จะพบว่า port ทำงาน

กรณีปัญหาและการแก้ไข

forscan อาการนี้เกิดจาก หา elm327 ไม่เจอ เท่าที่เจอ ไม่ได้ลง Driver ไว้ หากไปดูที่ Device manager จะพบ ว่า  Driver ยังไม่ได้ติดตั้ง


ให้ติดตั้ง Driver ใหม่

Forscan ตอนที่ 2.2 ติดตั้ง FORScan การเพิ่ม จอเมนู Navigation ,Climate

จากตอนที่ 1 ได้กล่าวถึง อุปกรณ์ที่ใช้ในการ ทำการโปรแกรมและการเลือกซื้อไปแล้วแล้ว
และ ตอนที่ 2.1 กล่าวถึง การติดตั้ง Driver ELM327
และตอนนี้จะกล่าวถึงตัวโปรแกรม ต่อ

โปรแกรม forscan เป็นหนึ่งในหลายโปรแกรมที่ใช้ในการปิดเปิดฟังก์ชั่นในรถ ford หรืออื่นๆ ได้ เขียนโดยโปรแกรมเมอร์ชาวรัสเซีย

อีกตัวนึงที่ศูนย์รถ ร้านซ่อม ในต่างประเทศรวมทั้งบ้านเราใช้กัน คือ Ford IDS ซึ่งต้องใช้คู่กับกล่อง VCM สร้างโดย ford motorcraft สามารถ เปิดปิดได้หลายอย่าง สามารถ load โปรแกรมเกียร์รุ่นล่าๆ มาใส่รถได้ และอื่นๆ  อีกมากมาย รุ่นปกติต้องซื้อลิขสิทธิ์กันแพงน่าดู
(ถ้าไม่ crack) แต่ช่างมันเถอะเพราะไม่เกี่ยวกับเราในหัวข้อนี้

ก่อนอื่น ไป download forscan ที่
http://www.forscan.org/download.html
Download  โปรแกรม Forscan รุ่นล่่าสุด

จากนั้นเมื่อได้ไฟล์แล้ว ทำการติดตั้ง การติดตั้งก็ไม่ยาก Next ลูกเดียว มีคลิ๊ก Accept บ้าง เมื่อติดตั้งเสร็จจะมี ไอคอนรูป Forscan ดังรูป

คลิ๊กที่ไอคอน Forscan เปิดโปรแกรม
กด OK ข้ามขั้นตอนต่างๆไป
จากนั้นกดรูป พวงมาลัย ล่างสุด จะเห็น Hardware id กด Copy to Clipboard
หรือจด Hardware id ไว้

จากนั้นสมัครสมาชิก (Register) ใน forum http://www.forscan.org/forum/

เมื่อเป็นสมาชิกแล้ว ไปขอ Extended License ฟรี มีอายุ 2 เดือนที่

http://forscan.org/forum/extlic.php

ในนี้จะมีให้กรอก ชื่อ นามสกุล,เบอร์โทร, Hardware ID

กด Generate
จะมีช่องให้ Download จะได้ไฟล์มา ชื่อ FORScanLicense.key
จากนั้นเปิดโปรแกรม Forscan
กด OK ข้ามขั้นตอนต่างๆไป
จากนั้นกดรูป พวงมาลัย ล่างสุด
กดปุ่ม Load License Key กดหาไฟล์ FORScanLicense.key กด OK

โปรแกรมจะทำงานเต็มทุก เมนู ให้เราซ่าได้ไปอีกสองเดือน

ติ๊งต่างว่า เรามีของครบแล้ว เรารออะไรอยู่ล่ะครับ ก็พุ่งไปที่รถ

– ดึงฝาปิด (กระชากเพราะดึงเบาๆไม่ออก)  กล่องฟิวส์ภายห้องโดยสารตรงเข่าคนขับออกมา

สังเกตว่าช่อง ELM327 OBDII เป็นรูปสี่เหลี่ยมคางหมู เสียบกับช่อง OBDII สีขาว
เสียบยังไงก็ไม่ผิด ผิดก็เสียบไม่ได้

– เสียบ ELM327 เข้าที่ช่องสีขาว เสียบไปตรงๆ
– เปิดคอมพิวเตอร์ รอ จนขึ้นหน้า desktop
– เสียบสาย usb ของ ELM327 เข้าช่อง USB ของคอมพิวเตอร์
– เปิดโปรแกรม Forscan ขึ้นมา
– บิดกุญแจรถไปที่ ON (แต่ไม่ต้อง สตาร์ทเครื่อง)

โปรแกรมจะขึ้นคำเตือน ที่ท่านควรสนใจ

แปลบ้านๆว่า

การลงทุน (ใช้คอมและโปรแกรมกับรถ) มีความเสี่ยง ผู้ลงทุน(ทำ)ควรศึกษาข้อมูลก่อนการตัดสินใจลงทุน (ทำ)

อ่านจบแล้ว ก็ปิดเครื่องเก็บของ แล้วไปให้คนที่เชี่ยวชาญจ้างร้านทำดีกว่า เสียเงินหน่อยสบายใจ

สำหรับคนที่อยาก D.I.Y. ก็เดินต่อ
กด OK

โปรแกรมจะขึ้นหน้า warning เตือนให้
-บิดกุญแจไป ON
– สวิทช์ HS/MS CAN ของ ELM327  ต้องอยู่ตำแหน่ง HS CAN (กรณีตั้งผิด ก็ปิดโปรแกรมเปิดใหม่)
– อย่าเคลื่อนรถ
พร้อมแล้วก็กด OK

โปรแกรมจะขึ้น Feedback need แสดง profileของรถ ที่เคยบันทึกไว้ ถ้ามีอยู่แล้ว จะถามว่าจะ load ของเดิมมาหรือไม่ ในที่นี้ตอบ No เพราะเราจะบันทึกใหม่ รถแต่ละคันจะมี profile ต่างกันนะครับ

โปรแกรมจะค้นหาอุปกรณ์ Module ต่างๆ ที่เชื่อมต่อในระบบรถ
ขึ้น feedback need ถามว่า อุปกรณ์เรารองรับ hs/mscan หรือไม่ ตอบ yes
3
โปรแกรมขึ้น Action need ให้เราโยกสวิทช์ที่ ELM327 มาที่ตำแหน่ง MS CAN
แล้วกด OK

โปรแกรมจะอ่านตัวอุปกรณ์ Module ทั้งหมดที่เชื่อมต่อในรถ ออกมา

เมื่อทำมาถึงจุดนี้ก็แสดงว่า ผ่านมาเกือบครึ่งเรื่อง แต่หนังยังไม่จบ
ตอนต่อไป (ถ้ามีเวลาจะกล่าวถึง) การทำงานของแต่ละเมนู การอ่านและเคลียรโค๊ด Error
การตั้งโปรแกรม ในส่วนที่หน้าสนใจ การคำนวน Checksum

Gotek USB FDD Firmware

https://github.com/keirf/FlashFloppy/wiki/Firmware-Programming

https://cortexamigafloppydrive.wordpress.com/

http://torlus.com/floppy/forum/viewtopic.php?f=33&t=1683

https://github.com/jfdelnero/HXCFE_file_selector

http://eab.abime.net/showthread.php?t=88002

Arduino + PIR + RFID + Relay

arduino-rfid_rc522-pir_hc-sr501-1ch_relay

อุปกรณ์

  • Arduino UNO R3 SMD
  • PIR Pyroelectric Infrared PIR Motion Sensor HC-SR501
  • RFID 13.56 MHz RC522 และ Tag
  • 1 Ch Relay 5V

การทำงาน  อ่านความเคลื่อนไหวจาก PIR แล้ว มาอ่านค่า Tag จาก RFID  หาก ตรงกัน ให้ Relay ทำงาน

ถ้าเอา tag ผ่าน RFID โดยไม่มีการเคลื่อนไหว จะไม่ทำงาน

ระยะ PIR

 

#include <SPI.h>
#include <RFID.h>
// ส่วนของ rfid
#define SS_PIN 10
#define RST_PIN 9
RFID rfid(SS_PIN,RST_PIN);
int serNum[5];
int cards[][5] = {
{22,227,22,203,40}
};
bool access = false;

int ledPin1= 7;
int rfidPPin1= 6;
int inputPin= 3;
int relay=2;
void setup(){
Serial.begin(9600);
pinMode(ledPin1, OUTPUT);
pinMode(inputPin, INPUT);
pinMode(relay, OUTPUT);
SPI.begin();
rfid.init();
}

void loop(){
int value= digitalRead(inputPin);

if (value == HIGH)
{
digitalWrite(ledPin1, HIGH);
Serial.println(” LED ON”);

//delay(100) ;
}else
{
digitalWrite(ledPin1, LOW);
Serial.println(” LED OFF”);
}
// rfid.isCard();
//
// while(digitalRead(7) == HIGH) ****** I try to use with while and if but the loop continue to run without the input signal condition even when the input wire is disconnected.

if(rfid.isCard()&& (value == HIGH)){
// if(rfid.isCard()){

if(rfid.readCardSerial()){
Serial.print(rfid.serNum[0]);
Serial.print(” “);
Serial.print(rfid.serNum[1]);
Serial.print(” “);
Serial.print(rfid.serNum[2]);
Serial.print(” “);
Serial.print(rfid.serNum[3]);
Serial.print(” “);
Serial.print(rfid.serNum[4]);
Serial.println(“”);

for(int x = 0; x < sizeof(cards); x++) {
for(int i = 0; i < sizeof(rfid.serNum); i++ ) {
if(rfid.serNum[i] != cards[x][i]) {
access = false;
break;
} else {
access = true;
}
}
if(access) break;
}

}

if(access);
Serial.println(“Get In—>”);
// while(digitalRead(7) == HIGH);
digitalWrite(relay, HIGH);
delay(500);
}else {
Serial.println(“You Blocked(-)”);
digitalWrite(relay, LOW);
delay(100);
}

rfid.halt();
}

ที่มา : http://forum.arduino.cc/index.php?topic=407081.0  แก้ไขโดย PualS

Arduino Uno + PIR Sensor

hc-sr501-labelled-althc-sr501

PIR Motion Sensor Module (HC-SR501)

จำนวน 1 ตัว

ตรวจจับความเคลื่อนไหว
Color: White + Green
Dimension: 3.2cm x 2.4cm x 1.8cm (approx)
Infrared sensor with control circuit board
The sensitivity and holding time can be adjusted
Working Voltage Range: DC 4.5V- 20V
Current drain:<60uA
Voltage Output: High/Low level signal:3.3V TTL output
Detection distance: 3–7M(can be adjusted)
Detection range: <140°
Delay time: 5-200S(can be adjusted, default 5s +-3%)
Blockade time: 2.5 S (default)
Trigger: L: Non-repeatable trigger H: Repeat Trigger (default)
Work temperature:-20-+80°C
Trigger Method: L unrepeatable trigger / H repeatable trigger

arduino-pir

 

int ledPin= 13;
int inputPin= 3;

void setup(){
pinMode(ledPin, OUTPUT);
pinMode(inputPin, INPUT);
}

void loop(){
int value= digitalRead(inputPin);

if (value == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(1000) ;
}

else
{
digitalWrite(ledPin, LOW);
}
}

 

ที่มา:https://www.arduinoall.com/product/29/pir-hc-sr501-%E0%B9%80%E0%B8%8B%E0%B8%99%E0%B9%80%E0%B8%8B%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B8%95%E0%B8%A3%E0%B8%A7%E0%B8%88%E0%B8%88%E0%B8%B1%E0%B8%9A%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B9%80%E0%B8%84%E0%B8%A5%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%99%E0%B9%84%E0%B8%AB%E0%B8%A7-motion-sensor-module-hc-sr501

esp8266 Deep Sleep Max

esp8266 Deep sleep โดยต่อ ขา GPIO16 (D0) ไปขา Reset

node.dsleep(15 * 60 * 1000000)

โดย 1,000,000 ไมโครวินาที (microseconds) = 1 วินาที (second) โดยตัวอย่างจะ deep sleep ได้ 15 นาที

การตั้งค่า  โดยทฤษฎี จะสามารถทำ deep sleep ได้  4,294,967,295, which is about 71 minutes แต่

เนื่องจากข้อจำกัด จะทำได้แค่ 35 นาที (2,100,000 milliseconds)

Disable Online Template Office 2013/2016

Microsoft office 2013/2016 open excel word everytime will link online template through templateservice.office.net

disable

Regedit

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Common\Internet]
“UseOnlineContent”=dword:00000000

This will stop Office (and Word) to display “Templates from Office.com” in the File New dialog and restrict the templates to the installed ones.

source:https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-msoffice_custom/is-is-possible-to-disable-officecom-templates/aea8d6c9-879f-418d-b78e-f6c5419ca928

SWR Monitor

การขยาย Client ให้คัดลอก SwrMoniter_Evolution ไปยังเครื่องอื่น

ค่าที่ชี้ DATABASE SERVER อยู่ใน DBDriver

ค่าตอน login อยู่ใน ไฟล์ SwrM_Connection.DTC

Database Server อยู่ที่ folder DATA EVO ชื่อ DTCGPS_EVO

map server อยู่ที่ Swr_Map