Simple IOT Sunlight Sensing Raspberry Pi Project – SunIOT Part 1

Simple IOT Sunlight Sensing Raspberry Pi Project – SunIOT Part 1SunIOT

At SwitchDoc Labs we have been building a number of prototype IOT (Internet Of Things) devices for a number of different videos, articles, products and books we have been working on.   Our latest Book,  “Raspberry Pi IoT Projects: Prototyping Experiments for Makers“, has been selling well on Amazon, published by APress-Springer/Daniel.  Our first O’Reilly Publishing tutorial video, “Introduction to the ESP8266 and the IOT” also just came out.  Time for a new project, SunIOT.

We just have added a new product, a Grove Sunlight Sensor to our lineup and wanted to build a project using it.   We are intending to add drivers for this sensing device to three of our product lines:  OurWeather, the GroveWeatherPi and the WXLink wireless data transmission products.  Since we are going to be using the Grove Sunlight Sensor so extensively, we thought we should build a quick example project.

SunIOT was thus born.   We will be building this project in four postings.  FIrst the description of the project (Part 1).  Secondly, we get the hardware up and connected , Python connected to both of the Grove devices (Part 2), Part 3 will have us connect up to initialstate.com and then in Part 4, we will use MQTT to connect to a dashboard, freeboard.io (and pubnub.com).

[include-page id=”SunIOTLinks”]

What is SunIOT?

The overall design of the project is simple.   We use the Raspberry Pi to read  a sensor that measures sunlight and breaks the sunlight down into three components (UV, IR and Visible). We also use an LED to provide visual feedback that a sample is being taken (two blinks) and that the process is still running (one blink).

The general idea of SunIOT is to build a software platform to build more complex IOT sensors.   In this column and the next, we will be going through a complete, albeit simple, IOT design.   As well as providing a test bed for the new Grove Sunlight Sensor.

figure-2

Hardware

The parts list for the SunIOT project is  follows.

What are Grove Connectors

Grove is a modular, standardized connecter prototyping system. Grove takes a building block approach to assembling electronics. Comparedfigure-3 to the jumper or solder based system, it is easier to connect, experiment and build and simplifies the learning system, but not to the point where it becomes dumbed down.  Some of the other prototype systems out there takes the level down to building blocks.   Good stuff to be learned that way, but the Grove system allows you to build real systems.   It requires some learning and expertise to hook things up.  Full Grove tutorial here.

The Grove system consists of a base unit and various modules with standardized connectors.

The Base unit allows for easy connection of any input or output from the Grove modules. and every Grove module typically addresses a single function, such as a simple button or a more complex heart rate sensor.   Two examples of base units are the Pi2Grover ($20) from SwitchDoc Labs and GrovePi+ ($30) from Dexter Industries.   The big difference between these two units, aside from price, is that the Pi2Grover provides a direct connection between the Raspberry Pi and the Grove units (allow normal python drivers to work without modification) while GrovePi+ puts an Arduino between the Grove device and the Raspberry Pi (which requires new drivers to be written for the GrovePi+ board).

You don’t need a Base unit to connect up to Grove modules.   You an use a cable (jumper wires to Grove connector) to run from the pins on the Raspberry Pi or Arduino to the Grove connectors.

Raspberry Pi 3

figure-4The Raspberry Pi 3 Model B features a quad-core 64-bit ARM Cortex A53 clocked at 1.2 GHz. This puts the Pi 3 roughly 50% faster than the Pi 2. The RAM remains the same – 1GB of SDRAM. The Pi 3 includes on-board 802.11n WiFi and Bluetooth 4.0. WiFi, wireless keyboards, and wireless mice now work out of the box.

Why are we using the Raspberry Pi 3 rather than a less expensive Raspberry Pi Zero?   Well, over the last three projects at SwitchDoc Labs, we have found it much easier to develop the software and hardware using a Pi 3 for speed reasons (especially reboot speeds!) and then porting the resulting software and hardware over to a Pi Zero (as we did recently with the SkyWeather2  Solar powered weather station).

Pi2Grover

The Pi2Grover board provides buffered connections and voltage translation between the Raspberry Pi pins and external Grove modules.figure-5   Pi2Grover provides bi-directional Pi2Grover voltage translation from the Raspberry Pi (3.3V) to 5V.   The board is “transparent” to any software, so existing drivers for modules will work with no translation required.   Voltage translation for I2C Bus is also supported by the Pi2Grover board.

 

figure-6

