mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-08 05:07:07 +00:00
board config
#define new board config; MQTT
This commit is contained in:
3
ESP32_Temperture-Node/.vscode/settings.json
vendored
Normal file
3
ESP32_Temperture-Node/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"idf.portWin": "COM3"
|
||||
}
|
@@ -39,8 +39,50 @@
|
||||
#define MQTT_IOT_CHANNEL_OUTPUT_PWM_1 "node1/pwm1"
|
||||
|
||||
// Uncomment corresponding board
|
||||
#define devkit_30pin_001
|
||||
//#define devkit_30pin_001
|
||||
//#define devkit_36pin_001
|
||||
#define devkit_v4_38pin_ext_antenna
|
||||
|
||||
#ifdef devkit_v4_38pin_ext_antenna
|
||||
/*
|
||||
#### ESP32 DEVKIT V4 DIY MALL ####
|
||||
#### 38 PINS External Antenna ####
|
||||
#### DEVELOPMENT BOARD SUPPORTED PIN OUTS ####
|
||||
----------------------------------------------
|
||||
GPIO | Physical | Description
|
||||
Pin | |
|
||||
----------------------------------------------
|
||||
2 Built-in LED
|
||||
D15 3
|
||||
D2 4 => Built-in LED
|
||||
D4 5
|
||||
D5 8
|
||||
D18 9
|
||||
D19 10
|
||||
D21 11
|
||||
D22 14
|
||||
D23 15
|
||||
D34 19 Input only
|
||||
D35 20 Input only
|
||||
D32 21*
|
||||
D33 22*
|
||||
D25 23* => Assigned to DAC
|
||||
D26 24* => Assigned to DAC
|
||||
D27 25
|
||||
D14 26* => Assigned to Switch 1
|
||||
D12 27* => Assigned to Switch 2
|
||||
D13 28 => Assigned to read RPM
|
||||
----------------------------------------------
|
||||
*/
|
||||
#define PING_PIN 33 // GPIO 33 pin # of audio ping
|
||||
#define LED_PIN 32
|
||||
#define SWITCH_1 14 // GPIO 14
|
||||
#define SWITCH_2 12 // GPIO 12
|
||||
#define DAC_CH1 25 // GPIO 25
|
||||
#define DAC_CH2 26 // GPIO 26
|
||||
#define FAN_RPM 13 // GPIO 13
|
||||
//uint8_t pins[] = {2,4,5,12,13,14,15,18,19,21,22,23,25,26,27,32,33}; // 20 GPIO pins
|
||||
#endif
|
||||
|
||||
#ifdef devkit_30pin_001
|
||||
/*
|
||||
|
@@ -332,10 +332,45 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
if (connection.connected()) { // connected() == 1 => Connected
|
||||
//connection.subscribe("esp32/sw1");
|
||||
//connection.subscribe("esp32/sw2");
|
||||
|
||||
// put function definitions here:
|
||||
int myFunction(int x, int y) {
|
||||
return x + y;
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
delay(250);
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
delay(250);
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
delay(250);
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
|
||||
connection.publish(MQTT_IOT_CHANNEL_TEMPERATURE, itoa(sensors_values.temperature, cstr, 10));
|
||||
connection.publish(MQTT_IOT_CHANNEL_PRESSURE, itoa(sensors_values.pressure / 100.0F, cstr, 10));
|
||||
connection.publish(MQTT_IOT_CHANNEL_HUMIDITY, itoa(sensors_values.humidity, cstr, 10));
|
||||
connection.publish(MQTT_IOT_CHANNEL_OUTPUT_PULSE, "1");
|
||||
connection.publish(MQTT_IOT_CHANNEL_0, "10");
|
||||
Serial.println("test_topic: 10");
|
||||
delay(1000);
|
||||
connection.publish(MQTT_IOT_CHANNEL_OUTPUT_PULSE, "0");
|
||||
connection.publish(MQTT_IOT_CHANNEL_0, "3");
|
||||
Serial.println("test_topic: 3");
|
||||
Serial.print("MQTT State: ");
|
||||
Serial.println(connection.state()); // state() == 0 => Connected to MQTT
|
||||
Serial.print("MQTT Connected: ");
|
||||
Serial.println(connection.connected()); // connected() == 1 => Connected to MQTT
|
||||
Serial.print("Wi-Fi Connection tatus: ");
|
||||
Serial.println(WiFi.status()); // status() == 3 => Connected to WiFi
|
||||
delay(1000);
|
||||
connection.loop();
|
||||
|
||||
digitalWrite(PING_PIN, LOW);
|
||||
digitalWrite(PING_PIN, HIGH);
|
||||
delay(250);
|
||||
digitalWrite(PING_PIN, LOW);
|
||||
}
|
||||
// Call function to establish connection if not connected to MQTT server.
|
||||
else {
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
mosquitto_connect();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user