Arduino
Download the Arduino IDE 及安裝系統 最好是用 Windows ZIP file for non admin install
system is in ------Windows hides windows store apps in c:/users/YourUserName/AppData(hidden folder)/Local/Packages
使用的程式檔案是在 user 文件夾中的 arduino下
Arduino IDE 預設並未含有 ESP8266 開發板函式庫與驅動程式, 必須在 "檔案/偏好設定" 的 "額外的開發板管理員位址" 欄位輸入下列網址 :
http://arduino.esp8266.com/stable/package_esp8266com_index.json
然後在 "工具/開發板/開發板管理員" 中, 搜尋 "ESP8266" 會看到 "esp8266 by ESP8266 Community" 這一項, 按底下的 "安裝" 鈕進行下載安裝
安裝完成後會顯示 "Installed" :
CH340 Driver https://sparks.gogo.co.nz/ch340.html
FT232 driver download http://www.ftdichip.com/Drivers/VCP.htm
CH340 for Mac https://drive.google.com/file/d/1G-_O2AtXkrz4RM0SgUmScOafu1Z6pz_r/view?usp=sharing
請先固定使用3.3V 燒錄韌體時必須先將 GPIO 0 接地 , 上電之後再拔掉 ,即進入燒錄模式。
D1 mini 腳位介紹 https://www.youtube.com/watch?v=07KIWT_yCi4
https://www.lazytomatolab.com/as-11/ Arduino IDE 內建的超強大人機互動工具:序列埠監控視窗
When I run this, I get the following output in the Serial Monitor (Ctrl + Shift + M):
跑馬燈、霹靂燈、流星燈、交通紅綠燈
/// 18b20 to ThingSpeak
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <OneWire.h>
#include <DallasTemperature.h>
ESP8266WiFiMulti WiFiMulti;
#define MQTT "3.114.197.59"
#define token "RqFM12eMY4yNPP3PAh8xykKee5cHZXVGZDgMrdddF3Px"
#define message "%E7%9B%AE%E5%89%8D%E6%BA%AB%E5%BA%A6%E6%98%AF" ///目前溫度是
#define wifi "jjwalk"
#define password "jamesjian"
#define ONE_WIRE_BUS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
float tempC;
int counter1 = 0;
#define api_key "HDN585SVBNGFYEIRx"
//String url="http://61.219.106.180/MQTT/publish.php?topic="topic"&value="value"&MQTT="MQTT;
/// 使用 uri 格式才可以
String url="http://"MQTT"/test/line_notify.php?token="token"&message="message;
String url1="http://api.thingspeak.com/update?api_key="api_key"&field1=";
void setup() {
Serial.begin(115200);
pinMode(D3, INPUT);
pinMode(D4, OUTPUT); //wifi led ,low is light on
digitalWrite(D4, HIGH);
for (uint8_t t = 2; t > 0; t--) {
Serial.printf("[SETUP] WAIT %d...\n", t);
Serial.flush();
delay(1000);
}
WiFi.mode(WIFI_STA);
WiFiMulti.addAP(wifi, password);
sensors.begin();
sensors.setResolution(insideThermometer, 10);
if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
}
void loop() { // wait for WiFi connection
digitalWrite(D4, HIGH); //light off
if ((WiFiMulti.run() == WL_CONNECTED)) {
digitalWrite(D4, LOW); //light on
sensors.requestTemperatures(); // Send the command to get temperatures
printTemperature(insideThermometer);
delay(2000);
if(counter1 > 60 ){
call_web(url1+String(tempC));
Serial.println(url1+String(tempC));
counter1 = 0;
}
counter1++;
Serial.println("counter1 is "+ String(counter1));
}
}
void call_web(String url_target){
WiFiClient client;
HTTPClient http;
Serial.print("[HTTP] begin...\n");
if (http.begin(client, url_target)) {
Serial.print("[HTTP] GET...\n");
// start connection and send HTTP header
int httpCode = http.GET();
// httpCode will be negative on error
if (httpCode > 0) {
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
Serial.println("send out url !!");
} else {
Serial.printf("[HTTP} Unable to connect\n");
}
}
void printTemperature(DeviceAddress deviceAddress)
{
tempC = sensors.getTempC(deviceAddress);
Serial.print("Temp C: ");
Serial.print(tempC);
Serial.print(" Temp F: ");
Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}
8266_mqtt_switch
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "jjwalk"; // Enter your WiFi name
const char* password = "jamesjian"; // Enter WiFi password
const char* mqttServer = "broker.hivemq.com";
const int mqttPort = 1883;
const char* topic = "cmnd/Zv9yGE5P/POWER";
const char* mqtt_username = "emqx";
const char* mqtt_password = "public";
WiFiClient espClient;
PubSubClient client(espClient);
// GPIO 5 D1
#define Relay D1
#define LED D4 //wifi led ,low is light on
void setup() {
Serial.begin(115200);
pinMode(Relay, OUTPUT);
pinMode(LED, OUTPUT); //wifi led ,low is light on
digitalWrite(D4, HIGH); //light off
digitalWrite(Relay, 1);
delay(1000);
digitalWrite(Relay, 0);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
client.setServer(mqttServer, mqttPort);
client.setCallback(callback);
while (!client.connected()) {
String client_id = "esp8266-client-";
client_id += String(WiFi.macAddress());
Serial.printf("The client %s connects to the public mqtt broker\n", client_id.c_str());
if (client.connect(client_id.c_str(), mqtt_username, mqtt_password)) {
Serial.println("Public mqtt broker connected");
} else {
Serial.print("failed with state ");
Serial.print(client.state());
delay(2000);
}
}
client.publish(topic, "test"); //Topic name
client.subscribe(topic);
}
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived in topic: ");
Serial.println(topic);
Serial.print("Message:");
String message = "";
for (int i = 0; i < length; i++) {
//Serial.print((char)payload[i]);
message = message + String((char)payload[i]);
}
Serial.print(message);
if( message == "on") digitalWrite(Relay, 1);
if( message == "off") digitalWrite(Relay, 0);
if( message == "toggle") digitalWrite(Relay, !digitalRead(Relay));
Serial.println();
Serial.println("-----------------------");
}
void loop() {
digitalWrite(D4, HIGH); //light off
if (WiFi.status() == WL_CONNECTED) {
digitalWrite(D4, LOW); //light on
}
client.loop();
}
mqtt: broker.hivemq.com topic: cmnd/Zv9yGE5P/POWER value: on off toggle
http://www.hivemq.com/demos/websocket-client/
http://3.114.197.59/MQTT/publish_hivemq.php?topic=cmnd/Zv9yGE5P/POWER&value=toggle 使用 broker.hivemq.com 的 mqtt
https://thingspeak.com/apps/timecontrols 可以使用Thingspeak來作為定時控制器
http://3.114.197.59/DeviceRC/url.php?title=物聯網控制器&data=[{"urlon":"3.114.197.59/MQTT/publish_hivemq.php?topic=cmnd/Zv9yGE5P/POWERamp;value=on","urloff":"3.114.197.59/MQTT/publish_hivemq.php?topic=cmnd/Zv9yGE5P/POWERamp;value=off","name":"開關1","type":"onoff"}]
https://github.com/Jorgen-VikingGod/ESP8266-MFRC522
example ReadUUID.ino 修改下列命令
#define buzzer 16
#define SS_PIN 2
#define RST_PIN 15
//setup{
pinMode(buzzer, OUTPUT);
//}
//loop{
callbeep();
//}
void callbeep(){
digitalWrite(buzzer, HIGH); // turn the LED on (HIGH is the voltage level)
delay(150); // wait for a second
digitalWrite(buzzer, LOW); // turn the LED off by making the voltage LOW
delay(100);
}
PICC type: MIFARE 1KB
A new card has been detected.
The NUID tag is:
In hex: E8 FE 53 D6
In dec: 232 254 83 214
copyUID file: https://drive.google.com/file/d/1uGWTqnkkTR81BAyAhHTWgEZp521qTxgx/view?usp=share_link
Must revert back to 8266 board version 2.5.0
作業: RFID 電子鎖, 白卡拷貝機
download file : https://drive.google.com/file/d/12IRLasCdo2lEsDWb2EFDKfb5m19M2Bfz/view?usp=sharing
https://blog.csdn.net/qq_35656476/article/details/99501380
U8G2_SH1106_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /*SCL*/ D2, /*SDA*/ D1, /*reset*/ U8X8_PIN_NONE);
https://robotzero.one/heltec-wifi-kit-8/
https://github.com/LilyGO/TTGO-ESP8266-0.91-SSD1306
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 4, /* clock=*/ 14, /* data=*/ 2);
省電型但時間上稍微延後一點,進入睡眠,喚喚醒後再連線
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
ESP8266WiFiMulti WiFiMulti;
#define url "http://61.219.106.180/MQTT/publish.php?topic=jjofficepc2&value=/close_windows&MQTT=broker.mqtt-dashboard.com"
#define wifi "jjwalk"
#define password "jamesjian"
void setup() {
Serial.begin(115200);
for (uint8_t t = 1; t > 0; t--) {
Serial.printf("[SETUP] WAIT %d...\n", t);
Serial.flush();
delay(1000);
}
WiFi.mode(WIFI_STA);
WiFiMulti.addAP(wifi, password);
}
void loop() {
// wait for WiFi connection
Serial.print("loop...\n");
if ((WiFiMulti.run() == WL_CONNECTED)) {
WiFiClient client;
HTTPClient http;
Serial.print("[HTTP] begin...\n");
if (http.begin(client, url)) {
Serial.print("[HTTP] GET...\n");
// start connection and send HTTP header
int httpCode = http.GET();
// httpCode will be negative on error
if (httpCode > 0) {
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
ESP.deepSleep(0);
} else {
Serial.printf("[HTTP} Unable to connect\n");
}
}
}
One button to LINE and call phone program ino file download : https://drive.google.com/file/d/1eHvcV8aS2PftBbueN7HDMxhV7Mf3ZGrl/view?usp=sharing
close windows boss come python download file : https://drive.google.com/file/d/1S65lSg79HSIHmERY3ACznQd7A31M2YbI/view?usp=sharing
boss come arduino ino file : https://drive.google.com/file/d/1xtM3xqTJDZJa8UZB5U_OsZBTzJoLpFO4/view?usp=sharing
/// 一直連在線上但是比較耗電
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
ESP8266WiFiMulti WiFiMulti;
#define MQTT "3.114.197.59"
///////////////////////////////////////////////////每個人需要修改的參數,參數中不得有空白,中文部分可用URL encode 來進行編碼,可用 https://www.urlencoder.org/
#define token "RqFM12eMY4yNPP3PAh8xykKee5cHZXVGZDgMrdddF3Px"
#define message "%E9%98%BF%E4%BC%AF%E5%87%BA%E4%BA%8B%E4%BA%86%EF%BC%8C%E8%AB%8B%E7%AB%8B%E5%8D%B3%E6%9F%A5%E7%9C%8B" ///阿伯出事了,請立即查看 可用URL encode 來進行編碼
#define wifi "jjwalk"
#define password "jamesjian"
String url1="http://maker.ifttt.com/trigger/call_phone/json/with/key/cBc--fMM1aPBjv_6gwdc7Dx"; // 如果要送2個url call phone by ifttt
/////////////////////////////////////////////////////////
//String url="http://61.219.106.180/MQTT/publish.php?topic="topic"&value="value"&MQTT="MQTT;
/// 使用 uri 格式才可以
/// close windows python url
/// send message to line
String url="http://"MQTT"/test/line_notify.php?token="token"&message="message;
void setup() {
Serial.begin(115200);
pinMode(D3, INPUT);
pinMode(D4, OUTPUT); //wifi led
for (uint8_t t = 2; t > 0; t--) {
Serial.printf("[SETUP] WAIT %d...\n", t);
Serial.flush();
delay(1000);
}
WiFi.mode(WIFI_STA);
WiFiMulti.addAP(wifi, password);
}
void loop() { // wait for WiFi connection
digitalWrite(D4, HIGH);
Serial.println("switch open !!");
delay(500);
if(digitalRead(D3) == LOW){
if ((WiFiMulti.run() == WL_CONNECTED)) {
digitalWrite(D4, LOW);
call_web(url);
delay(1000);
call_web(url1); // 如果要送2個url
}
}
}
void call_web(String url_target){
WiFiClient client;
HTTPClient http;
Serial.print("[HTTP] begin...\n");
if (http.begin(client, url_target)) {
Serial.print("[HTTP] GET...\n");
// start connection and send HTTP header
int httpCode = http.GET();
// httpCode will be negative on error
if (httpCode > 0) {
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
Serial.println("send out url !!");
} else {
Serial.printf("[HTTP} Unable to connect\n");
}
}
該板使用 TM1640,如您所見,有 8 個 8 個 LED,具有 8 個強度級別。還將使用您的 wemos mini 的 D5 和 D7 引腳
http://www.esp8266learning.com/wemos-mini-matrix-led-shield-example.php
This requires the library from https://github.com/wemos/WEMOS_Matrix_LED_Shield_Arduino_Library
Example codes http://www.getelectronics.net/wemos-led-matrix-shield-examples.php
1 0.66" Oled screen library https://github.com/ThingPulse/esp8266-oled-ssd1306
範例 SSD1306ClockDemo 將 143 行的 display->setFont(ArialMT_Plain_24); --> display->setFont(ArialMT_Plain_16); 即可完整呈現時鐘
2 0.96" Oled screen 打鴨子
範例影片 https://www.youtube.com/watch?v=vSvZcdnIoog
範例程式 https://drive.google.com/file/d/1hLJ8UO2RRGUYGUMNjuKNiWPxyCVtBPuj/view
sck --> d1 sda --> d2
UP-D5
DOWN-D4
LEFT-D6
RIGHT-D7
A-RX
B-D3
BUZZLE-D8
SCK-D1
SDA-D2
3 0.96" Oled screen Floppy bird https://www.instructables.com/PeSP-Esp8266-Based-Gaming-Console/
4 Arduboy game list https://community.arduboy.com/c/games/35?order=op_likes
5 ESP32 game 打磚塊 breakout https://github.com/rzeldent/esp32-breakout-ttgo
6 ESP32 game 俄羅斯方塊 Tetris https://github.com/channel2007/TBoy_ZooCube
7 ESPlay Micro Game模擬器 https://github.com/pebri86/esplay-retro-emulation
1 EspWifiConfDemo with D1 Relay https://drive.google.com/file/d/1aPkwEAPFp_MPboCs9u014e-FsNBPp54x/view?usp=sharing