element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
1 Meter of Pi
  • Challenges & Projects
  • Design Challenges
  • 1 Meter of Pi
  • More
  • Cancel
1 Meter of Pi
Blog Blog# 9 EAS - Electrical and Class Unit Testing
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: skruglewicz
  • Date Created: 27 Dec 2020 3:24 AM Date Created
  • Views 689 views
  • Likes 6 likes
  • Comments 2 comments
Related
Recommended

Blog# 9 EAS - Electrical and Class Unit Testing

skruglewicz
skruglewicz
27 Dec 2020

image

BLOG# 9 -Edible Algae System - (Growing Spirulina in space)

Developmental Unit Testing

This is my 9th blog post in a series of blog post for the Design Challenge 1 Meter of Pi

Updated version 1.2

,<<< PREVIOUS BLOG

NEX BLOG  >>

Blog# 8.2 (Part 2 of 2) EAS - DATA REPOSITORY MongoDB

Blog# 10 Application Implementation and Tests

INTRODUCTION

  • This blog will describe the Unit Test done on each component of the system
    • the test will be broken into 2 groups Electronic and Software
      • The Software Only Test section
        • I will contain sections on the python code used to test the database,alerts and and timer classes from the class diagram described in Blog#8.1
      • The Software/Electronic Test section
        • I will Test the controller(Automation hat) and sensor(Environ Hat) classes along with the devices attached as described in Blog# 8.1
        • Problem 1

          I ws unable to get a circut working to connect output 1,2,3 to a working Circut containing the LED Light, WaterPump and the WaterHeater Pad.

          I gesign the controller class to tun on/off these devices from the outputs of the Automation hat

          I will be working on this hopefully I'l figure it out

        • Problem  2

          With output 2 from the Automation HAT, It wil turn on but the test circut will not light the LED?

           

        • For the Controller test I have attached all 3 outputs to the test circuit that will turn ON/OFf an LED. This will allow me to Unit test the controller module. This is how I found theat output2 was not working?

 

  • Software Only Test
      • Alerts
        • alerts.py
        • TEST run and results
      • Timers
      • timer.py
        • TEST run and results
          • Test 1
          • Test 2
          • Test 3
          • Test 4
        • db.py
        • TEST run and results
          • Test 1
          • Test  2
          • Test  3
          • Test  3
          • Test  4
  • Software/Electronic Test
      • Sensors
        • sensors.py
        • TEST run and results
            • Test 1 the start of the test run
            • Test 2
            • Test 3 Atlass Chart Dashboard
            • Test 4 -- Document list
            • Test 5 - Atlase charts
      • Controllers
        • controllers.py
        • --CODE
        • TEST run and results
            • TEST 1
            • TEST 2
  • Conclusion and Summary

Software Only Test

  • This section will contain sections on the python code used to test the database,alerts and and timer clases from the class diagram described in Blog#8.1
    • Each class module contains testing code which I will run and document the results
    • When I was developing each class I placed a "if __name__ == __main__" at the end of each module file.
    • I made sure each child class or module was working as I coded. This process is commonly refered to as Test-Driven Development (TDD)
    • I will run each test and document my results

 

Alerts

alerts.py

--CODE

 

TEST run and results

  • the following screenshot shows:
  •      THe Visual Studio run of the test script
  •      The test run output is display in the Terminal window beneath the code.
  •      the Mongodb Alerts Collection is displayed on the left, indicating that the data was saved properly.
  •      Later section in this blog will display the test run in this format.

image

Timers

timer.py

--CODE

TEST run and results

 

  • Test 1
    • Showing the first timer being set and the data saved to the collection Timers

image

 

  • Test 2
    • showing the second timer running and the data added to the colection Timers.

image

 

  • Test 3
    • Showing the third timer running
    • I did not refresh the data collection screen, so the data in the clolection is not displayed. It will be displayed in the next screenshot.

image

 

 

Test 4

Showing the forth and final timer running

And the 4 documents in the alerts collection view on the Left.

 

 

