Archive for the ‘Arduino’ Category

Wi-Fi Camera Trap

Project source code at GitHub: wifi-camera-trap

We have lots of small wildlife around our house (mostly rabbits this year) and since I have a small camera module and a cheap PIR (passive infrared) motion sensor, I thought it would be fun to make a motion triggered wi-fi camera to deploy somewhere near the house.

Wi-Fi Camera Trap

The project is quite simple. If the PIR sensor is triggered, software on an ESP8266 wi-fi microcontroller captures an image using the ArduCAM camera module and uploads it to an image server. I wrote a very simple Node.js server that saves the uploaded images and makes them available on a gallery page for easy viewing. Nothing fancy.

Here are some of the great images we captured. The bunny’s movement triggered the PIR sensor with no problem!

Bunnies over Wi-Fi

Inside the enclosure is an IoT Experimenter board that I designed to help me with my IoT projects. You can read more about it here. It has an ESP8266 wi-fi chip and connector for an ArduCAM module. I’m powering the whole device from a 5V battery pack. The IoT Experimenter is designed for input of 9V, but the onboard 5V regulator drops the 5V input down to about 4V, which is still fine for the camera module and PIR sensor in this project.

You can use any ESP8266 board you have. The camera connects to both the I2C and SPI pins, and the PIR sensor is connected to “Arduino pin 3” which is the RX pin on the ESP8266 but you can move it to any pin.

Wi-Fi Camera Trap – inside

Here’s what it looks like outside of the enclosure:

Wi-Fi Camera Trap Hardware

Here’s a closeup of the sensor. These are super cheap on AliExpress or Ebay. The output pin goes HIGH when there is new movement detected.

Cheap PIR Sensor


I prefer to program ESP8266 chips using Arduino so I can take advantage of the hundreds of useful Arduino libraries. There’s plenty of information about using Arduino code on the ESP8266 here. This project uses the ArduCAM library control the camera module.

I’m also using the excellent WiFiManager library to make it easier to connect the ESP8266 to a network. Instead of hardcoding the SSID and password in code, if the chip can’t connect to any networks it already knows about, the WiFiManager will set up an access point (AP) named “CameraTrap”. Use your computer or phone to connect to the CameraTrap access point and a captive portal page will prompt you for your network name and password. If you aren’t automatically shown the captive portal page, just navigate to and it will load.

After the CameraTrap code captures an image, it needs to upload it somewhere. I’ve provided a simple Node.js server for this purpose. The code POSTs the image to /upload on the image server which writes it to disk. You will have to specify the server hostname in the CameraTrap code. Note that the camera is actually installed upside down in the enclosure (so the wires fit) so my server rotates the image 180 degrees when it saves it to disk. On any machine where you can run a node server, type

npm install
node app.js

The server will run on port 8000. In any browser, just navigate to


to see the images. (Make sure you don’t accidentally include a trailing slash in the URL.)

All the software is available in the wifi-camera-trap GitHub repository. The Arduino code is in the CameraTrap directory, and the Node.js image server is in the imageserver directory.

Published by Michael, on September 9th, 2017 at 8:09 am. Filed under: Arduino,ESP8266,IoT. | 2 Comments |

Introducing the IoT Experimenter ESP8266 Development Board

Like many other hardware hackers, I fell in love with the ESP8266 Wi-Fi microcontroller as soon as I started using it. It is fast, has plenty of memory, has Wi-Fi networking, and can be programmed in a number of ways. Lots of people like the Lua firmware, but I prefer to use the ESP8266 core for Arduino because I can use all the great libraries already built for Arduino.

I’m also working with LoRa radio technology. Several small Arduino-based boards are available for experimenting with LoRa: Moteino and Anarduino MiniWireless have LoRa capable boards that are easy to use. They both have the standard 6-pin serial connection for easy programming. What I really wanted to do is combine long range radio technology with Wi-Fi connectivity, so I designed an ESP8266 Development board that allows for easy connection of a LoRa radio module. While I was at it, I also included connectivity for an OLED display, ArduCAM camera module, and included a nice big PL9823 RGB LED that can be controlled just like WS2812 LEDs.

IoT Experimenter ESP8266 development board

There’s also connection for analog input with a voltage divider to scale voltage down to the 1V ranged required by the ESP8266. The board has 2 voltage regulators: a 3.3V one for the ESP8266, and a 5V regulator for powering the RGB LED and to provide power to the radio module header. If you are wondering how I drive a 5V LED with 3.3V logic from the ESP, a diode in line with the LED’s power supply drops the VCC low enough for 3.3V logic to work reliably. I learned that clever trick from this Hackaday article. If you want to connect a strip of WS2812 LEDs, there are pads for that, too.

The TX/RX serial lines for the radio module and ESP8266 are connected together for simple serial communication. This makes it easy to build a simple radio to Internet gateway. See my project Solar-Powered LoRa Weather Station for a good example of this approach. Also, this header can be used for any kind of radio (not just LoRa) that has a 6-pin header with the standard FTDI pinout. In fact, it doesn’t have to be a radio at all! Communication with any serial device might be just what you need.

Radio module attached to IoT Experimenter

The ArduCAM camera module for Arduino works great with the ESP8266 (here is the library) so I can make surveillance cameras with this board. The 8-pin female header for the camera is on the underside of the board and the camera fits great right on top of the board.

ArduCAM module attached to IoT Experimenter

I also love those cheap I2C OLED displays. They come in several colors and are only a few dollars. So I added a header for that also. It’s great for debugging, and when you are done, just pull the display off.

OLED display attached to IoT Experimenter

