Can you request time from an AdafruitIO Feed in Circuit Pyth

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
pcswanson
 
Posts: 4
Joined: Mon Feb 03, 2020 11:39 am

Can you request time from an AdafruitIO Feed in Circuit Pyth

Post by pcswanson »

Hello all, I'm putting together a project that involves a MatrixPortal M4 board pulling data from my Adafruit IO account (which works fine) but I am hitting a wall trying to set the clock on the board from an online time sync. The examples in the Learn section show how to set the time from a Network Time Service using:

Code: Select all

NETWORK = Network(status_neopixel=board.NEOPIXEL, debug=False)
NETWORK.connect()
to connect and then

Code: Select all

NETWORK.fetch_data('http://www.geoplugin.net/json.gp',
                           json_path=[['geoplugin_latitude'],
                                      ['geoplugin_longitude']]))
But I can't run this in the same program that is accessing IO, because then I have two things using the wifi and I get an "ESP_BUSY in use" error.

The Time Services docs makes it sound like the GET functions aren't supported in CircuitPython. Any suggestions?

User avatar
ksprayberry
 
Posts: 45
Joined: Tue Feb 05, 2019 8:52 pm

Re: Can you request time from an AdafruitIO Feed in Circuit

Post by ksprayberry »

Have you had a peek at this? https://learn.adafruit.com/weather-disp ... lay-matrix? It uses the

Code: Select all

network.get_local_time()
to fetch the time periodically.

Then I used this to parse out the parts of the date and time I needed. I think this is how it's done, but I'm kind of a hack at it.

Code: Select all

        Mymonth = time.localtime()[1]
        Myyear = time.localtime()[0]
        Myday = time.localtime()[2]
        Mymin = time.localtime()[4]
        Myweekday = time.localtime()[6]
        prv_hour = time.localtime()[3]
        resetmytime()

User avatar
pcswanson
 
Posts: 4
Joined: Mon Feb 03, 2020 11:39 am

Re: Can you request time from an AdafruitIO Feed in Circuit

Post by pcswanson »

Thanks, yes I have used this in my code, but it only requests the local time on the board which is just set to 12:00 when you power it up. I'm looking to request the actual time from an online time server to set this local time.

User avatar
Rimwolf
 
Posts: 1
Joined: Wed Apr 29, 2015 7:43 pm

Re: Can you request time from an AdafruitIO Feed in Circuit

Post by Rimwolf »

Adafruit.IO does run a time service; see https://learn.adafruit.com/adafruit-mag ... -date-time

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”