NodeMCU Projects: Difference between revisions

Line 532:
import time
 
# Deep Sleep
def deep_sleep(delta):
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
print('woke from a deep sleep')
rtc.alarm(rtc.ALARM0, delta*1000*60)
machine.deepsleep()
# LCD Config
spi = SPI(1, 10000000)
d = max7219.Max7219(32, 8, spi, Pin(15), False)
 
cntry = ["India", "China", "Italy", "Iran", "Canada", "USA", "Ireland", "Germany", "Pakistan", "France", "Spain"]
 
while True:
# Print Global Data
try:
res = requests.get(url='http://coronavirus-19-api.herokuapp.com/all')
Line 548 ⟶ 558:
time.sleep(5)
continue
# Print Country Data
for i in cntry:
link = 'http://coronavirus-19-api.herokuapp.com/countries/%s' %i
Line 560 ⟶ 571:
time.sleep(5)
continue
 
# Sleep for 30 minutes
print("Deepsleep for 30 minutes")
deep_sleep(30)
</syntaxhighlight>