The PL9823 RGB LED can be controlled using any WS2812 library, like the Adafruit NeoPixel library. This big 8mm LED looks great. Make it any color you want!


This board has proven really useful for me in several projects, and I’m probably going to offer it as a product. Hope you like it, and if you are interested, let me know.

Published by Michael, on September 3rd, 2017 at 8:42 am. Filed under: Arduino,ESP8266,IoT,LoRa. | 2 Comments |

Individually Addressable Incandescent Lamps

Everyone playing with electronics these days knows about LED strips made of dozens or hundreds of individually addressable RGB LEDs. I love them and make great use of them in the nootropic design Lumazoid music visualizer. But what about incandescent lamps? Old-school light bulbs with a filament have a soft warm glow that you just can’t get from LEDs. Wouldn’t it be great to be able to control a bunch of lamps individually by setting their brightness in code on a microcontroller? This is just what I set out to do recently, and the results are great.

Individually addressable lamp module

Individually addressable lamp module

How it works

I simply used the same technology as LED strips to allow communication between lamp modules. LED strips have RGB LEDs with an embedded driver chip which uses PWM (pulse width modulation) to control the duty cycle on the red, green, and blue LEDs. This combined LED/chip is called WS2812 or WS2812B. On older LED strips, the driver chip was not embedded into the LED itself, but was a separate chip called WS2811. These standalone driver chips are somewhat obsolete now which means they are cheap! I got 50 of them on eBay for $5.00. Since these modules use the same technology as LED strips, the same code can be used. Adafruit’s NeoPixel library is a very simple way to control LEDs, so we can control each lamp easily. The lamp is controlled by the “blue” pin on the WS2811 so that is the value to set.

byte brightness = 128;
lamps.setPixelColor(lampNum, pixels.Color(0, 0, brightness));


The driver chip cannot sink enough current to control a lamp directly, so I connected one of the LED output pins (the pin designated for blue) to a P-channel MOSFET. The PWM output from the WS2811 pin controls the MOSFET gate and the MOSFET then controls the current flowing to the lamp. I tried several MOSFETs to find one that worked best for a 5V source and allowed good control at very low PWM duty cycle. The FQP27P06 MOSFET allows the lamp filament to glow at an almost imperceptible level at a PWM duty cycle of 1/255. Since a lamp filament takes a bit of time to turn on/off, there is no flicker at low duty cycles. Nice!


Notice that the module has a big 1500uF capacitor. This is because the PWM creates a lot of ripple in the power line that needs to be smoothed out. At first I did not experience this when using only one WS2811/MOSFET/lamp in the circuit, but as soon as I added more there was lots of flickering caused by power line noise. A big fat cap solved that.

Lamp bulbs and sockets

The board is designed to allow the lamp socket to be mounted on the top or the bottom. That’s why there are 2 lamps in the schematic. There are also solder pads with holes to allow wires to be attached if I don’t want the lamp directly on the board. I used E10 miniature sockets from eBay and #27 bulbs with an E10 miniature base. These are 5V bulbs that draw up to 300mA. These can be bought at Mouser (part number 560-27). Or you can get them and lots of other bulbs from Bulb Town. Who knows more about bulbs than Bulb Town? Nobody, that’s who.


If you are using lots of them at full brightness, you’ll need a beefy power supply. I have 20 lamp modules strung together and power it with a 10A supply. If I try to set all 20 lamps to full brightness at the same time, the lamps at the end of the string are dim because of the resistance in the power wires, so my Arduino driver programs need to account for this. Also, a lamp filament doesn’t turn on/off immediately like an LED, so I also had to take this in consideration in my programs. This slowness in the on/off actually smooths out the illumination so there is no flicker, even at very low duty cycles.


I’m really happy with how this all turned out. I’m not planning on offering these modules as a product because I think the minimum price would need to be about $7 each, which I’m not sure people would want to pay. If you really think I should offer these or are interested, please let me know.

Published by Michael, on May 21st, 2016 at 1:25 pm. Filed under: Arduino,Art. | 5 Comments |

Frequency Filtering with the Audio Hacker Shield

The Audio Hacker shield for Arduino lets you do some cool things with digital signal processing. This new project shows how a fairly simple Arduino sketch can implement a low-pass filter, high-pass filter and band-pass filter.

A low-pass filter allows low frequencies to pass through (makes sense, right?) while attenuating or cutting out the frequencies that are higher than a specified cutoff frequency.

A high-pass filter is the opposite. It lets high frequencies through while attenuating frequencies below the cutoff frequency.

A band-pass filter lets frequencies that are near the cutoff frequency to pass through but attenuates the frequencies above and below it.

There is a new example sketch included in the Audio Hacker library called “Filter” that implements these 3 filters. In the video below I’m using the DJ Shield to make it easy to provide inputs but it is not strictly required. An audio source is plugged into the Audio Hacker input. A pot connected to A0 controls the cutoff frequency. A button on digital pin 5 starts/stops the audio processing, and a button on digital pin 4 controls the filter selection. I’m lighting up the red LED for low-pass filter, blue LED for high-pass filter, and both LEDs for band-pass filter.

Now shown in the video is the effect of the filter resonance. The pot conntected to A1 controls the resonance of the filter. Resonance amplifies the frequencies around the cutoff frequency, and has an especially cool effect when using a low-pass filter.

The resonant filter implemented here is adapted from the code here. I hope this simple project lets you hear how different filters sound and gives you something new to explore with your Audio Hacker shield!

Published by Michael, on September 22nd, 2015 at 6:55 am. Filed under: Arduino,Audio. | 5 Comments |