Grove Sunlight Sensor – SI1145

hardware_overviewThe Grove Sunlight, IR and UV I2C sensor can monitor sunlight intensity, IR intensity and UVfigure-7 intensity.  All in one sensor. The sensor is a multi-channel digital light sensor, which has the ability to detect UV-light, visible light and infrared light.

This device is based on SI1145, a new sensor from SiLabs. The Si1145 is a low-power, reflectance-based, infrared proximity, UV index and ambient light sensor with I2C digital interface and programmable-event interrupt output. This device offers excellent performance under a wide dynamic range and a variety of light sources including direct sunlight.

It measures total visible light (in Lumens), infrared light (in Lumens) and UV  (UV index).

You can download the SI1145 Specification here.

What are Lumens?

The lumen (symbol: lm) is the SI derived unit of luminous flux, a measure of the total “amount” of visible light emitted by a source. Luminous flux differs from power (radiant flux) in that luminous flux measurements reflect the varying sensitivity of the human eye to different wavelengths of light, while radiant flux measurements indicate the total power of all electromagnetic waves emitted, independent of the eye’s ability to perceive it. Lumens are related to lux in that one lux is one lumen per square meter.

  • For some examples:
  • Dark night: 0.001—0.02
  • Moonlight night: 0.02—0.3
  • Cloudy day indoor: 5—50
  • Cloudy day outdoor: 50—500
  • Sunny day indoor: 100—1000
  • Suitable for reading: 500—600
  • home video camera: 1400

figure-8

[callout size=”col-12″ last_column=”true” title=”SwitchDoc Note” description=”If you want to put your IOT device in a box and put it outside, since the sensor is not waterproof you will probably want to stick in a window that will let the light shine through to the sensor.   However, remember most plastics and glass are basically impervious to UV radiation (that’s why your Photogray sun glasses don’t work well in a car) so you need to use a special plastic  or what I prefer, Silica Quartz.   These Quartz windows will let the UV through.”  flip_left_edge=”false” flip_right_edge=”true”]

 

Grove LED

figure-9This is a very simple Grove board.   It turns the LED on when the digital input is high and off when the input is low.  It connects to a Digital Grove connector.   There is a potentiometer on the board if you want to adjust the brightness of the LED.

 

Coming in Part 2

Part 2 will go through the assembly of SunIOT and go through the Python software for the Raspberry Pi.  And then some results!

 

 

6 Comments

    • Yes, all but the Raspberry Pi:

      The parts list for the SunIOT project is follows.

      – Raspberry Pi 3 (Many Sources)
      – Pi2Grover store.switchdoc.com or https://amzn.to/2dWQrR2
      – Grove Sunlight Visible/UV/IR Sensor – SI1145 store.switchdoc.com
      – Grove LED store.switchdoc.com

  1. I purchased the hardware for SunIOT, followed the directions in Jan/Fed issue of raspberry pi Geek, and tried running simpletest.py. Unfortunately it crashed complaining it could not find a module Adafruit_PureIO. It took me some time to figure I had to “sudo pip install Adafruit_PureIO” Once it installed all ran perfectly. Too bad this step was omitted from the article. Hope this helps any other newbee’s. Thank you for the great coding and hardware!!

    • Ack! Thank you for finding that. We have updated the README.md on the SunIOT repository on GitHub.

      Not much we can do for the article!

      Best,SDL

  2. I am wondering how far a sensor could be used from the Raspberry Pi Server. The cables supplied to connect Grove products are usually no more than several inches long. Can they be extended to 4 feet or more??

    • The Sunlight sensor is on an I2C bus, so the limits of how far the cable can go is related to how far you can go with I2C, rather than strictly Grove. The I2C bus has a spec of maximum net bus capacitance of 400pF.

      This should be OK for around 400cm or so. 50cm is no problem. You could measure the capacitance on a 50cm cable and then figure it out. Remember everything else on the I2C bus counts too. You can use our 4 Channel I2C bus Multiplexer to fix that problem (and if you want more than one I2C device with the same address).

      CAT5 cable can’t be higher than 52pf/m, or it isn’t CAT5.

      100m of 52pf cable has a capacitance of 5200pf, so about 8m with a standard CAT5 cable.

      To go longer distances, you need to improve the buffers. The NXP’s P82B96 could be used to change the voltage levels on the bus, allowing much longer distances.

      The datasheet contains examples for I2C cable lengths of 3m, 25m, 100m and 250m.

      Best,
      SDL

Comments are closed.