Last active
April 9, 2022 10:05
-
-
Save sebadima/781ead8ecc421f7e0de717612b831d2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enter your forum-formatted code here | |
#include <ESP32WiFi.h> | |
#include <EEPROM.h> | |
#include | |
int val; | |
#define wifi_name “SSID” | |
#define password “la propria Password Wifi” | |
#define server “io.adafruit.com” | |
#define port 1883 | |
#define nome utente “Il proprio Adafruit ID Utente” | |
#define aio chiave “il Tuo AIO Tasto” | |
#define USE_SERIAL Serial | |
#define GAS_SENSOR A0 | |
//A0 di NodeMCU è collegato ad un pin Analogico di MQ-02 | |
void setup( ) | |
{ | |
Serial.begin(115200); | |
delay(10); | |
} | |
void loop() | |
{ | |
val=analogRead(GAS_SENSOR): | |
// Analogico di lettura per la lettura di un qualsiasi ingresso analogico. | |
Di serie.stampa (val); | |
// Qui, si stampa il valore di lettura attraverso il monitor seriale. | |
Di serie.println (” “); | |
delay(100); | |
} | |
WiFiClient me; | |
Adafruit MQTT Client mqtt (&me, server, porta, nome utente, aiokey); | |
Adafruit MQTT_Publishgas_data = Adafruit_MQTT_Publish (&mqtt, username”/feed/sensore del Gas”); | |
void setup() | |
{ | |
Serial.begin (115200); | |
delay(10); | |
Serial.println(“Connessione”); | |
Serial.stampa(wifi_name); | |
WiFi.begin (wifi_name, password); | |
while(wi-Fi.stato() != WL_CONNECTED) | |
{ | |
delay(500); | |
Serial.print(“.”); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment