Monday, May 4, 2015

Remote Control Mood Lamp

I love RGB LED's. One little module can produce a wide spectrum of colors just by varying the signal on the red, green and blue pins. I also love my TV remote, as I am a bit of a couch potato. What if I could change the mood of the room, with my TV remote?

I took an arduino, connected a RGB LED module that has the three dropping resistors on board, and connected a InfraRed (IR) receiver out of an old VCR. Radio shack sells these for about 80 cents. You could use three separate LED's and 220 Ohm resistors, but the effect would not be the same. You could also get a RGB LED, and add the three resistors to it.

I went a step further, and connected a LED to the output of the receiver chip so I would get a visual confirmation that the receiver saw a signal from the remote. That part isn't necessary, so I left it off the schematic. If you want to implement, connect a 220 ohm resistor to the IR module signal pin. Connect the other end of the resistor to the short leg of an LED (color is your choice). Connect the long end of the LED to Arduino +5. The receiver outputs a LOW when it sees a IR signal.


I cut a small hole in a ping pong ball and placed it over the RGB LED (tape holds the module in place) to diffuse the light and make the whole ball glow with color.

I'm not detecting actual codes, just an IR signal, so this project will work with any remote you have laying around, and any button on the remote. It just cycles to the next color.

All 3 LED pins are connected to PWM pins, so you can add additional case statements, and change the pwm values with analogWrite to the pins, to create new and additional colors.

Code:


int ledcolor = 0;
int red = 9; //this sets the red led pin
int green = 10; //this sets the green led pin
int blue = 11; //this sets the blue led pin

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}

void loop() {
  if (ledcolor > 6){
    ledcolor=0;
  }
  // put your main code here, to run repeatedly:
bool triggered = digitalRead(12);
if (triggered == LOW){

switch (ledcolor) {
case 0: //if ledcolor equals 0 then the led will turn red
digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
analogWrite(red, 204);

break;
case 1: //if ledcolor equals 1 then the led will turn green
digitalWrite(red, LOW);
digitalWrite(green, HIGH);

break;
case 2: //if ledcolor equals 2 then the led will turn blue
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);

break;
case 3: //if ledcolor equals 3 then the led will turn yellow
digitalWrite(blue, LOW);
analogWrite(red, 160);
digitalWrite(green, HIGH);
//delay(a);

break;
case 4: //if ledcolor equals 4 then the led will turn cyan
digitalWrite(red, LOW);
digitalWrite(green, LOW);
analogWrite(red, 168);
digitalWrite(blue, HIGH);

break;
case 5: //if ledcolor equals 5 then the led will turn magenta
digitalWrite(red, LOW);
digitalWrite(blue, LOW);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);

break;
case 6: //if ledcolor equals 6 then the led will turn white
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
analogWrite(red, 100);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);

break;
}
  ++ledcolor;
  delay(200);
}
}



Saturday, April 25, 2015

Arduino UPS / Battery Shield

We just picked up a LIPO shield from Adafruit, which allows us to battery power our projects.

The shield contains a optional 2Ah LIPO battery, and recharges from a mini usb cable (same as a Kindle).

You can power your project from the shield on battery power, or plug in the cable, and it charges the battery and acts like a online UPS, powering your project. LED's show power on, charging, charged, and low battery status, and you can monitor battery voltage on one of your analog pins.

All we had to install was the extended headers, and the optional power switch (finally, you can power off the arduino). Stack the shield, plug in the battery and a usb cable for charging when necessary, and you are set to go.

Take it solar with http://tinyurl.com/kjlupbg

We used a Ada Fruit RGB I2C LCD Shield
Make sure you download the Adafruit Libraries for the LCD.

// set up the voltage monitor
// select the input pin for the battery voltage. 
//Make sure you solder the correct pad on the bottom 
//of the power boost shield.
int sensorPin = A2;    
// variable to store the value coming from the battery
int sensorValue = 0;  

