Корпус тензодатчика в вентиляцию

master
SmartUA 2021-08-07 17:22:41 +03:00
parent 69d0fcb68b
commit c6348a6706
14 changed files with 44591 additions and 44 deletions

View File

@ -10,7 +10,6 @@
#include <PubSubClient.h> //Mtqq #include <PubSubClient.h> //Mtqq
#include <ArduinoJson.h> //Упакова в JSon - удобная библиотека #include <ArduinoJson.h> //Упакова в JSon - удобная библиотека
#include <ESPmDNS.h> #include <ESPmDNS.h>
#include "esp32-hal-ledc.h"
#define Fpin 22 #define Fpin 22
#define Bpin 19 #define Bpin 19
@ -19,10 +18,7 @@
#define TRIGGER_PIN 39 #define TRIGGER_PIN 39
unsigned int VersionSW = 4; unsigned int VersionSW = 4;
const int freq = 5000;
const int ledChannel1 = 0;
const int ledChannel2 = 1;
const int resolution = 8;
//3 - Первый код для анемостата //3 - Первый код для анемостата
@ -39,8 +35,8 @@ IPAddress IpMqtt;
WiFiUDP ntpUDP; WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "192.168.89.210", 0, 20000); //Собственно сервер времени смещение и частоат запроса, но он вручную NTPClient timeClient(ntpUDP, "192.168.89.210", 0, 20000); //Собственно сервер времени смещение и частоат запроса, но он вручную
const PROGMEM char *willmess = "{\"conn\":\"err\"}"; const PROGMEM char *willmess = "{\"conn\":\"err\"}";
const char *mqttHostName = "cctv.automation.art"; //Хостнейм брокера metrics.local cctv.automation.art //192.168.89.210 const char *mqttHostName = "metrics"; //Хостнейм брокера metrics.local cctv.automation.art //192.168.89.210
unsigned int mqttPort = 8889; //Порт брокера 1883 8889 unsigned int mqttPort = 1883; //Порт брокера 1883 8889
String getMacAddress(); String getMacAddress();
String macc = getMacAddress(); String macc = getMacAddress();
@ -54,17 +50,20 @@ int stateResistor = 0;
const char *mqttIPHost; //тут хранится IP хоста по хостнейму const char *mqttIPHost; //тут хранится IP хоста по хостнейму
unsigned long timingUpdate = 0, timingReqSensor = 0, timingSendMqtt = 0; //Таймеры для millis() unsigned long timingUpdate = 0, timingReqSensor = 0, timingSendMqtt = 0; //Таймеры для millis()
int PROGMEM nextM5Update = 450000, nextMqttSend = 10000; //каждые 7.5 минут запрос обновления с сервера int PROGMEM nextM5Update = 450000, nextMqttSend = 20000; //каждые 7.5 минут запрос обновления с сервера
bool mqttSendFlag = false; bool mqttSendFlag = false;
int reqCounter = 0; int reqCounter = 0;
long rssi = 0, minRes = 1450, maxRes = 2600; long rssi = 0, minRes=1480, maxRes=2600;
char bufTopic[140], bufWillTopic[150], bufSetTopic[150]; char bufTopic[140], bufWillTopic[150], bufSetTopic[150];
int moveAnemo(byte speed, byte percent); int moveAnemo(byte speed, byte percent);
int setMotor(bool Finput, int Binput); int setMotor(bool Finput, int Binput);
void callback(char *topic, byte *payload, unsigned int length); void callback(char *topic, byte *payload, unsigned int length);
int disconnectMQTT(); int disconnectMQTT();
int SendMqttReq(bool sendVal, bool sendStatus, byte statusConn);
void ledset(byte color = 0) void ledset(byte color = 0)
{ {
@ -283,6 +282,7 @@ int moveAnemo(byte speed, byte percent)
} }
setMotor(false, false); setMotor(false, false);
SendMqttReq(true,true,1);
// 0 - 1460 // 0 - 1460
// 10 - 1535 - 1547 // 10 - 1535 - 1547
@ -438,7 +438,6 @@ int SendMqttReq(bool sendVal = true, bool sendStatus = true, byte statusConn = 1
doc["analog"] = nowResist(); doc["analog"] = nowResist();
doc["percent"] = nowPercent(nowResist()); doc["percent"] = nowPercent(nowResist());
doc["co2"] = "";
doc["ts"] = timeNow; doc["ts"] = timeNow;
@ -482,7 +481,7 @@ int SendMqttReq(bool sendVal = true, bool sendStatus = true, byte statusConn = 1
doc["rssi"] = rssi; doc["rssi"] = rssi;
doc["bsid"] = WiFi.BSSIDstr(); doc["bsid"] = WiFi.BSSIDstr();
doc["ts"] = timeNow; doc["ts"] = timeNow;
doc["exp"] = timeNow + 11000; doc["exp"] = timeNow + 20000;
doc["sv"] = VersionSW; doc["sv"] = VersionSW;
JsonData = ""; JsonData = "";
@ -555,12 +554,6 @@ void setup()
pinMode(Fpin, OUTPUT); pinMode(Fpin, OUTPUT);
pinMode(Bpin, OUTPUT); pinMode(Bpin, OUTPUT);
ledcSetup(ledChannel1, freq, resolution);
ledcSetup(ledChannel2, freq, resolution);
ledcAttachPin(Fpin, ledChannel1);
ledcAttachPin(Bpin, ledChannel2);
setMotor(false, false); setMotor(false, false);
@ -627,11 +620,11 @@ void loop()
stateResistor = analogRead(Resist); stateResistor = analogRead(Resist);
// if (millis() - timingSendMqtt > nextMqttSend) if (millis() - timingSendMqtt > nextMqttSend)
// { {
// SendMqttReq(); SendMqttReq(true,true,1);
// timingSendMqtt = millis(); timingSendMqtt = millis();
// } }
// 40 секунд и происходит сброс настроек WIFI // 40 секунд и происходит сброс настроек WIFI
if (M5.Btn.wasReleasefor(40000)) if (M5.Btn.wasReleasefor(40000))
@ -664,19 +657,14 @@ int setMotor(bool Finput, int Binput)
if (Finput == true && Binput == false) if (Finput == true && Binput == false)
{ {
digitalWrite(Fpin, HIGH);
// digitalWrite(Fpin, HIGH);
ledcWrite(ledChannel1, 200);
digitalWrite(Bpin, LOW); digitalWrite(Bpin, LOW);
} }
if (Finput == false && Binput == true) if (Finput == false && Binput == true)
{ {
digitalWrite(Fpin, LOW); digitalWrite(Fpin, LOW);
digitalWrite(Bpin, HIGH);
ledcWrite(ledChannel2, 200);
// digitalWrite(Bpin, HIGH);
} }
//stop //stop

Binary file not shown.

0
anemostat/~WRL2371.tmp Normal file
View File

Binary file not shown.

9900
tenzo/1.stl Normal file

File diff suppressed because it is too large Load Diff

3642
tenzo/2.stl Normal file

File diff suppressed because it is too large Load Diff

BIN
tenzo/2354667.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

9956
tenzo/3.stl Normal file

File diff suppressed because it is too large Load Diff

3754
tenzo/4.stl Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
tenzo/Untitled.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

BIN
tenzo/Untitled.skb Normal file

Binary file not shown.

BIN
tenzo/Untitled.skp Normal file

Binary file not shown.

17307
tenzo/Untitled.xml Normal file

File diff suppressed because it is too large Load Diff