Sunday, March 6, 2016

The Sodium Launcher Arduino/Xbee Sketch...

Simple stuff, but here it is:

//Single Servo Servo controlled by Xbee after receiving character commmand
*****************************************************************/
// We'll use SoftwareSerial to communicate with the XBee:
#include <SoftwareSerial.h>
#include <Servo.h>
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created


int pos = 0;

// XBee's DOUT (TX) is connected to pin 2 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 3 (Arduino's Software TX)
SoftwareSerial XBee(2, 3); // RX, TX



void setup()
{


  XBee.begin(9600);
  Serial.begin(9600);
  myservo.attach(9);

}

void loop()
{
  if (Serial.available())
  { // If data comes in from serial monitor, send it out to XBee
    XBee.write(Serial.read());
  }
  if (XBee.available())
  { // If data comes in from XBee, send it out to serial monitor
    Serial.write(XBee.read());
 
  }

while (Serial.available ()>0) {
    char incomingByte = Serial.read();
   Serial.println(incomingByte);
   if(incomingByte=='1'){
     for(pos = 90; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=90; pos-=1)     // goes from 180 degrees to 0 degrees
  {                              
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }

   }

}
}

Friday, March 4, 2016

sodium launcher with xbee's


Fun little project. Sodium blowup demonstration covers a lot of ground in chemistry: molarity, acid/base, logarithms,ph, periodic trends, stoichiometry. We work out the predicted ph of the bucket of water after the sodium reacts and makes sodium hydroxide. Thought it would be fun to put together a simple radio controlled sodium launcher with a pair of xbee's signalling a servo motor to drop the sodium - for safety, of course.







           Launcher.  Servo run by arduino receives command via xbee.

Friday, December 25, 2015

Arduino Ethernet Shield and Xbee

This summer I worked with the folks at the Chattanooga Public Library's 4th Floor Lab and we've now got a basic sketch that integrates the Arduino Ethernet Shield with XBee Communication.  I've searched high and low for someone to post an Arduino sketch that integrates them, but I haven't found one.  Well, if you too have been looking, here it is!  I used this some a few months ago to post some sensor data that was being logged several hundred feet away in the field and sent via XBee 1 to XBee 2 stacked with the Arduino Ethernet Shield.  There's plenty of html code changes you can add or change to make your 1990's-looking webpage better.  Hope it's useful!  Merry Christmas!

*/
#include <SPI.h>
#include <Ethernet.h>
#include <SoftwareSerial.h>


// XBee's DOUT (TX) is connected to pin 2 (Arduino's Software RX)


// XBee's DIN (RX) is connected to pin 3 (Arduino's Software TX)

SoftwareSerial XBee(2, 3); // RX, TXint ReadingNumber=0;

char link[]="wirelessearthwatchdawgs.blogspot.com"; //link data

// Enter a MAC address and IP address for your controller below.


// The IP address will be dependent on your local network:

byte mac[] = {

   0x90, 0xA2, 0xDA, 0x0D, 0xA8, 0x6B

};

IPAddress ip(192,168,1,120

);

//IPAddress ip(172, 16, 100, 120);


// Initialize the Ethernet server library


// with the IP address and port you want to use


// (port 80 is default for HTTP):

EthernetServer server(8081);


void setup() {

  // Open serial communications and wait for port to open:

  Serial.begin(1200);

   XBee.begin(1200);

  while (!Serial) {

    ; // wait for serial port to connect. Needed for Leonardo only

  }

  // start the Ethernet connection and the server:

  Ethernet.begin(mac, ip);

  server.begin();

  Serial.print("server is at ");

  Serial.println(Ethernet.localIP());

}

