[Guide] How to use the CLOCK

I've been working on a way to set the time on an ESP32 over BLE, eventually I found a way. I used the included Arduino code on the ESP32, adapted with the use of the ESP32Time library, as this allows you to set the RTC directly, most solutions involve connecting to the internet to get the time from an NTP server, my product will be carried around across the world to getting the time from a phone makes much more sense.

Challenges:

  • BLE works with short strings, this meant converting the millis clock to a string, I added "" to it to get that to happen. Other ways are suggested but they didn't work for me.
  • Although the system time took into account the UTC offset, the millis time didn't, adding the result of the 'Z' format didn't work either, the less well-known 'X' format for time zone offset did.

Perhaps it's easier to see by looking at my blocks, there's a bit added for debugging. I'm using a variable tzone1 to pass the UTC offset around.

1 Like

Hey everyone.. i read this article a bunch of times, but i still have no clue on how to make a simple delay.. can anyone help?

2 Likes

Thanx. a wonderfull blog page

Hi, Hope help U
Pause.aia (2,1 KB)

Thanks a bunch! it helped :grin:

1 Like

It will end in tears if you take that approach!! :rage:

Like this:

image

9 Likes

hi same here i have also not understand. But, follow these step which is above 'how to make a clock' :slight_smile:

Why is a wait procedure generally a bad idea?
The model of event processing in App Inventor by Lyn

Please Wait method by Scott

Taifun

3 Likes

I wonder if writing these pause procedures correlates with having a sleep disorder, where the coder retires to their bed at night but just lies there all night staring at their clock?

I knew some one with an autistic child. The child never slept at night. It wrecked the parent's health.

The Clock Timer requires a leap of faith.

It requires you to fall off the end of your current Event block, and accept that control will resume in a Clock Timer or another Event block.

This may come as a surprise to people who started out coding in non-event oriented environments.

6 Likes

Is true, I change my program, with enable a clock, and change the action with a variable, then disable the cloc. Is easier. Thanks TIMAI2

Did you mention which builder are you using, I don't think this is MIT App Inventor, at all :thinking:

Hi I am very new to this site so I don't know anything, this will probably will be of use to me!

Actually looks like it is App Inventor - it's just the colour resolution of the screen the images were captured from?

2 Likes

actually, it looks like kodular, which is not app inventor

and the checkboxes of the properties look so purple but in app inventor it's blue

Actually, it really doesn't matter....

7 Likes

But if the things are different on another builder, I am only concerned abut that...

Clearly the Blocks are identical in function if not in colour (which is why I doubted they were Kodular blocks as they didn't burn holes in my eyes) Of course, they could indeed be Kodular blocks but as Tim points out, it doesn't matter in this specific case.

4 Likes

Oh so now I get it... :wink:

Yes you are right. But as there were a lot of "Do It's" I performed to get the desired outputs to make the guide, it would have been quite tedious for me to do the same in the App Inventor builder once again. Hence I just took snaps of the Kodular blocks, where I was working initially.

3 Likes