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

Will post a tutorial shortly for monitoring battery voltage.

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.

Monday, March 16, 2015

SD Card Datalogging with the DHT22 Temp Humidity Sensor

We were asked to do a tutorial explaining how to do logging with the DHT22 Temperature Humidity Sensor. This is a little tricky, as the sensor outputs floats, and we send strings to the SD card, I've put together a float to string feature to help with this. Please see our previous tutorials on how to connect the DHT22, and how to connect a SD card module. If you are able to get that to run, then you are ready for this tutorial.

Use checkout code "steveics", and get a 15% discount on the sensors!

Code: steveics Discount Amount: 15% Max Use: 1 No Min Order Started Date: 16th Mar, 2015 Ended Date: 16th May, 2015

Here is the sketch for the logging feature. It reads the DHT22, converts the floats to strings, and writes the comma delimited data to the SD card. Video is below!


#include<stdlib.h>

#include "DHT.h"

#define DHTPIN 7     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);


#include <SPI.h>
#include <SD.h>

const int chipSelect = 10;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
  
  Serial.println("DHTxx test!");
 
  dht.begin();
}

void loop()
{
  
    // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);
  
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index
  // Must send in temp in Fahrenheit!
  float hi = dht.computeHeatIndex(f, h);

  Serial.print("Humidity: "); 
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: "); 
  Serial.print(f);
  Serial.println(" *F\t");

  
  
  
  // make a string for assembling the data to log:
  String dataString = "";



char buffer[10];  
String stringH = dtostrf(h,6,2,buffer);  
dataString = stringH;
dataString += ",";
String stringF = dtostrf(f,6,2,buffer); 
dataString += stringF;

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
}