void loop() {


  // listen for incoming clients

  EthernetClient client = server.available();

  if (client) {

    Serial.println("new client");

    // an http request ends with a blank line

    boolean currentLineIsBlank = true;

    while (client.connected()) {

      if (client.available()) {

        char c = client.read();

        Serial.write(c);

        // if you've gotten to the end of the line (received a newline

        // character) and the line is blank, the http request has ended,

        // so you can send a reply

        if (c == '\n' && currentLineIsBlank) {

          // send a standard http response header

          client.println("HTTP/1.1 200 OK");

          client.println("Content-Type: text/html");

          client.println("Connection: close");  // the connection will be closed after completion of the response

          client.println("Refresh: 5");  // refresh the page automatically every 5 sec

          client.println();

          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println();

          //set background to yellow

          client.print("<body style=background-color:yellow>");

          //send first heading

          client.println("<font color='red'><h1>My Web Title</font></h1>");

          client.println("<hr />");

          client.println("<hr />");

          //output some sample data to browser

          client.println("<font color='blue' size='5'>Sample data:w/m2");


          // output the value of each analog input pin

          boolean xbeenewline = false; // initialize boolean variable to keep track if a new line has been seen.

          while (xbeenewline == false) {          //when this is false; a new line hasn't been seen; 

            char c = XBee.read ();        // render it as characters, rather than as integers.

            if (c == '\n') {          // if c hits the ASCII symbol for new line

              xbeenewline = true;   // it's true that the server sees a new line from the xbee feed

              boolean newxbeenewline = false;  // initialize a variable that will serve as the recognition of the end of a line of data

              while (newxbeenewline == false) {  // keep reading data, we arent' at the end of the line yet

                char c = XBee.read();

                if (c == '\n') {            // but when we see the symbol for end of line

                  newxbeenewline = true;    // we're done reading data

                } else if (c != -1) {       // -1 is the value for nothing sent by xbee, so don't print it

                 

                  client.print(c);

                  delay (1);

                }

              }


                client.println ("<br/>");                                    //(“<br />”);

          client.println ("<hr/>");   

      

          client.println ("<font color='blue' size='5'>Link: ");         //(“<font color=’blue’ size=’5′>Link: “);

          client.print ("<a href=");            //(“<a href=”);

          client.print(link);

          client.println(  ">Visit our Project Site!</a>");          //(“>Visit Scienceprog!</a>”);

          client.println ("<br/>");                                    //(“<br />”);

          client.println ("<hr/>");                             //(“<hr />”);

            }

          }


          client.println("</html>");

          break;

        }

        if (c == '\n') {

          // you're starting a new line

          currentLineIsBlank = true;

        }

        else if (c != '\r') {

          // you've gotten a character on the current line

          currentLineIsBlank = false;

        }

      }

    }

    // give the web browser time to receive the data

    delay(1);

    // close the connection:

    client.stop();

    Serial.println("client disconnected");

  }

}


Friday, July 3, 2015

Getting those final test runs in

After a few days in the garbage pail simulation, I figured we'd get a realistic current usage for 24 hours with all the circuitry running.  We put a  Vernier current logger in line and took readings every  6 minutes.  Vernier has a good statistics function so I could get the total consumption over the day (the integral- for all you calculus folks).  Pretty much was as predicted ~.84 amps/day.  Definitely puts us comfortably in the zone for leaving the station for a month with a 42 amp-hour battery (50 days, in theory). .  There's enough room in the box to put two batteries in parallel for a seasonal duty cycle, but we'll hold off on that until this project proves it's mettle over a 30 day field test.




Wednesday, July 1, 2015

Water buoy-proof of concept phase

Testing it out in a municipal waste bin filled with water- water goes up and down with the rain and some occasional hose input.  Decided to put the steel pipe aside and go for schedule 80 PVC held with three pieces of rebar at 120 degrees separation each driven well into the creek bed.  I couldn't imagine doing this in anything bigger than very small tributaries with such a design, but that's what we're testing.  Looking to get it out in a few days.  Have a couple of ideas for securing the battery and for providing a bit of ventilation for the hydrogen gas that would emit.


Friday, January 30, 2015