//measure your AREF pin and replace our 
//measured value of 4.77v
float stepVolt = 4.77/1024.0; 

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can't use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7



void setup() {
  // Debugging output
  //Serial.begin(9600);
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  lcd.setBacklight(YELLOW);
  lcd.setCursor(0,0);
  lcd.print("Battery Voltage");
}


void loop() {
 sensorValue = analogRead(sensorPin); 
 lcd.setCursor(0,1);
 lcd.print(sensorValue*stepVolt);
 delay(5000);
}



Wednesday, April 22, 2015

Earth Day - Have your lights turn off when you leave the room!

We wanted to save energy, and create convenience, by adding motion sensors to our lighting circuits. Maybe you want some notification of an intruder. Both can be done with a PIR Motion sensor.  When I walk into a room, the lights come on automatically, and when I leave, shut off after a short period of time. You can choose how long that time delay is in the code. No more fumbling for a light switch in the dark with my arms full of groceries!

http://www.instructables.com/id/DIY-Arduino-Motion-Sensor-Lighting-Control/

Monday, April 20, 2015

Solar & Wind Data Logger Video

This data logger monitors a solar or wind off -grid power system. A current shunt and voltage divider monitors the voltage and current of the system. This data is displayed on the LCD and written to the SD card along with time / date stamping from the real time clock module. A Screw prototyping shield enables easy access to pins for connecting additional sensors like temperature, humidity, barometric pressure, wind speed and direction and rain gauges. Additional information including the web based charting and graphing module is available at http://www.green-trust.org/jmc/



Saturday, April 11, 2015

Arduino LM35 Temperature Sensor

One of the least expensive and simplest ways to measure temperature is with a LM35. This is another component found in our SainSmart kit. This transistor looking device has 3 pins, 5v, Signal out, and Gnd. The signal is an analog voltage that connects directly to a Arduino analog input. In this example we will use A0.

Now the LM35 outputs 0-1v for it's range of -55C to 150C. Since the Arduino defaults to a 5v reference for analog to digital conversion, we are losing 80% of the sensors range, so we are switching to the internal reference which is 1.1v. This is a better match for this sensor. We are also doing a Celsius to Fahrenheit conversion in the code.

With the pins down, and the flat face of the sensor facing you, the pins, from left to right are:

V- S - G

Where V connects to +5, S connects to A0, and G connects to ground. The data sheet can be found at http://www.ti.com/lit/ds/symlink/lm35.pdf

The code looks like this:

float tempC;
float tempF;
int reading;
int tempPin = 0;

void setup() {
  // put your setup code here, to run once:
  analogReference(INTERNAL); //changing from a 5v reference to a 1.1v reference
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  reading = analogRead(tempPin);
  tempC = reading / 9.31;
  //Serial.print(tempC);
  tempF=tempC * 9/5 + 32;
  Serial.println(tempF);
  delay(5000);
}

Arduino Relay Control

Previously I have blogged about using relays with an Arduino, and SainSmart relays specifically. A while back I received a 4 relay, and a 8 relay board, and both of them used negative logic, i.e. a LOW activated them, and a HIGH deactivated them. Yesterday I received a single relay module as part of a kit, and found that this module uses positive logic, i.e. a High activates it, and a LOW deactivates it.

Being a 5v relay, it's able to be driven directly from the arduino power. If you have a lot of additional hardware, you may want to consider a separate 5v supply, and common ground.

We are printing the relay state to the serial monitor, but the LED on the relay board also signifies whether it's active or not.

Only 3 pins are used, 5v ("V"), Gnd ("G"), and a data pin. We are using pin 7 in this example, and connects to the relay "S" (signal) pin.

Here is my test code:

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(7, OUTPUT); //don't forget to declare the pin as output!
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(7, HIGH);
Serial.println("Active");
delay(5000);
digitalWrite(7, LOW);
Serial.println("Inactive");
delay(5000);

}

Tuesday, April 7, 2015

Adafruit RGB I2C LCD Keypad Shield

