National Geographic Education Water Sensor Challenge

This was originally a tutorial that was given at the 2014 Bay Area Science Festival. Let us know if you have any improvements to it or if you have a successful workshop!

Workshop Focus:
Lesson explores computer programming and the impact of computers on better understanding of our environment. Workshop participants build and test a boat that uses hardware and software to send temperature readings using an Arduino board. They connect the hardware, program the code, test their system, customize it (with different sample times, team names, etc), evaluate their results, and watch the data posted live to a map and twitter.

Workshop Synopsis
The ” National Geographic Explorer Water Sensor Challenge” lesson explores how computer and software engineers can help us better understand the world around us. Participants work in teams to set up and program an Arduino board to take a reading from a temperature sensor and send that reading over SMS. Teams build their system, program and test it, reflect on the challenge, and deploy the sensors into the Bay.

Preferred Age Levels
Core team of ages from 12-18, however younger/older team members could help with some of the process (decorating the boat, etc.).

DSC_1215

Objectives

  • Understand the need to know more about our environment.
  • Learn about engineering design/redesign and open source
  • Learn about circuits, computers, and software coding.
  • Learn about the importance in engineering to help solve Earth’s challenges.
  • Learn about teamwork and problem solving.

Resources/Materials
Prices for the electronics reduce with greater volumes of purchases. All necessary soldering will be done before the workshop so hardware just involves simple connections with breadboard. Code for the functions will be created in advance (including lessons on rationale behind that code) to help teams that have issues in determining the correct code.

Project Inspiration
Via here: http://newswatch.nationalgeographic.com/2014/08/20/open-source-okavango14-the-heartbeat-of-the-delta/

Shah Selbe is the Project Technologist that is responsible for the design and development of the environmental monitoring platforms for the Okavango Wilderness Project, a collaborative project amongst a number of National Geographic Explorers. During the 2014 expedition, three prototype open source sensor platforms were deployed to test the ability for sensors to directly measure and report these environmental parameters. These platforms are currently collecting daily measurements of temperature, pH, and conductivity and sending the data to the Into The Okavango website via SMS. The lessons learned from these deployments and their integration with www.intotheokavango.org have influenced the need for a next generation of sensors to be deployed and linked to the public API in 2015. For 2015, fifty of these platforms will be deployed at various points during the expedition.

This workshop allows future engineers and scientists to repeat the work that we are doing with National Geographic to protect one of this planet’s greatest environmental resources, Botswana’s Okavango Delta.

Procedure

  1. Show students the participants reference sheets and final completed platform.
  2. Conduct primer to open source computing including:
    1. Background about Okavango14 (2 mins)
    2. Introduction to engineering for helping our planet (5 mins)
    3. Introduction to Arduino (5 mins)
  3. Organize teams and pass out workshop plans. Explain process.
  4. Participants set up their Arduino, build circuits, program it and test it until it meets the challenge. (60 mins)
  5. Participants place systems in the boat and decorate accordingly. (20 mins)
  6. Teams deploy sensors into the Bay, watch screen for the sensor readings to come up real-time on the twitter. (remaining time)
  7. Retrieve sensors using tether. Shah to later deploy sensors in the LA River to allow for continued updates.
  8. Teams reflect on the challenge, and present their experiences to the class. (5 mins)
  9. Buffer time?

Set-up computer software

Download necessary software:

Software

Unzip the OneWire and DallasTemperature archives and copy them into your Arduino libraries folder.

For Windows users:

My Documents -> Arduino -> libraries

Mac users:

<home directory> -> Documents -> Arduino -> Libraries

Then restart the Arduino software.

Start building circuit

The parts necessary are:

  • Arduino Leonardo microcontroller
  • GPRS (SMS) Arduino shield
  • Prepay SIM card (T-Mobile)
  • Dallas Semiconductor DS18B20 One-Wire Temperature Sensor
  • 7k pullup resistor
  • Half-size breadboard
  • Battery holder
  • AA batteries (6 per sensor)
  • Jumper wires
  • Plastic boat body
  • Miscellaneous paper decorations for the boat, rope to deploy/retrieve
  • Computers per team to do the coding and uploading

