Hi all,
I struggle to get my m5stack Atom Matrix to connect to AWS. I double checked the AWS setup including the policy etc. There seem to be a problem with the connection I always get the following error when trying to publish something:
[45944] MQTTException -> [Errno 9] EBADF
reconnect start ...
reconnect finish ...
[48536] MQTTException -> [Errno 9] EBADF
reconnect start ...
reconnect finish ...
It also seems there changed some things recently. All examples I find are with a block called "dump to json" but this is no longer available. I work with "create JSON (string) and keys. See the picture.
Code is here:
from m5stack import *
from m5ui import *
from uiflow import *
from IoTcloud.AWS import AWS
from libs.json_py import *
import time
import unit
rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
tvoc_0 = unit.get(unit.TVOC, unit.PORTA)
eCO2 = None
TVOC = None
H2 = None
Ethanol = None
aws = AWS(things_name='CO2Sensor', host='xxxxxxxxxxx-ats.iot.eu-central-1.amazonaws.com', port=8883, keepalive=60, cert_file_path="/flash/res/co22-certificate.pem.crt", private_key_path="/flash/res/co22-private.pem.key")
aws.start()
print('AWS started')
while True:
eCO2 = tvoc_0.eCO2
TVOC = tvoc_0.TVOC
H2 = tvoc_0.H2
Ethanol = tvoc_0.Ethanol
aws.publish(str('$aws/things/CO2Sensor/co2'),str((py_2_json({'eCO2':eCO2,'TVOC':TVOC,'H2':H2,'Ethanol':Ethanol}))))