Measuring Light Intensity

Any camera buffs out there? Sometimes it is handy to be able to measure the amount of light at a particular spot. This is needed sometimes so you can adjust your camera to take the ‘perfect’ picture. Or perhaps you are calculating the amount of solar energy your solar panels will be producing given the amount of light available.

In any case, there  are a couple of components that are very useful for this, the TSL235R light to frequency converter and the BH1750 digital light sensor.

 

TSL235R

TSL235R

BH1750

BH1750

 

 

 

 

 

 

 

 

 

Here are both components on a DIY Arduino breadboard (click on the image to enlarge it):

Arduino LUX Meter

Arduino LUX Meter

Here is the Arduino sketch (code) to get the readings from these components. (Note: the code comments show how these components are wired.) Two libraries are need for this sketch (Wire and BH1750).  The BH1750 library can be downloaded here.  The Wire library is included in the standard Arduino IDE.

 

ESP8266 Wi-Fi Module

My children bought a present for me recently (yes, another birthday, I really am getting older 🙁 ). It is an ESP8266 Module which is a self-contained [IoT] Wi-Fi networking solution. Here are pictures (with the pins labelled):

 

ESP8266

ESP8266 Wifi Transceiver Module

 

 

 

 

 

 

 

 

 

My module comes from Elecrow.com. Since this module is rather new there is not much documentation nor sample code for it, however there is a WEB site dedicated to these devices here :  esp8266.com.

The SDK is here. The Cross-Compiler is here. A very handy ESP8266 ROM Bootloader utility is here.

The module I have takes 5 pins (3.3V, GND, TxD, RxD and CH_PD). The CH_PD pin on my module needs 3.3V. The default BAUD rate for my module is 115200. I connected to it using an FTDI cable and Minicom. (For 3.3V I used an Arduino Nano.)

Here is a good article on hooking it up similar to how I did it with links to new firmware, sample code, newer SDK and other tools.

I plan on eventually attaching mine to an Arduino and using it to send sensor data to a WEB site for data collection.

Since the ESP8266 is a serial device and the debugging ‘view’ to what is going on with it (USB to the Arduino)  is also using a serial connection (FTDI probably), two serial connections are needed. I probably should explain this (especially if you are new to using Arduinos). All Arduino boards have at least one serial port (also known as a UART or USART). The  serial port communicates using digital pins 0 (RX) and 1 (TX) as well as communicating with the computer via USB. So,  if you use USB to communicate with the Arduino, you cannot also use pins 0 and 1 for digital input or output and thus you need to another serial port to both communicate with the Arduino and the ESP8266.

One might be tempted to try the Arduino software serial library to connect to the ESP8266, however the software serial library is too slow to keep up. Two hardware serial connections are therefore needed. An Arduino Leonardo, Due or Mega 2560 have at  least two hardware serial interfaces and would work fine for this purpose.

DIY Dual Relay Circuit

It is sometimes very handy to be able to control mains electric via an arduino to turn things like lights on and off.  [warning]BE VERY CAREFUL hooking up any mains electricity. [/warning]

I built a dual circuit so that two things can be controlled from one board. Here is the fritzing graphic:

 

DIY Dual Relay CircuitOnce built, here is what it looks like:

Dual Relay Circuit TopDual Relay Circuit Back

Click on the above images to enlarge them and see the parts used.

Input (3 pins) comes from a simple arduino circuit (GND, 5V Power and another pin to control the relay state). A simple arduino sketch can toggle the relay off/on.

Here is the fritzing source so you can modify it yourself.

3 PIN HD44780 LCD

One of the problems of connecting an HD44780 LCD

HD44780 LCDto an arduino is the number of pins taken up (usually 6). There is an older article here for hooking up an HD44780 LCD to an arduino with only 3 pins.  (Note: There is an alternate link here as the original link may be down.)

The circuit uses the 74HC595 shift register IC.  I liked the idea and have built several of these circuits.

 

LCD_Shift_Register

 

LCD_Shift_register_1

 

 

 

 

 

Thus I have a handy way of attaching an LCD to arduino projects without taking too many pins.

 

You will need a library for controlling the LCD (attached via the 74HC595 shift register) which you can get here. (Updated:  here)  A sample sketch is shown below. It is the same one here from the original author but I modified it via:

to turn the backlight on. Here is the sketch:

 

DIY Arduino Circuit Board

Shown below is one of my DIY Arduino circuits.

DIY Arduino Circuit FrontDIY Arduino Circuit (Back View)

 

 

 

 

 

 

 

 

The circuit does not have the FTDI chip built in. The FTDI circuit is only needed for programming and cutting out un-necessary components saves a bit of money. The ICSP connection (6 pins comming out the side) on this circuit is perfectly connected to the SparkFun FTDI breakout board:

 

FTDI Breakout 5V

FTDI Breakout 5V

 

 

 

or an FTDI cable:

 

FTDI Cable

 

Here is the Fritzing graphic:

DIY Arduino Circuit Board

DIY Arduino Circuit Board

If you’d like to modify the Fritzing source, get it by clicking here.

Here is the parts list:

 

Quantity Description
 connecting wire
1 AVR Atmega328P
1 16Mh Crystal
2 22pf Capacitor
1 fiber protoboard
1 5mm Red LED
1 0.1 uf Capacitor
1 Base 28 Dip .3 inch
1 1/2 Watt 10K Ohm Resistor
1 1/2 Watt 220 Ohm Resistor
2 16 Pin Header Connector
1 6 Pin Connector 90 degrees

 

If you’d like to experiment on a breadboard before building (soldering) the circuit, here is the breadboard view:

Arduino on a BreadboardYou can  get the Fritzing source here if you’d like to modify it.

Servo Motors

A lot of people when first getting into Arduino projects seem to like robotics. It is fun to create something that you can watch move around. If you are interested in such things, you will be interested to learn about servo motors.

 

Pictured below is a Parallax Continuous Rotation Servo motor.

 

Parallax Servo Motor

Parallax Servo Motor

Click the above image or here to learn more about them and download the Arduino sketch to experiment with them.

AVR Raspberry Pi Programmer

There are a number of ways to program AVR microcontroller chips. For my DIY projects, I like to save money by buying components and putting them together to create what I need. I bought some blank ATMEGA 328P micro controllers so that I could make Arduino circuit boards for my projects. Building the Arduino circuit board myself rather than buying the completed Arduino saves money. Granted, it takes more time, but to me it is more satisfying to do it myself.

Since I have blank chips, they need the Arduino Bootloader programmed in. My favorite programmer for that purpose is a Raspberry Pi shown below.

Raspberry Pi Programmer

Raspberry Pi
Programmer

It uses a modified version of AVRDude especially for the Raspberry Pi. Instructions on how to get it and use it are here.

Here is how it is wired.

The astute observer will note that besides the 6 wires, I have a 16Mgz crystal  on the breadboard. If the chip is blank when it is being programmed this crystal is not needed, however there are times when I reprogram a chip. For those times, the crystal is needed because the fuses are set to use external clocking rather than the internal clock.

 

The BusPirate (a very useful circuit)

A few days ago my son bought me a birthday present. It was a BusPirate from SparkFun. This is what it looks like plugged into a breadboard.

BusPirate

BusPirate and Breadboard

The BusPirate is quite a handy circuit. I have used it to flash a BIOS chip using FLASHROM  and also program an AVR ATMEGA 328P with AVRDude.

It can even be used in the Arduino IDE as a programmer simply by adding a few lines:

in programmers.txt (found in the hardware directory).

The I/O header [breakout] looks like this:

BusPirate I/O Header

BusPirate I/O Header

The BusPirate has many uses, check out the possibilities here.

If you’d like to try some of the functions of the BusPirate on an Arduino, you might be interested in the Arduino Sketch called “MiniPirate“. You can find more information here.

PIR Sensor for your Arduino

A PIR  or Passive Infrared module is really fun to play with. This is what they look like:

 

Passive Infrared Sensor [front view]Passive Infrared Sensor [back view]

 

They are basically a motion detector and are called ‘passive’ in the sense that these devices do not generate any energy for detection purposes. They work entirely by detecting the energy given off by other objects in the infrared spectrum wavelengths. More information about infrared can be found here.

Here is how to hook it up:

 

PIR Fritzing Example

Get the Fritzing source for the above image here. Once you have it hooked up, head on over to the Arduino Playground and get the sketch to make it work.

I added a buzzer and it alerts me when anything (including the cat) sneaks up on me.

 

 

 

Wireless Bluetooth Module for your Arduino

If you’d like to wirelessly attach your Arduino to another device (such as a phone or tablet) via bluetooth, I’d recommend the serial bluetooth module from Elecrow.com.

Here is what they look like:

 

Serial Bluetooth Module

 

The module has firmware from BOLUTEK. The PDF document with all of the available BOLUTEK commands is BLK-MD-BC04-B_AT COMMANDS . I also document the AT commands in the sample source code (aduino sketch) below.

There was no sample code that I could find for using these with an Arduino so I wrote my own. The following sketch (load it into any arduino) sets up the module in slave mode so you can connect to it with any blue tooth enabled device. The PIN code is 232323 as you can see from the source.

 

Load more