Explain all the part and what they do.

Explain the history of the Arduino.

Start assembly of units

  1. Place parts in front of the teams in the work area to be able to identify everything
  2. Put SIM card in the back of the GPRS shield
  3. Carefully place the GPRS shield onto the Arduino (pins connect easily on-top of each other)
  4. Use the breadboard to connect the temperature sensor, resistor, Arduino-GPRS combination, and resistor

ds18b20_bb

  1. Place batteries in battery holder (but do not connect to the Arduino yet)
  2. Plug in the USB cord into the Arduino and the computer

Build the boat

  1. Thread the temperature sensor through the lid of the boat
  2. Place decorations into the boat housing
  3. Place the parts into the boat, but allow access to the USB plug and power port
  4. Tie rope onto lid for deployment and retrieval

Start coding

Open the Arduino IDE for uploading the code to the Arduino.

  1. Connect the Arduino through the correct port and Arduino board

Screen Shot 2014-10-29 at 8.38.40 PM

 

Screen Shot 2014-10-29 at 8.39.03 PM

  1. Check to make sure that the Libraries are loaded into the IDE

Screen Shot 2014-10-29 at 8.39.17 PM

  1. Explain the software coding philosophy
    1. Generic Arduino sketch program architecture “What is a sketch”
    2. Look at code examples (back of this document)
    3. Upload ino to test to make sure that the temperature sensor is reading
    4. Upload ino to test to make sure the Arduino can SMS a pre-defined message
    5. Upload ino to take temperature reading and send it with team name
  2. Open ino in IDE
  3. Explain how the program works
  4. Open Serial Monitor to see the temp sensor reading

Screen Shot 2014-10-29 at 8.53.10 PM

 

tempmonitor_ide

 

  1. Open ino in IDE
  2. Explain how the program works
  3. Make custom message for each team
  4. Send to Arduino, watch @NGExploreSensor for message
  5. Open ino in IDE
  6. Explain how the program works
  7. Make custom message for each team
  8. Send to Arduino, watch @NGExploreSensor for message
  9. Plug in battery pack

Deploy boats

  1. Place lid on the boats
  2. Walk them over to the water
  3. Hold on to end of rope and deploy
  4. Tie rope end to something to not lose the boat
  5. Watch the readings come in on @NGExploreSensor twitter

Screen Shot 2014-10-29 at 10.54.21 AM

Open Source Computing

Arduino is an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino projects can be simple — such as turning on and off a light — or very complex. The boards can be assembled by hand or purchased preassembled; the open-source software can be downloaded for free. The Arduino software runs on Windows, Macintosh OSX, and Linux operating systems.

Computer Programming

Computer programming (often shortened to programming or coding) is the process of designing, writing, testing, debugging, and maintaining source code of computer programs. The code can be written in many different programming languages. Programming is basically a set of instructions that a computer or other device uses to perform a task — it might be turning on a light, opening a door, or writing a document.

Arduino Development Environment

The Arduino development environment or software contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions, and a series of menus. It connects to the Arduino hardware to upload programs and communicate with them. Software written using Arduino is called a “sketch.” These sketches are written in the text editor. Sketches are saved with the file extension .ino. There are features for cutting/pasting and for searching/replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino environment including complete error messages and other information. The bottom right hand corner of the window displays the current board and serial port.

Arduino code

 

temperature.ino

// This Arduino sketch reads DS18B20 “1-Wire” digital

// temperature sensors.

// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

 

#include <OneWire.h>

#include <DallasTemperature.h>

// Data wire is plugged into pin 2 on the Arduino

#define ONE_WIRE_BUS 2

 

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)

OneWire oneWire(ONE_WIRE_BUS);

 

// Pass our oneWire reference to Dallas Temperature.

DallasTemperature sensors(&oneWire);

 

