Results for
Bom dia se alguém puder me ajudar, meu código abaixo, não estou conseguintdo conectar o meu Esp8266 ao ThingSpeak, o erro tá na conexão. Estou usando o MicroPython e NodeMCU na plataforma Pytohn o sistema operacional Ubuntu 20
# DHT11 -> ESP8266/ESP32
# 1(Vcc) -> 3v3
# 2(Data) -> GPIO12
# 4(Gnd) -> Gnd
import time, network, machine
from dht import DHT11
from machine import Pin
from umqtt.simple import MQTTClient
print("Iniciando...")
dht = DHT11(Pin(12, Pin.IN, Pin.PULL_UP))
estacao = network.WLAN(network.STA_IF)
estacao.active(True)
estacao.connect('xxxxxxx', 'xxxxxxxxx')
while estacao.isconnected() == False:
machine.idle()
print('Conexao realizada.')
print(estacao.ifconfig())
SERVIDOR = "mqtt.thingspeak.com"
CHANNEL_ID = "XXXXXXXXXXXXXXXXX"
WRITE_API_KEY = "XXXXXXXXXXXXXXXXXXXXX"
topico = "channels/" + CHANNEL_ID + "/publish/" + WRITE_API_KEY
cliente = MQTTClient("umqtt_client", SERVIDOR)
try:
while True:
dht.measure()
temp = dht.temperature()
umid = dht.humidity()
print('Temperatura: %3.1f °C' %temp)
print('Umidade: %3.1f %%' %umid)
conteudo = "field1=" + str(temp) + "&field2=" + str(umid)
print ('Conectando a ThingSpeak...')
cliente.connect()
cliente.publish(topico, conteudo)
cliente.disconnect()
print ('Envio realizado.')
time.sleep(600.0)
except KeyboardInterrupt:
estacao.disconnect()
estacao.active(False)
print("Fim.")
*****************************************************************************************************
No shell aparece como resposta:
MPY: soft reboot
Iniciando...
Conexao realizada.
('192.168.0.23', '255.255.255.0', '192.168.0.1', '8.8.8.8')
Temperatura: 29.0 °C
Umidade: 63.0 %
Conectando a ThingSpeak...
Traceback (most recent call last):
File "<stdin>", line 38, in <module>
File "umqtt/simple.py", line 67, in connect
OSError: -2
linha 38 é cliente.connect()
Try to install MATLAB2024a on Ubuntu24.04. In the image below, the button indicated by the green arrow is clickable, while the button indicated by the red arrow are unclickable, and input field where text cannot be entered, preventing the installation.