This project is a bit more complicated than some we have done recently. Adafruit makes a very nice LCD Keypad Shield, that unlike most of the others, has a 2 wire I2C interface (covers the lcd and the keypad), and a multi-color RGB backlight. This frees up 7 I/O pins over the typical LCD Keypad Shield. It comes in a kit, and all the components need to be soldered on the board. Fortunately Adafruit provides a very comprehensive tutorial that is easy to understand.


Monday, April 6, 2015

Adafruit RTC / SD Data Logger

Many of our projects require logging the sensor data to a sd card, and some of those projects require a time / date stamp. We used to use discrete modules to do this, but Adafruit has a very nice Proto shield with a real time clock and a sd module on board. As you can see, this takes a regular size sd card, or a micro sd in a conversion carrier. At under $20, this is a cost effective replacement for discrete RTC and SD modules, and a proto shield. It does not come with extended headers, so it either has to be the top shield in a stack, or get a pack of extended headers and solder those on instead of the normal headers included (but not installed). We have several projects coming up using this shield, so stay tuned.


Will the Real Arduino, Please Stand Up?

For years we have been receiving these wonderful blue Arduino boards with Arduino.cc printed on the back.

Imagine my surprise, when this time, it's a green (teal) board and says ARDUINO.ORG on the back. Not only that, but it comes up with warning's it's an UNCERTIFIED board when you use it.

Yes, it's a knock-down drag-out fight between two founders of Arduino, one in charge of manufacturing, the other in charge of software development, and both trying to keep the community in their pocket by claiming they are the real Arduino. Who wins? I don't know, but the real losers could be the hundreds of thousands of enthusiasts using these products. Stop fighting, kids, or I'm calling the Super Nanny!


Proto Screw Shields - Continued

Last week I built a Proto Screw Shield from Sparkfun. Although it's a very nice piece, and easily assembled, I received one from Adafruit today that I believe to be a bit better. First of all, It's REV 3 compliant, which the Sparkfun piece was not. Second, it also came with the pass through extended headers for the traditional ICSP block. Construction time and ease was essentially identical. Sparkfun still has the better shipping rates, so if you order from Adafruit, you better have a large order. I get charged $15 S&H for a $3 transistor or $100 worth of boards.


Thursday, April 2, 2015

Arduino IDE Improvements

Big things are happening! Sceptical? Download the latest Arduino IDE, and go to Sketch - Include Library - Manage Libraries
The new IDE is much more responsive as well!

Hot on the heels of Arduino’s 1.6.2 IDE release for Arduino Day over the weekend, you can now access all of Adafruit’s Arduino libraries from within the new IDE’s library manager!  To access the libraries you’ll need to use the brand new 1.6.2 version of Arduino’s IDE and simply access the Sketch -> Include Library -> Manage Libraries… menu to open the library manager.  Filter to different topics like sensors, displays, etc. or search by name to find libraries and install them with the click of a button.  You can also learn more from this handy guide to using the new library manager too.  There are over 100 Arduino libraries from Adafruit that are now available in the library manager!


https://blog.adafruit.com/2015/04/01/adafruit-arduino-libraries-now-available-inside-arduino-1-6-2-ide

Monday, March 30, 2015

Wind & Solar Datalogger

We are rolling out our newest Wind & Solar Power Datalogger. A shunt between the battery and the power sources (wind turbines, solar panels, microhydro, your cousin on the exercycle), tell us the current being generated, and a voltage divider reads the voltage of the battery pack. From that we can calculate the watts being produced. With our SD Card and RTC Module, we can calculate amp hours and watt hours, and save them to a sd card. A second shunt between the battery and the loads will also tell us our power consumption, and then we can calculate the approximate level of juice left in the battery. We have also designed a website where you can upload the contents of your SD card, and track your production (and consumption) over time. Although this was designed for those without internet access at the monitoring site, if you do have internet access, we offer real time data uploads.