Cutting Pipe for our Buoy Design

The idea is to have a dense foam cylinder inside a pipe in the stream that rises and falls with the stream level.  The pipe is vertical, and held by rebar, big rebar.  The probes will stick out of the cylinder while the cables go up into a sealed, watertight box where all the circuitry and battery are stored. I'll try to have a diagram out soon.  Pipe is expensive.





Monday, December 1, 2014

Francophone readers and commenters welcome

I've noticed that a fair number of blog guests are from the Francophone world, mostly France.  While I can't say that I'm an absolute master of the language (to say the least!), I d speak it fairly well and welcome any feedback or questions in the language.  Ce serait avec plaisir, mais veuillez m'excuser si mon ecriture est plein de fautes grammatiques. 

Check out my tutorials on Youtube

I've only got some rudimentary stuff up so far, but I do have a channel on Youtube where I post 5010 minute tutorials on various parts of our project.  So far, it's stuff that's covered pretty well already on other sites, but I have some fresh ones coming up soon that are more specific to the project and won't necessarily be found elsewhere, at least in the way that integrates Arduino with other things.  Upcoming videos include:  using MOSFET's to save power, hacking into the Sparkfun Vernier shield, and making a simple voltage regulator/charge controller for solar recharging of system batteries.

Wednesday, November 26, 2014

jeff's in town

Jeff Branson, the Gypsy Engineer from Sparkfun, has been evangelizing the masses with can-do spirit, sharp ideas, and mad skills. Here he his showing some kids how to use the new Sparkfun Data service for those of us who need a simple, effective, free place to post data.  This writer is already staying up late trying to run with some top-notch suggestions he has made.

In other news, I went to Walter Wood Hardware to pick up supplies for our first couple of buoys.

Happy Thanksgiving!

Wednesday, November 12, 2014

hangout with brian

Some of the crew did a video conference with Brian Huang of Sparkfun about using sleep functions to reduce power consumption in our projects. As usual, no matter the topic, Brian was on top of it.  The kids took down his suggestions.  He also gave some ideas on how to get the data coming over the Ethernet shield at the North Chickamauga site to graph, rather than just print some numbers on a blank IP address screen.
The key right now is to bypass the initialization "Press D12" part of the Vernier shield so that the probes take readings automatically once power has been restored to the shield following the sleep period (which would be most of the day).  If we're going to try to get by with using only a 20 ah battery in the buoy and come only once a month to check in for data harvesting and power check, we need to squeeze every milliamp we can.

Sunday, November 9, 2014

charge controller still doing well

I've had the N3904 transistor in place of the BC548 and it seems to be fine. I think we're about ready to box one of these into a monitoring station.

Friday, November 7, 2014

charge controller tests out well so far

We've been testing a 6v charge controller schematic with a small 10w solar panel that students of mine built last year and a small 3 amp hour battery with an arduino attached as a dummy load. 
Here's the breadboarded circuit with battery.
And here's the schematic:



Thanks of course to electroschematics.com.

The LM 317 is a standard adjustable voltage regulator.  Output is regulated with the variable resistor.  Most lead-acid 6v batteries have 6.8 v as a cutoff voltage.   The reverse-biased zener diode 2D starts conducting when load reaches float charge and sends excess voltage to ground.
We've heat sunk the LM 317.  A 1W rated resistor for R3 is too low.  It gets way too hot for this application.  We substituted a a ceramic 10W rated resistor and it stays cool. We'll give it a few more days, and if performance still checks out, we'll solder a permanent circuit.  Some of our remote monitoring sites get at least mottled sunlight for a few milliamps each day.

Saturday, October 25, 2014

circuit add-ons working well so far

We're experimenting with the FET switching and charge controller circuits that we mentioned in an earlier post.  So far, so good.

The FET switch, being pretty simple, does exactly what we thought it would do:  shut the "load" shields down.  Here's a link to the the particular setup we're using.

