<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Communication with AWS Server]]></title><description><![CDATA[<p dir="auto">I want to send date that I recived from  a Oxygen sensor(SDS011) using serial port. I want to send this values to the Amazon server using MQTT. My main code is the next:</p>
<pre><code>print("Importing Library")
import time
import sys  
import datetime
import paho.mqtt.client as paho
import ssl
import os
import json
print("Importing Done")

def on_connect(client, userdata, flags, rc):
global connflag
connflag = True
if rc == 0:
	print("Connected")
else:
print("Connection returned result: " + str(rc) )

def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))

mqttc = paho.Client("Omega-C11B")
mqttc.on_connect = on_connect
mqttc.on_message = on_message
print("Paho Client Setup Done")

awshost = "a3rzs5flqm8tjk-ats.iot.ap-south-1.amazonaws.com"
awsport = 8883
clientId = "Omega-C11B"
thingName = "Omega-C11B"
caPath = "/root/root-CA.crt"
certPath = "/root/496d95a10e-certificate.pem.crt"
keyPath = "/root/496d95a10e-private.pem.key"

mqttc.tls_set(caPath, certfile=certPath, keyfile=keyPath, cert_reqs=ssl.CERT_REQUIRED, 
tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None)
print("TLS Established")
mqttc.connect(awshost, awsport, keepalive=60)
print("Server Connected")
mqttc.loop_start()

while True:
humidity = 60 #Supposing Data
temperature = 30  #Supposing Data
t = time.time();
date = datetime.datetime.fromtimestamp(t).strftime('%Y%m%d%H%M%S')
mqttc.publish("$aws/things/Omega-CF2D/shadow/update/", json.dumps({"time": date, 
    "temperature": temperature, "humidity": humidity}), qos=1)
time.sleep(10)
</code></pre>
<p dir="auto">In my console I get that the connection was sucefull, but when I see the AWS server, I can´t find the data.  I don't know if it's due to a code problem or caPath Certificate, beacuse I don't know where I can find. So I get it forn this link <a href="https://docs.aws.amazon.com/es_es/iot/latest/developerguide/server-authentication.html#server-authentication-certs" rel="nofollow">link text</a>. In my console I get :</p>
<p dir="auto"><img src="/assets/uploads/files/1583421618188-daa9d182-5496-4a1f-8a29-c41770d816dd-image.png" alt="daa9d182-5496-4a1f-8a29-c41770d816dd-image.png" class="img-responsive img-markdown" /></p>
<p dir="auto">I'm sending data with a time to 10seconds.</p>
]]></description><link>http://community.onion.io/topic/4060/communication-with-aws-server</link><generator>RSS for Node</generator><lastBuildDate>Thu, 14 May 2026 06:39:57 GMT</lastBuildDate><atom:link href="http://community.onion.io/topic/4060.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Mar 2020 15:13:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Communication with AWS Server on Thu, 05 Mar 2020 15:21:02 GMT]]></title><description><![CDATA[<p dir="auto">I want to send date that I recived from  a Oxygen sensor(SDS011) using serial port. I want to send this values to the Amazon server using MQTT. My main code is the next:</p>
<pre><code>print("Importing Library")
import time
import sys  
import datetime
import paho.mqtt.client as paho
import ssl
import os
import json
print("Importing Done")

def on_connect(client, userdata, flags, rc):
global connflag
connflag = True
if rc == 0:
	print("Connected")
else:
print("Connection returned result: " + str(rc) )

def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))

mqttc = paho.Client("Omega-C11B")
mqttc.on_connect = on_connect
mqttc.on_message = on_message
print("Paho Client Setup Done")

awshost = "a3rzs5flqm8tjk-ats.iot.ap-south-1.amazonaws.com"
awsport = 8883
clientId = "Omega-C11B"
thingName = "Omega-C11B"
caPath = "/root/root-CA.crt"
certPath = "/root/496d95a10e-certificate.pem.crt"
keyPath = "/root/496d95a10e-private.pem.key"

mqttc.tls_set(caPath, certfile=certPath, keyfile=keyPath, cert_reqs=ssl.CERT_REQUIRED, 
tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None)
print("TLS Established")
mqttc.connect(awshost, awsport, keepalive=60)
print("Server Connected")
mqttc.loop_start()

