<?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[pm2.5 and mqtt incomplete python code]]></title><description><![CDATA[<p dir="auto">Before I go into describing the bug I ran into I want to make a request that the pm2.5 blocks includes temperature and humidity values from the sensor. Now onto the issue:<br />
I am using uiflow with pm2.5 and mqtt blocks. I start off with some block code for the pm2.5 that is working well but when I try to add the mqtt blocks the generated python code is incomplete and it doesn't include the mqtt python code even when there are mqtt blocks. Sometimes, depending on the sequence of when I add the mqtt blocks it will even remove previously generated python code that was and should still be there. If I then try and go back from the python tab to the blocks tab uiflow will lock up and I then need to reload the m5f file. I can get the code to work by typing it into the python editor but I can't get it working using blocks. Here is the file with the blocks and you can see the incomplete python code it generates. I am using 1.3.4 beta <a href="https://github.com/machinehistories/m5pm2.5" target="_blank" rel="noopener noreferrer nofollow ugc">pm25 m5f on github</a></p>
<p dir="auto">Here is the working python code that I manually typed into the python editor tab.</p>
<pre><code>from m5stack import *
from m5ui import *
from uiflow import *
import module
from m5mqtt import M5mqtt
import unit

setScreenColor(0x222222)


m5mqtt = M5mqtt('xxx, 'io.adafruit.com', 1883, 'xxx', 'xxx', 3000)

pm0 = module.get(module.PM25)

i = None
ioTopics = None
xPos = None
yPos = None
pmText = None
pmVal = None
xPos = 5
yPos = 16

def upRange(start, stop, step):
  while start &lt;= stop:
    yield start
    start += abs(step)

def downRange(start, stop, step):
  while start &gt;= stop:
    yield start
    start -= abs(step)
	
m5mqtt.start()
pmText = ['SPM 1.0', 'SPM 2.5', 'SPM 10', 'APM 1.0', 'APM 2.5', 'APM 10', '# &gt;  0.3 um', '# &gt;  0.5 um', '# &gt;  1.0 um', '# &gt;  2.5 um', '# &gt;  5.0 um', '# &gt; 10.0 um']
i_end = float(len(pmText))
for i in (1 &lt;= i_end) and upRange(1, i_end, 1) or downRange(1, i_end, 1):
  lcd.print(pmText[int(i - 1)], xPos, (yPos * i), 0xffffff)
  wait_ms(300)
  
#ioTopics = topic_data
#i_end2 = float(len(ioTopics))
#for i in (1 &lt;= i_end2) and upRange(1, i_end2, 1) or downRange(1, i_end2, 1):
#  lcd.print(ioTopics[int(i - 1)], 150, (yPos * i), 0xffffff)  
 
  
while True:
  pmVal = [pm0.get_pm1_0_factory(), pm0.get_pm2_5_factory(), pm0.get_pm10_factory(), pm0.get_pm1_0_air(), 
  pm0.get_pm2_5_air(), pm0.get_pm10_air(), pm0.get_num_above_0_3(), pm0.get_num_above_0_5(), 
  pm0.get_num_above_1(), pm0.get_num_above_2_5(), pm0.get_num_above_5(), pm0.get_num_above_10()]
  i_end2 = float(len(pmText))
  for i in (1 &lt;= i_end2) and upRange(1, i_end2, 1) or downRange(1, i_end2, 1):
    lcd.print(pmVal[int(i - 1)], (xPos + 130), (yPos * i), 0xffffff)
    m5mqtt.publish(str('xxx/feeds/pm2-5.pm-1'),str(pmVal[1]))
    m5mqtt.publish(str('xxx/feeds/pm2-5.pm-2-5'),str(pmVal[2]))
    m5mqtt.publish(str('xxx/feeds/pm2-5.pm-10'),str(pmVal[3]))
    m5mqtt.publish(str('xxx/feeds/pm2-5.pm-2-5'),str(pmVal[2]))
    #pm2-5.particles-0-3
    wait_ms(200)
</code></pre>
]]></description><link>https://community.m5stack.com/topic/1138/pm2-5-and-mqtt-incomplete-python-code</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 09:48:09 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/1138.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 Jul 2019 04:55:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to pm2.5 and mqtt incomplete python code on Thu, 12 Dec 2019 21:27:03 GMT]]></title><description><![CDATA[<p dir="auto">This is already requested some time ago via git.  Still not filled.</p>
]]></description><link>https://community.m5stack.com/post/6677</link><guid isPermaLink="true">https://community.m5stack.com/post/6677</guid><dc:creator><![CDATA[OyczE]]></dc:creator><pubDate>Thu, 12 Dec 2019 21:27:03 GMT</pubDate></item><item><title><![CDATA[Reply to pm2.5 and mqtt incomplete python code on Thu, 12 Dec 2019 20:45:16 GMT]]></title><description><![CDATA[<p dir="auto">You can't edit micropython and then switch back to blocks as your edited code wont have a matching block code in its librarys.<br />
Also last time I checked, temperature and humidity from the PM2.5's internal sensors are not supported.</p>
]]></description><link>https://community.m5stack.com/post/6675</link><guid isPermaLink="true">https://community.m5stack.com/post/6675</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Thu, 12 Dec 2019 20:45:16 GMT</pubDate></item><item><title><![CDATA[Reply to pm2.5 and mqtt incomplete python code on Thu, 12 Dec 2019 19:04:49 GMT]]></title><description><![CDATA[<p dir="auto">that is frequently the case that one ends by manually adapting the code.<br />
BTW: do you have some description of the functions, like <em>get_pm2_5_factory</em> which delivers values in µg/m³, the number of particles is per dm³  acc <a href="https://www.aliexpress.com/item/32725547467.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.aliexpress.com/item/32725547467.html</a></p>
]]></description><link>https://community.m5stack.com/post/6673</link><guid isPermaLink="true">https://community.m5stack.com/post/6673</guid><dc:creator><![CDATA[Efried]]></dc:creator><pubDate>Thu, 12 Dec 2019 19:04:49 GMT</pubDate></item></channel></rss>