The charge controller we've only used for a couple of days.  I want to see how it holds up for at least a week before we commit to field use.

student skyping

Zack helping the Hixson kids with setting up the Ethernet shield.

Sunday, October 12, 2014

show at the creative discovery museaum

Several youngsters took time from their fall break to put on a demo/educational booth at the Creative Discovery museum.  They set up several stations showing kids some core programming structures.  We set up an air sensor (methane- which isn't going to report much) to an xbee so kids could walk around while the radio sent data back to a laptop.  Fun evening.




Saturday, October 11, 2014

Core structure: Using FET's to Control Power

As I mentioned in an earlier post, we're going to work in FET's  (mostly MOSFET's) to do some important stuff, notably to conserve power in remote locations and to regulate voltage.

For the former, a MOSFET can be used as a switch.  Below is a simple example I'll show the kids next wee: a motor powered by a separate power supply that is shut on an off by sending highs and low from an Arduino digital out pine to the gate of the MOSFET.  Signal high, MOSFET switches motor on. Signal low, motor is off.


·         The diode running parallel with the motor is sometimes called a flyback or kickback diode.  When current is shut off in a device that has a coil, like a motor or a relay, some of it will run backwards, which can possibly blow the MOSFET.  The diode routs that backwards current back to the motor, protecting the MOSFET.
·         The 10k resistor we see often in Arduino sketches.  It functions a  pulldown resistor.  It keeps the gate voltage at 0 if the Arduino output is low.  This avoids what is called a floating pin situation. We don’t want any stray voltage to the gate except when we signal it to be there with the digital out. 

a   And here's the generic code, setting the motor to go on and off at 5 second intervals. 
int motor=3;
void setup ()
{
  pinMode (motor, OUTPUT);
}
void loop ()
{
  digitalWrite (motor, HIGH);
 delay (5000);
  digitalWrite (motor, LOW);
  delay (5000);
}

If things work out, we can shut off the Vernier shield at much longer intervals, saving valuable milliamps along the way.  
      


Wednesday, October 8, 2014

burning in the mq 131

This ozone sensor takes a 48 hour burn in time.  I'm going to use the local air quality station to calibrate a value, courtesy of the AirNow site, which give you your local Air Quality Index, PM count, and ozone count in real time.


Saturday, October 4, 2014

the "Wireless" part of our program getting started

One of our team members Zack got an Arduino Ethernet Shield going-  just a bit of data going to an IP address- in this case, an air sensor that we were playing with .  One small step......

How to keep the power going on our remote stations

Certainly a problem.  You have some choices:  include a bigger battery, change out the battery more often, reduce power consumption, and provide extra power.  We've been tinkering with solar, since that's where I have a bit of background.  Starting to look at a mini turbine as well.  Of course, on the supply end, there's going to be the need for charge controllers/voltage regulators. We just ordered some components to try building a few circuit designs.  There's commercial stuff out there, but might as well give a crack at making our own.

There's also using a switching function to shut the vernier shields on and off, which would also reduce power consumption. I've just gone through a skyping with the Hixson kids on how to measure power consumption of different loads and to get a rough estimate of total daily consumption.  Bit of ohm's law there.

What the voltage regultion and switching functions both have in common is that they feature FET's (Field Effect Transistors), which will give a good opportunity to bring in a bit of circuit fundamentals.  Don't know if I want to make it a recorded tutorial, skype it, or both.  It's now on my list, though.

Kids will have a booth at Startup Week


We're on to show off what we're doing at Chattanooga Startup Week at the Creative Discovery Museum. They came up with a plan where folks can graduate through several stations of increasing complexity through different programming structures.  We'll also try to get a weather balloon in the air with some of our calibrated sensors.  We've just found an ozone sensor (read the datasheet! that we look forward to using.
Here's a time lapse video of three of our youngsters trying to assemble it all while figuring out exactly how the stations will work, including a bit of venting of frustration.  Good job, kids.