CODE: mqtt.bas
CODE: mqtt3.bas
'for z = 1 to 10
'print mqtt.setup("maqiatto.com")
'print ramfree
'print mqtt.disconnect()
'print ramfree
'print mqtt.connect("sergei@sharklasers.com", "sergei")
'print ramfree
'print mqtt.subscribe("sergei@sharklasers.com/entra")
'print ramfree
''print mqtt.publish("sergei@sharklasers.com/prova", "Annex"+str$(z))
''print ramfree
'onmqtt mqtt_msg
'next z
'print mqtt.setup("maqiatto.com")
'print mqtt.connect("sergei@sharklasers.com", "sergei")
'print mqtt.subscribe("sergei@sharklasers.com/entra")
'print ramfree
'for z = 1 to 10
'print mqtt.publish("sergei@sharklasers.com/prova", "Annex"+str$(z))
'print ramfree
'next z
'endprint mqtt.setup("maqiatto.com")print mqtt.connect("sergei@sharklasers.com", "sergei")print mqtt.subscribe("sergei@sharklasers.com/entra")onmqtt mqtt_msgfor z = 1 to 10 print mqtt.publish("sergei@sharklasers.com/prova", "Annex"+str$(z)) 'print mqtt.refresh() 'pause 1000next zprint ramfreewaitmqtt_msg:print "-------"; mqtt.topic$print "-------"; mqtt.message$return
' Simple program using Annex and a MAX7219 dot matrix module
' by cicciocb 2019
'Set 4 8x8 displays with GPIO15 as CS pin
Openweather_ID$ = "1f7dd1b2a6ffcf80c1e20b5d5365f545"
Town$ = "Toulouse,fr"
Language$ = "fr"
Units$ = "metric"
MAXSCROLL.SETUP 4, 15
intensity = 5
'Set the first message with Annex
MAXSCROLL.PRINT "Annex"
MAXSCROLL.SHOW 31, intensity
weather$ = ""
onWgetAsync asynco
wlog mqtt.setup("maqiatto.com")
wlog mqtt.connect("waller@apown.com", "waller")
wlog mqtt.subscribe("waller@apown.com/clock3d")
onmqtt mqtt_msg
'endprint mqtt.setup("maqiatto.com")print mqtt.connect("sergei@sharklasers.com", "sergei")print mqtt.subscribe("sergei@sharklasers.com/entra")onmqtt mqtt_msgfor z = 1 to 10 print mqtt.publish("sergei@sharklasers.com/prova", "Annex"+str$(z)) 'print mqtt.refresh() 'pause 1000next zprint ramfreewaitmqtt_msg:print "-------"; mqtt.topic$print "-------"; mqtt.message$return
CODE: mqtt2.bas
msg_counter = 0message$ = "" 'mqtt message receivedpause 1000'Set the refresh rate of the display (50 msec) - lower values -> scroll fasterTIMER0 50, SCROLLME' timer for the weather infotimer1 20000, get_weathergosub get_weatherWAITSCROLLME: 'Scroll the display with the intensity defined beforeMAXSCROLL.SCROLL intensity if msg_counter <= 0 then ' Set the text with the Date and Time MAXSCROLL.NEXT DATE$ + " " + left$(TIME$, 5) + " " + weather$else MAXSCROLL.TEXT message$end ifRETURNget_weather:wgetasync("api.openweathermap.org/data/2.5/weather?q=" + town$ + "&lang=" + language$ + "&units=" + Units$ + "&appid=" + Openweather_ID$, 80)msg_counter = msg_counter - 1returnasynco:a$ = wgetresult$'wlog a$'k$ = ""'for z = 126 to 248'k$ = k$ + chr$(z)'next zweather$ = json$(a$, "weather.temp") + chr$(248) + "C " + json$(a$, "weather.pressure") + "hPa " + json$(a$, "weather.humidity") + "% " + json$(a$, "weather.description")weather$ = replace$(weather$, "é", chr$(130))weather$ = replace$(weather$, "è", chr$(138))weather$ = replace$(weather$, "à", chr$(133))returnmqtt_msg:wlog "TOPIC : "; mqtt.topic$wlog "MESSAGE: "; mqtt.message$message$ = mqtt.message$MAXSCROLL.SHOW 0, intensity msg_counter = 1return
z = 0
t = 0
COUNTER.SETUP 1, 15, 3
COUNTER.SETUP 2, 14, 3
print mqtt.setup("maqiatto.com")
print mqtt.connect("sergei@sharklasers.com", "sergei")
print mqtt.subscribe("sergei@sharklasers.com/entra")
onmqtt mqtt_msg
timer0 500, mqtt_out
'for z = 1 to 10
' print mqtt.publish("sergei@sharklasers.com/prova", "Annex"+str$(z))
' 'print mqtt.refresh()
' 'pause 1000
'next z
print ramfree
wait
mqtt_msg:
print "-------"; mqtt.topic$
print "-------"; mqtt.message$
returnmqtt_out:a = mqtt.publish("sergei@sharklasers.com/prova", "ESP "+str$(z))z = z + 1a = mqtt.publish("sergei@sharklasers.com/temp", str$(t))t = t + 1if t > 40 then t = 0return