element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • 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
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • 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
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs How many sunny hours do we have?
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: alainlavanchy
  • Date Created: 10 Nov 2020 10:41 AM Date Created
  • Views 503 views
  • Likes 8 likes
  • Comments 4 comments
  • lux-sensor
  • azure
  • lux
  • graphical display
  • iothub
  • nodemcu
Related
Recommended

How many sunny hours do we have?

alainlavanchy
alainlavanchy
10 Nov 2020

A nodeMCU with a lux sensors and the DRiBox to measure the sunny hours per day.

 

German version available here: https://reterra.ch/sonne-auf-dem-dach/

 

For quite some time my neighbours and us were thinking of adding a solar system to the roofs of our houses. While we have a lot of sun during summer months, in autumn, winter and spring foggy days are much more common than sunny days. I wanted to know it more in detail, as well as do a first apporach in using the Azure IOT hub. In this blog I will take you along the steps it took me to make the system work.

 

You will find here

    • Steps and goals
    • Used material
    • Hardware
    • Coding
      • C1 - Connect the nodeMCU to the wireless network
      • C2 - Setting up Azure IOT

 

 

Steps and goals

  • Measure the light intensity
  • Save the data to the Azure IOT hub
  • Determine the number of sunny hours per day
  • Display the data in a graphical way

 

Used material

I decided to use a nodeMCU, as the WiFi connectivity is already built in. That what I used for my project:

  • nodeMCU
  • TSL2591 lux sensor
  • Small powerbank
  • 5V solar cell
  • DRiBox by Sockitbox
  • Hardwood board
  • Cubes made out of concrete

 

 

Hardware

There is not really a lot to do for the microcomputer but get the sensor data and send it to the IOT hub of Azure. I decided to go with a nodeMCU ESP8266. It hast a built-in WiFi connectivity, is small, cheap and supports I2C. After I already have started building the system I noticed it even has a deep sleep mode. The energy consumption can therefor get optimized, but later more on that.

 

The sensor is a TSL2591 lux sensor. It measures the light intensity and additionally also the amount of IR radiation.

 

 

Coding

When developing software, I normally try to slice my programm first into smaller components and try them out seperately. In this case I will do this as well. There is a great library available for the TSL2591 sensor including several code samples. Therefore I will first do the Azure IOT connectivity.

 

C1 - Connect the nodeMCU to the wireless network

The first part of the code is to connect the nodeMCU to my wifi. The system will at the end be on my roof, so I don't have a terminal to see if the connection to the WiFi works or not. I use the internal LED at GPIO2 for signaling the status of the connection.

 

#include <ESP8266WiFi.h>        // Include the Wi-Fi library

const char* ssid     = "SSID";         // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "PASSWORD";     // The password of the Wi-Fi network

void setup() {
  pinMode(2, OUTPUT);     // Initialize GPIO2 pin as an output

  WiFi.begin(ssid, password);             // Connect to the network
  
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    delay(1000);
    digitalWrite(2, LOW);   // Turn the LED on by making the voltage LOW
    delay(1000);            // Wait for a second
    digitalWrite(2, HIGH);  // Turn the LED off by making the voltage HIGH
  }

   digitalWrite(2, LOW);    // Turn the LED off by making the voltage LOW
   delay(3000);
digitalWrite(2, HIGH);     // Turn the LED off by making the voltage HIGH
}

void loop() { }

 

And yes, it works as expected. Only problem that occurs some time is that your not able to see the builtin LED blinking due to a fast connection to the WiFi.

 

C2 - Setting up Azure IOT

I decided to use the Azure service by Microsoft. The data storage services by Google or Amazon would also be possible I guess. But Microsoft seems to me to be more secure for not misusing the data.

 

First you have to create a Azure account. That's no big deal, so I will not show it steps by steps. It's really easy, you need a credit card though. They don't bill you at the start and you also get free services to start with.

You need the following services from Azure:

  • Event hub - to communicate with the nodeMCU
  • Stream analytics job - to send your data to the storage
  • Some storage - to store the data

 

This video tutorial shows you step by step what to do. It's important that you locate all your services in the same region. If not, you will have to pays to transfer your data inbetween.

 

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

  • Sign in to reply

Top Comments

  • dubbie
    dubbie over 2 years ago +3
    This looks interesting. I have messed about with solar cells and measuring sunlight intensity off and on for several years. One interesting feature is that the colder solar panels get the more efficient…
  • ralphjy
    ralphjy over 2 years ago +2
    To get a better idea of the effective solar irradiance make sure to mount your sensor in the same orientation (plane) that you would mount your solar panels. At higher latitudes there is a significant…
  • alainlavanchy
    alainlavanchy over 2 years ago in reply to ralphjy +2
    At the moment we have a flat roof, so the solar system would be at a slight angle headed towards east and west. But we plan to add a floor to our house and then will have another form of roof. So for now…
  • colporteur
    colporteur over 2 years ago

    I think it is the ideal project for someone considering investing in solar power. It would give you data that could help you analyse what you hope to achieve. I think it would be a good placement determination tool also.

     

    Augh crap, I didn't realize the apartment building would cause me to lose exposure!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • alainlavanchy
    alainlavanchy over 2 years ago in reply to ralphjy

    At the moment we have a flat roof, so the solar system would be at a slight angle headed towards east and west. But we plan to add a floor to our house and then will have another form of roof. So for now I hope to measere like a general sun duration using this small clear dome.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ralphjy
    ralphjy over 2 years ago

    To get a better idea of the effective solar irradiance make sure to mount your sensor in the same orientation (plane) that you would mount your solar panels.  At higher latitudes there is a significant shift in the sun's incident angle from summer to winter.  I'm at about 45 degrees N and I have a south facing roof with a 40 degree pitch, so I get a reasonable compromise between summer and winter performance.  One depressing thing about tracking the data is that you get to see how many non-productive days you have during the winter image.   We had wildfires during September and I lost about two weeks of energy due to the heavy smoke in the area.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dubbie
    dubbie over 2 years ago

    This looks interesting. I have messed about with solar cells and measuring sunlight intensity off and on for several years. One interesting feature is that the colder solar panels get the more efficient they become, so they actually work better in the winter when there is less light.

     

    It is also difficult to get good data on sunlight intensity throughout the year so it will be good to see your data.

     

    Dubbie

    • Cancel
    • Vote Up +3 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 © 2023 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube