Simple IOT Sunlight Sensing Raspberry Pi Project – SunIOT Part 1
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).
- – Part 1 – Introduction to SunIOT
- – Part 2 – The SunIOT Hardware and Software
- – Part 3 – Hooking up SunIOT to initialstate.com
- – Part 4 – Hooking up SunIOT with MQTT to freeboard.io and pubhub.com
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.
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
What are Grove Connectors
Grove is a modular, standardized connecter prototyping system. Grove takes a building block approach to assembling electronics. Compared 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
The 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 GroveWeatherPi Solar powered weather station).
The Pi2Grover board provides buffered connections and voltage translation between the Raspberry Pi pins and external Grove modules. 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.
Grove Sunlight Sensor – SI1145
The Grove Sunlight, IR and UV I2C sensor can monitor sunlight intensity, IR intensity and UV 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
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.
This 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!
Looking For A Specific Topic?
Recent Blog Posts
- Guest Blog – Smart Garden System 3D Printed Top for Sensors
- Tutorial – Part 4 – Experiments! Using an Analog to Digital Converter with your Raspberry Pi
- Tutorial – Part 3 – Using an Analog to Digital Converter with your Raspberry Pi
- Tutorial – Part 2 – Using an Analog to Digital Converter with your Raspberry Pi
- Tutorial – Using an Analog to Digital Converter with your Raspberry Pi