image

 

 

 

DATA

db.py

--CODE

TEST run and results

 

  • Test 1
    • THe run of the test THere is no logging in the out.
    • The MongoDB database list is shown on the left. It list all the tables created in the script. showing on document for each.
    • I stated out with an empty database before this test run(I deleted all the data in the database)
    • It should be noted here, that if a collection is not present in the database the insert statement will create it and put the data into it.

image

 

 

  • Test  2
    • I wanted to show the putSensore() method in the screen
    • I'm displaying the Light collection with the docuent inserted from the test run

 

 

image

 

 

 

 

  • Test  3
    • I wanted to show the putController() method() in the screen
    • I'm displaying the LedLight collection with the docuent inserted from the test run

 

image

 

 

  • Test  3
    • I wanted to show the putAlerts() method in the screen
    • I'm displaying the Alerts collection with the docuent inserted from the test run

 

 

image

 

 

  • Test  4
    • I wanted to show the putTimer() method in the screen
    • I'm displaying the timers collection with the docuent inserted from the test run

image

 

That does it for these three class modules. THe next section will describe the Controller and Sensor class test.

 

 

Software/Electronic Test

This section will Test the controller(Automation hat) and sensor(Environ Hat) classes along with the devices attached as described in Blog# 8.1

 

Sensors

sensors.py

--CODE

TEST run and results

 

  • Environ Hat  -  the three sensors used for:
    • Roomtemp
    • RoomHumiidity
    • RoomLight
  • Water temp Sensor used for:
    • WaterTemp

 

 

Test 1 the start of the test run

image

 

Test 2

I let the test Runn for a little while acumulating documents

image

Test 3 Atlass Chart Dashboard

image

Test 4 -- Document list

showing the number of documents in each sensor collection.

image

Test 5 - Atlase charts

Showing the Roomlight and the Water Tempreture during the Run

image

Controllers

controllers.py

 

--CODE

TEST run and results

The following  video will show the controller test running and turning ON and OFF the Test circut LED.

Notice that the LED does not light for WaterPump on output2 even though the driver status indicated it's on.?

I spent a while trying to figure out why but had to move on.

image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

 

  • AutomationHat -- output 1-3
    • LEDLight               output1
    • WaterPump           output2
    • WaterHeaterPad   output3
    • There was not enough outputs for these devices, so they are Not implemented yet. But the classes are included.
      • RoomHeater         
      • IntakeFan              
      • OutTakeFan 

 

  • TEST 1
    • the Light section of the test script is displayed
    • Shows the entire run with the  LedLight collection display with the 2 documents with the on/off times

image

 

  • TEST 2
    • The waterpump test script is shown
    • the WaterPump and the WaterHeater collections are displayed on the left.

 

image

 

Conclusion and Summary

in this blog I ran test on the devices connected to the system and the Classes that I implemented in the previous blog# 8.1

Did all the test Run?
Ans: NO
  • I had problems with the following
    • See above 2 problems
  • Test Completed with Sucesss
    • Alerts
    • DB
    • Timers
    • Sensors
  • What Test Failed and Why?
    • Controller
      • DId not Turn on the LED for output1 the waterpump
  • I was not able to implement the following because I was unble to get these devices connected to the Automation Hat
    • Water Heater
    • Water Pum
    • LED Lamp

 

Now onto the Implementation of scripts to use these classes in my next Blog......

 

,<<< PREVIOUS BLOG

NEX BLOG  >>

Blog# 8.2 (Part 2 of 2) EAS - DATA REPOSITORY MongoDB

Blog# 10 Application Implementation and Test
  • Sign in to reply

Top Comments

  • DAB
    DAB over 4 years ago +1
    Nice update. Good step in testing the software before HW integration. DAB
  • skruglewicz
    skruglewicz over 4 years ago in reply to DAB

    THanks DAB

    I published before I was done. I'll be updateing it tonight.

    Steve K

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 4 years ago

    Nice update.

     

    Good step in testing the software before HW integration.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube