amc2022:groupz:start
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| amc2022:groupz:start [2022/09/12 00:48] – [3.1. Complete Code] gheorghe001 | amc2022:groupz:start [2022/09/12 00:58] (current) – [3.1. Complete Code] gheorghe001 | ||
|---|---|---|---|
| Line 275: | Line 275: | ||
| } | } | ||
| | | ||
| - | void setup() { | + | void setup() { //29 |
| EEPROM.begin(EEPROM_BYTES); | EEPROM.begin(EEPROM_BYTES); | ||
| - | Serial.begin(115200); | + | Serial.begin(115200); |
| - | while (!Serial); | + | while (!Serial); |
| - | if (!mlx.begin()) { | + | if (!mlx.begin()) { //32 |
| Serial.println(" | Serial.println(" | ||
| while (1); | while (1); | ||
| }; | }; | ||
| - | delay(1000); | + | delay(1000); |
| | | ||
| - | ++bootCount; | + | ++bootCount; |
| Serial.println(" | Serial.println(" | ||
| - | print_wakeup_reason(); | + | print_wakeup_reason(); |
| - | esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); | + | esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); |
| Serial.println(" | Serial.println(" | ||
| " Seconds" | " Seconds" | ||
| - | Serial.println(" | + | Serial.println(" |
| delay(1000); | delay(1000); | ||
| - | WiFi.begin(ssid, | + | WiFi.begin(ssid, |
| - | while (WiFi.status() != WL_CONNECTED) { | + | while (WiFi.status() != WL_CONNECTED) { //39 |
| - | delay(1000); | + | delay(1000); |
| - | Serial.println(" | + | Serial.println(" |
| - | Serial.println(" | + | Serial.println(" |
| | | ||
| // | // | ||
| - | client.setServer(mqtt_broker, | + | client.setServer(mqtt_broker, |
| client.setCallback(callback); | client.setCallback(callback); | ||
| | | ||
| - | while (!client.connected()) { | + | while (!client.connected()) { //42 |
| String client_id = " | String client_id = " | ||
| client_id += String(WiFi.macAddress()); | client_id += String(WiFi.macAddress()); | ||
| Serial.printf(" | Serial.printf(" | ||
| | | ||
| - | if (client.connect(client_id.c_str())) { | + | if (client.connect(client_id.c_str())) { //43 |
| Serial.println(" | Serial.println(" | ||
| } | } | ||
| - | else { | + | else { //44 |
| Serial.print(" | Serial.print(" | ||
| Serial.print(client.state()); | Serial.print(client.state()); | ||
| Line 324: | Line 324: | ||
| } | } | ||
| - | void loop() { | + | void loop() { //45 |
| - | char soil_moisture_value[3]; | + | char soil_moisture_value[3]; |
| char air_temperature[3]; | char air_temperature[3]; | ||
| char air_humidity[3]; | char air_humidity[3]; | ||
| Line 332: | Line 332: | ||
| char ground_temperature[3]; | char ground_temperature[3]; | ||
| | | ||
| - | int value = analogRead(AOUT_PIN); | + | int value = analogRead(AOUT_PIN); |
| - | int percHumidity = map(value, dry, wet, 0, 100); | + | int percHumidity = map(value, dry, wet, 0, 100); //48 |
| delay(2000); | delay(2000); | ||
| - | if ((percHumidity > -5) && (percHumidity < 105)) { | + | if ((percHumidity > -5) && (percHumidity < 105)) { //49 |
| - | | + | |
| | | ||
| - | dtostrf(percHumidity, | + | dtostrf(percHumidity, |
| - | client.publish(topic_1, | + | client.publish(topic_1, |
| } | } | ||
| delay(2000); | delay(2000); | ||
| Line 382: | Line 382: | ||
| delay(1000); | delay(1000); | ||
| | | ||
| - | Serial.flush(); | + | Serial.flush(); |
| esp_deep_sleep_start(); | esp_deep_sleep_start(); | ||
| Serial.println(" | Serial.println(" | ||
amc2022/groupz/start.1662936504.txt.gz · Last modified: 2022/09/12 00:48 by gheorghe001