Additional sensors track weather related data like temperature, humidity, heat index, dew point, wind chill, wind speed and direction, rainfall, UV Index, Radiation and more. Kits and documentation will be available soon.


Cost is $199 delivered in the US. Includes Programmed arduino, LCD screen, SD card and module, real time clock, Screw Shield, and current shunt. Also includes web interface and data storage for archiving, searching data, and graphing.

Email me at greentrust@gmail.com so we can discuss your particular needs and application.

More pictures and a full list of available sensors at http://www.green-trust.org/wordpress/2015/03/30/wind-solar-power-datalogger/

Saturday, March 28, 2015

Sparkfun Proto Screw Shield

Today I got a package from Sparkfun that included a Raspberry Pi 2, a couple of MOSFETS, some right angled breakaway headers, and a Proto Screw Shield kit. This shield makes it very easy to connect sensors to the Arduino, and still be able to stack additional shields on top of this one. There is quite a bit of room to put additional components on this board as well. The kit has to be assembled, which takes about 15 minutes, and is easy to do. There is a good tutorial for this at https://www.sparkfun.com/tutorials/266


The above shows a SainSmart LCD Keypad shield stacked on the Sparkfun Proto Screw Shield, stacked on a SainSmart Uno. All the UNO pins (rev 2 and earlier) are exposed.

Wifi with the WizFi210 module

I'm playing with a new wifi module today from WizNet, the WizFi210. I have mine mounted on a test board that has 9 pin rs-232, usb, and TTL Serial interfaces. There is an Arduino shield available as well. This is a inexpensive wifi board that can be used for many applications, from smart appliances to wireless sensor monitoring. For ease of testing and prototyping, the test board or the shield are a necessity.

The wifi module itself is the square board on the right end of the test board, covered in metal, with the antenna attached. There is a version with on board chip antenna as well. I'll be documenting the setup and Arduino sketches necessary for communicating with this device, as well as it's applicability to working with a Raspberry Pi. Stay tuned!

Arduino Library

  • Single band 2.4GHz IEEE802.11b Wi-Fi module
  • Host Interface : UART & SPI
  • Quick booting time : under 20msec
  • Ultra low power through dynamic power management (34μA at the standby mode)
  • Security protocols : WEP, WPA/WPA2-PSK, Enterprise (EAP-FAST, EAP-TLS, EAP-TTLS, PEAP)
  • Operation temperature : -40 ~ 85
  • CE, FCC, KCC, TELEC certified
  • Dimension : 32 x 23.5 x 2.9(mm)
  • Provides chip antenna mounted version

Wednesday, March 25, 2015

The Arduino APRS Journey

We are investigating adding APRS abilities to our DIY Weather Stations. Automatic Packet Reporting System (APRS) is an amateur radio-based system for real time tactical digital communications of information of immediate value in the local area. In addition, all such data are ingested into the APRS Internet System (APRS-IS) and distributed globally for ubiquitous and immediate access. Along with messages, alerts, announcements, and bulletins, the most visible aspect of APRS is its map display. Anyone may place any object or information on his or her map, and it is distributed to all maps of all users in the local RF network or monitoring the area via the Internet. Any station, radio, or object that has an attached GPS is automatically tracked. Other prominent map features are weather stations, alerts and objects and other map-related amateur radio volunteer activities including Search and Rescue and signal direction finding.

Our friend Stanley has already been down this path, and reported on the various available options already out there, and why he went with his own open source solution. Good work Stanley! - http://9w2svt.blogspot.com/2014/07/building-open-source-arduino-aprs.html

We will be building upon his excellent foundation for our work. Thank you to Bob Bruninga (WB4APR) for developing this technology.

The new Lightning Sensor project has been finished. We now report Temperature, Humidity, calculate Heat Index and Dew Point, UV Index, Distance to Lightning strikes, and very soon radiation levels. Wind Speed / Direction (with wind chill) and rainfall amounts are coming online soon. Everything you need for your off grid weather station. Contact us if you are interested in building your own weather station, or want an assembled unit.