void setup(void)

{

// start serial port

Serial.begin(9600);

Serial.println(“Dallas Temperature IC Control Library Demo”);

// Start up the library

sensors.begin(); // IC Default 9 bit. If you have troubles consider upping it 12. Ups the delay giving the IC more time to process the temperature measurement

}

void loop(void)

{

// call sensors.requestTemperatures() to issue a global temperature

// request to all devices on the bus

Serial.print(“Requesting temperatures…”);

sensors.requestTemperatures(); // Send the command to get temperatures

Serial.println(“DONE”);

Serial.print(“Temperature for Device 1 is: “);

Serial.print(sensors.getTempCByIndex(0)); // Why “byIndex”? You can have more than one IC on the same bus. 0 refers to the first IC on the wire

}

 

textmessage.ino

// This Arduino sketch reads DS18B20 “1-Wire” digital

// temperature sensors.

// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

 

#include <SoftwareSerial.h>

SoftwareSerial SIM900(7, 8);

 

void setup()

{

SIM900.begin(19200);

SIM900power();

delay(20000); // give time to log on to network.

}

 

void SIM900power()

// software equivalent of pressing the GSM shield “power” button

{

digitalWrite(9, HIGH);

delay(1000);

digitalWrite(9, LOW);

delay(5000);

}

 

void sendSMS()

{

SIM900.print(“AT+CMGF=1\r”);                                                       // AT command to send SMS message

delay(100);

SIM900.println(“AT + CMGS = \”+13239994470\””);                                     // recipient’s mobile number, in international format

delay(100);

SIM900.println(“Hello, world. This is a text message from an Arduino.”);       // message to send

delay(100);

SIM900.println((char)26);                       // End AT command with a ^Z, ASCII code 26

delay(100);

SIM900.println();

delay(5000);                                     // give module time to send SMS

SIM900power();                                   // turn off module

}

 

void loop()

{

sendSMS();

do {} while (1);

}

 

 

SMStemp.ino

// This Arduino sketch reads DS18B20 “1-Wire” digital

// temperature sensors.

// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

 

#include <SoftwareSerial.h>

#include <String.h>

#include <OneWire.h>

#include <DallasTemperature.h>

String textForSMS;

float currentTemp;

SoftwareSerial mySerial(7,8);

 

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

void setup()

{

mySerial.begin(19200);               // the GPRS baud rate

Serial.begin(19200);   // the GPRS baud rate

Serial.println(“test”);

delay(500);

sensors.begin();

}

 

///SendTextMessage()

///this function is to send a sms message

void SendTextMessage(String message)

{

mySerial.print(“AT+CMGF=1\r”);   //Because we want to send the SMS in text mode

delay(100);

mySerial.println(“AT + CMGS = \”+13239994470\””);//send sms message, be careful need to add a country code before the cellphone number

delay(100);

mySerial.println(message);//the content of the message

delay(100);

mySerial.println((char)26);//the ASCII code of the ctrl+z is 26

delay(100);

mySerial.println();

}

 

String AppendFloat(String oldString, float num)

{

char buf[20];

char* string = dtostrf(num, 4, 2, buf);

oldString.concat(string);

return oldString;

}

 

 

void GetTemp(float reading)

{

sensors.requestTemperatures();

currentTemp = sensors.getTempCByIndex(0);

}

 

void loop()

{

Serial.println(“Trying…”);

GetTemp(currentTemp);

currentTemp = sensors.getTempCByIndex(0);

textForSMS = “Team SF Temp (deg C) reading is “;

textForSMS = AppendFloat(textForSMS, currentTemp);

Serial.println(“Message:”);

Serial.println(textForSMS);

SendTextMessage(textForSMS);

delay(300000);

Serial.println(“Done waiting”);

}

void ShowSerialData()

{

while(mySerial.available()!=0)

Serial.write(mySerial.read());

}

 

 

 

Comment(1)

  1. Mr WordPress says

    Hi, this is a comment.
    To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.

Post a comment