パソコン画面より
【remote xy】を検索して
【Remote XY editor】を選択
スマホ図に【Controls】(Button)【Indication】(Instrument)(Led)
それぞれ適当な位置に貼付る。【Configuration】(Wi-Fi)(ESP32 based board)(WiFi on chip)選択して【Get source code】によりソースコードをArdino IDEにはる
同ブログ:【RemoteXY使い方】
【Get source code】に63.以降を修正したプログラムです。
プログラム
- /*
- -- LED_DTH11_SW --
-
- This source code of graphical user interface
- has been generated automatically by RemoteXY editor.
- To compile this code using RemoteXY library 3.1.8 or later version
- download by link http://remotexy.com/en/library/
- To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
- - for ANDROID 4.11.1 or later version;
- - for iOS 1.9.1 or later version;
-
- This source code is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- */
- //////////////////////////////////////////////
- // RemoteXY include library //
- //////////////////////////////////////////////
- // RemoteXY select connection mode and include library
- #define REMOTEXY_MODE__ESP32CORE_WIFI_POINT
- #include <WiFi.h>
- #include <RemoteXY.h>
- // RemoteXY connection settings
- #define REMOTEXY_WIFI_SSID "RemoteXY"
- #define REMOTEXY_WIFI_PASSWORD "12345678"
- #define REMOTEXY_SERVER_PORT 6377
- // RemoteXY configurate
- #pragma pack(push, 1)
- uint8_t RemoteXY_CONF[] = // 92 bytes
- { 255,1,0,9,0,85,0,16,31,1,1,0,20,58,24,24,2,31,0,70,
- 16,3,4,9,9,26,37,0,71,56,3,22,27,27,0,2,24,135,0,0,
- 0,0,0,0,200,66,0,0,160,65,0,0,32,65,0,0,0,64,24,0,
- 71,56,32,22,28,28,0,2,24,135,0,0,0,0,0,0,200,66,0,0,
- 160,65,0,0,32,65,0,0,0,64,24,0 };
-
- // this structure defines all the variables and events of your control interface
- struct {
- // input variables
- uint8_t button_1; // =1 if button pressed, else =0
- // output variables
- uint8_t led_1; // led state 0 .. 1
- float instrument_1; // from 0 to 100
- float instrument_2; // from 0 to 100
- // other variable
- uint8_t connect_flag; // =1 if wire connected, else =0
- } RemoteXY;
- #pragma pack(pop)
- /////////////////////////////////////////////
- // END RemoteXY include //
- /////////////////////////////////////////////
- #define SWPin 12
- #define LEDPin 13
- #define DHTPIN 14
- int sw ;
- #include "DHT.h" // https://github.com/adafruit/DHT-sensor-library
- #define DHTTYPE DHT11 //our sensor is DHT11 type
- DHT dht(DHTPIN, DHTTYPE); //create an instance of DHT senso
- void setup()
- {
- RemoteXY_Init ();
-
-
- // TODO you setup code
- Serial.begin(115200);
- pinMode(SWPin, INPUT_PULLUP); //SW
- pinMode(LEDPin, OUTPUT); //LED
- dht.begin();
- }
- void loop()
- {
- RemoteXY_Handler ();
-
-
- // TODO you loop code
- // use the RemoteXY structure for data transfer
- // do not call delay()
- float temperature = dht.readTemperature(); // 温度読み取り
- float humidity = dht.readHumidity(); // 湿度読み取り
-
- // 読み取りに失敗しているかチェック
- // 失敗している場合はもう一度、温湿度の読み取りをする
- if (isnan(temperature) || isnan(humidity)) {
- Serial.println("Failed to read from DHT sensor!");
- return;
- }
- RemoteXY.instrument_1 = temperature ;
- RemoteXY.instrument_2 = humidity ;
-
- sw = digitalRead(SWPin ) ; //スイッチの状態を読む
- RemoteXY.led_1 = sw ;
- digitalWrite(LEDPin,RemoteXY.button_1) ;
-
-
- Serial.print("湿度: ");
- Serial.print(humidity);
- Serial.print(" *C\t");
- Serial.print("温度: ");
- Serial.print(temperature);
- Serial.print(" % ");
- Serial.print("スイッチ:");
- Serial.println(sw);
-
- }
ボタンを押すとESP32ブレッドボードLedが点灯する
0 件のコメント:
コメントを投稿