while True:
humidity = 60 #Supposing Data
temperature = 30  #Supposing Data
t = time.time();
date = datetime.datetime.fromtimestamp(t).strftime('%Y%m%d%H%M%S')
mqttc.publish("$aws/things/Omega-CF2D/shadow/update/", json.dumps({"time": date, 
    "temperature": temperature, "humidity": humidity}), qos=1)
time.sleep(10)
</code></pre>
<p dir="auto">In my console I get that the connection was sucefull, but when I see the AWS server, I can´t find the data.  I don't know if it's due to a code problem or caPath Certificate, beacuse I don't know where I can find. So I get it forn this link <a href="https://docs.aws.amazon.com/es_es/iot/latest/developerguide/server-authentication.html#server-authentication-certs" rel="nofollow">link text</a>. In my console I get :</p>
<p dir="auto"><img src="/assets/uploads/files/1583421618188-daa9d182-5496-4a1f-8a29-c41770d816dd-image.png" alt="daa9d182-5496-4a1f-8a29-c41770d816dd-image.png" class="img-responsive img-markdown" /></p>
<p dir="auto">I'm sending data with a time to 10seconds.</p>
]]></description><link>http://community.onion.io/post/21326</link><guid isPermaLink="true">http://community.onion.io/post/21326</guid><dc:creator><![CDATA[Victor Lucio]]></dc:creator><pubDate>Thu, 05 Mar 2020 15:21:02 GMT</pubDate></item><item><title><![CDATA[Reply to Communication with AWS Server on Thu, 05 Mar 2020 17:47:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/7056">@Victor-Lucio</a> Take a look at my response in this thread. Paho is not great at exposing errors if you don't use the callbacks.</p>
<p dir="auto"><a href="https://community.onion.io/topic/3691/omega2-aws-connect-error-ssl-certificate-verify-failed/7" rel="nofollow">https://community.onion.io/topic/3691/omega2-aws-connect-error-ssl-certificate-verify-failed/7</a></p>
]]></description><link>http://community.onion.io/post/21332</link><guid isPermaLink="true">http://community.onion.io/post/21332</guid><dc:creator><![CDATA[crispyoz]]></dc:creator><pubDate>Thu, 05 Mar 2020 17:47:28 GMT</pubDate></item><item><title><![CDATA[Reply to Communication with AWS Server on Thu, 05 Mar 2020 18:20:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/6184">@crispyoz</a>  Which others changes I need to do?<br />
Thanks for responding <img src="http://community.onion.io/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=ic093v0mjao" class="not-responsive emoji emoji-android emoji--wink" title=";)" alt="😉" /></p>
<p dir="auto"><img src="/assets/uploads/files/1583432223248-f232b060-e23d-4971-9bf0-1653cc52c874-image.png" alt="f232b060-e23d-4971-9bf0-1653cc52c874-image.png" class="img-responsive img-markdown" /></p>
<p dir="auto">Could you explain me, what de you tried to say in this " I would also implement the on_publish callback.</p>
<p dir="auto">¿This? Sorry if my question it's basic- I´m new using this module and sendding data to AWS.<br />
def on_publish(client, userdata, mid):<br />
print("Message published: " + message)</p>
<pre><code># message published, disconnect
client.disconnect()
</code></pre>
<p dir="auto">client.on_publish    = on_publish"</p>
]]></description><link>http://community.onion.io/post/21333</link><guid isPermaLink="true">http://community.onion.io/post/21333</guid><dc:creator><![CDATA[Victor Lucio]]></dc:creator><pubDate>Thu, 05 Mar 2020 18:20:48 GMT</pubDate></item><item><title><![CDATA[Reply to Communication with AWS Server on Thu, 05 Mar 2020 19:36:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/7056">@Victor-Lucio</a> your on_log should print the buffer, it has no parameter named msg. buffer should contain any errors or warnings.</p>
]]></description><link>http://community.onion.io/post/21334</link><guid isPermaLink="true">http://community.onion.io/post/21334</guid><dc:creator><![CDATA[crispyoz]]></dc:creator><pubDate>Thu, 05 Mar 2020 19:36:20 GMT</pubDate></item></channel></rss>