Difference: SolutionsToRealTimeClockAndDataLogging (1 vs. 3)

Revision 32020-05-27 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Solutions"

Solutions to Exercise 9: Real Time Clock and Data Logging

Exercise 1:

Line: 20 to 20
  The exercise sheet already shows how to use the program
Added:
>
>

Exercise 5: Write "Hello World!" file to the SD card

In the solution I mount the SD card (skipping the OSError EPERM emitted if the card is already mounted). I then check with uos.stat if the data directory already exists and I create it if not. Then I open the hello.txt file for writing and I write "Hello World!" onto the file. I finish writing by closing the file.

In order to be sure everything went ok I re-open the file, this time for reading. I read the content and print it before closing the file again.

sdcardHello.png

I can the connect to the Internet through WiFi and start the ftp server. This allows me to transfer the hello.txt file to the PC and print it there.

uftpd.png

ftpHello.png

Here is the script:

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToRealTimeClockAndDataLogging/mountSD.py.txt

Exercise 6: Data acquisition and logging with time stamp

This exercise is quite similar to the previous one with the exception that we write real data now. You have already seen how to read out the SHT30 using the SHT3X driver and you can easily get at the time stamp with now = time.time() if you have set up the correct time with ntptime before.

In this case I open the file for writing in append mode and I close it again after having written a new data sample.

sht30Readout.png

I recuperate the data through ftp on the PC side:

ftpSHT30Data.png

Finally I convert the time to a humanly readable form and I compare it to the time seen in MicroPython:

cpythonTime.png

And here is the script:

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToRealTimeClockAndDataLogging/sht30Readout.py.txt

 -- Uli Raich - 2020-05-06

Comments

Line: 30 to 67
 
META FILEATTACHMENT attachment="wifi_connect_UCC.py.txt" attr="" comment="" date="1590402547" name="wifi_connect_UCC.py.txt" path="wifi_connect_UCC.py.txt" size="2084" user="UliRaich" version="1"
META FILEATTACHMENT attachment="dayOfWeek.py.txt" attr="" comment="" date="1590402547" name="dayOfWeek.py.txt" path="dayOfWeek.py.txt" size="1738" user="UliRaich" version="1"
META FILEATTACHMENT attachment="wifi_connect_print.png" attr="" comment="" date="1590406391" name="wifi_connect_print.png" path="wifi_connect_print.png" size="43254" user="UliRaich" version="2"
Added:
>
>
META FILEATTACHMENT attachment="mountSD.py.txt" attr="" comment="" date="1590572655" name="mountSD.py.txt" path="mountSD.py.txt" size="1659" user="UliRaich" version="1"
META FILEATTACHMENT attachment="sht30Readout.py.txt" attr="" comment="" date="1590572655" name="sht30Readout.py.txt" path="sht30Readout.py.txt" size="2766" user="UliRaich" version="1"
META FILEATTACHMENT attachment="ftp.png" attr="" comment="" date="1590572808" name="ftp.png" path="ftp.png" size="75341" user="UliRaich" version="1"
META FILEATTACHMENT attachment="micropythonTime.png" attr="" comment="" date="1590572808" name="micropythonTime.png" path="micropythonTime.png" size="7083" user="UliRaich" version="1"
META FILEATTACHMENT attachment="cpythonTime.png" attr="" comment="" date="1590575019" name="cpythonTime.png" path="cpythonTime.png" size="30848" user="UliRaich" version="2"
META FILEATTACHMENT attachment="ftpHello.png" attr="" comment="" date="1590573379" name="ftpHello.png" path="ftpHello.png" size="81983" user="UliRaich" version="1"
META FILEATTACHMENT attachment="uftpd.png" attr="" comment="" date="1590573379" name="uftpd.png" path="uftpd.png" size="6218" user="UliRaich" version="1"
META FILEATTACHMENT attachment="sdcardHello.png" attr="" comment="" date="1590573555" name="sdcardHello.png" path="sdcardHello.png" size="19046" user="UliRaich" version="1"
META FILEATTACHMENT attachment="sht30Readout.png" attr="" comment="" date="1590574772" name="sht30Readout.png" path="sht30Readout.png" size="112030" user="UliRaich" version="1"
META FILEATTACHMENT attachment="ftpSHT30Data.png" attr="" comment="" date="1590574772" name="ftpSHT30Data.png" path="ftpSHT30Data.png" size="139615" user="UliRaich" version="1"

Revision 22020-05-25 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Solutions"

Solutions to Exercise 9: Real Time Clock and Data Logging

Added:
>
>

Exercise 1:

 
Changed:
<
<
Article text.
>
>
Since connecting to the Internet through WiFi is a very common task, we develop a module doing only this. The module can be put into the /lib directory on the ESP32 (or even better: frozen into the binary of MicroPython) making it available also for later exercises.

Here is a program connecting to the Internet through WiFi. You will have to modify it in order to adapt it to your WiFi SSID and password.

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToRealTimeClockAndDataLogging/wifi_connect_UCC.py.txt

... and this is how to access it and what it will print as answers:

wifi_connect_print.png

Exercise 2:

Sometimes you may not have access to WiFi but you want to set the time nevertheless. Then the solution to exercise 2 comes in handy:

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToRealTimeClockAndDataLogging/esp32RTC.py.txt

The exercise sheet already shows how to use the program

  -- Uli Raich - 2020-05-06
Line: 10 to 26
 
<--/commentPlugin-->
Changed:
<
<
META FILEATTACHMENT attachment="esp32RTC.py.txt" attr="" comment="" date="1588795527" name="esp32RTC.py.txt" path="esp32RTC.py.txt" size="4603" user="UliRaich" version="1"
>
>
META FILEATTACHMENT attachment="esp32RTC.py.txt" attr="" comment="" date="1590402547" name="esp32RTC.py.txt" path="esp32RTC.py.txt" size="4602" user="UliRaich" version="2"
META FILEATTACHMENT attachment="wifi_connect_UCC.py.txt" attr="" comment="" date="1590402547" name="wifi_connect_UCC.py.txt" path="wifi_connect_UCC.py.txt" size="2084" user="UliRaich" version="1"
META FILEATTACHMENT attachment="dayOfWeek.py.txt" attr="" comment="" date="1590402547" name="dayOfWeek.py.txt" path="dayOfWeek.py.txt" size="1738" user="UliRaich" version="1"
META FILEATTACHMENT attachment="wifi_connect_print.png" attr="" comment="" date="1590406391" name="wifi_connect_print.png" path="wifi_connect_print.png" size="43254" user="UliRaich" version="2"

Revision 12020-05-06 - UliRaich

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="Solutions"

Solutions to Exercise 9: Real Time Clock and Data Logging

Article text.

-- Uli Raich - 2020-05-06

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="esp32RTC.py.txt" attr="" comment="" date="1588795527" name="esp32RTC.py.txt" path="esp32RTC.py.txt" size="4603" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback