NodeMCU Projects: Difference between revisions
Content added Content deleted
Line 532: | Line 532: | ||
import time |
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) |
spi = SPI(1, 10000000) |
||
d = max7219.Max7219(32, 8, spi, Pin(15), False) |
d = max7219.Max7219(32, 8, spi, Pin(15), False) |
||
cntry = ["India", "China", "Italy", "Iran", "Canada", "USA", "Ireland", "Germany"] |
cntry = ["India", "China", "Italy", "Iran", "Canada", "USA", "Ireland", "Germany", "Pakistan", "France", "Spain"] |
||
while True: |
while True: |
||
# Print Global Data |
|||
try: |
try: |
||
res = requests.get(url='http://coronavirus-19-api.herokuapp.com/all') |
res = requests.get(url='http://coronavirus-19-api.herokuapp.com/all') |
||
Line 548: | Line 558: | ||
time.sleep(5) |
time.sleep(5) |
||
continue |
continue |
||
# Print Country Data |
|||
for i in cntry: |
for i in cntry: |
||
link = 'http://coronavirus-19-api.herokuapp.com/countries/%s' %i |
link = 'http://coronavirus-19-api.herokuapp.com/countries/%s' %i |
||
Line 560: | Line 571: | ||
time.sleep(5) |
time.sleep(5) |
||
continue |
continue |
||
# Sleep for 30 minutes |
|||
print("Deepsleep for 30 minutes") |
|||
deep_sleep(30) |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||