Saturday, April 16, 2016

Problem solving with Code and Arduino

When some teachers asked me if we could build a temperature sensor that didn't require walking up and taking a physical  reading, without hesitation I said yes.  What followed was a deep exploration into the Arudino environment and an introduction to Python coding.

The project has been very rewarding.  While not totally complete, we did answer the question of whether we could build a system that could remotely monitor the temperature and communicate that information in graphic form to another computer.  Now the winter has left us, we'll have some time to move our beta to a real embedded model.

When I initially began the project, I worked independently trying to learn as much as I could about the hardware, what I needed to order and how to set it up.   After some individual learning time, I started working with some students from our Computer Systems Technology class.  They helped with soldering parts and setting up our communication network with our Arduino compatible radios.  We also studied some of the Arduino code libraries, testing a variety of sketches using our new Xbee radios.  Probably the most fun we had was building test models of projects that were not even related to our project.  As long as the students were excited, I didn't mind the need moving slowly on this project.  Learning can be fun, and experimenting is probably the best form of that.

Currently the project is in beta form.  We have to still figure out how to use our digital sensor to pass data.  We had no problem with the analog sensors.  We also have to build a waterproof shell and configure the radios to hibernate so as not to burn out the batteries.  I've spent countless hours working on various configurations, temp sensors and code combinations.  I feel like I am a lot more confident while working with the Arduino IDE and writing basic code.  I really enjoyed learning some Python basics and I only hope I can get a few more students interested in the project and other projects by showcasing this one.  I plan to introduce this beta project with the new CST class next fall.  We'll then form a group that will tackle this project including the design of the housing and computer configuration (remote IP address and website) that will be capturing the data.

I've included this Link to my Google Site - Create with Code.  There you may explore the entire project, review the code and set up.  Share any materials as you see fit.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

Sunday, March 27, 2016

Using PHP for Web Design

Using PHP to code & validate web forms
This spring I enrolled in a web design course with UVM.  Weekly we have been creating with Code!  To date, I've created four different web sites using HTML and CSS.  In addition, we have been writing a lot of PHP to create the HTML code on each page, or for validating forms, debugging and automating pages.

For example, instead of updating a footer element on each page of a ten page site - just create a footer.php page and write your footer.  Then, call the footer on each web page using a PHP include statement.  Very cool way to do mass updates and changes.  I learned that the same process can be used to create a header.php, nav.php and top.php pages.  This process ensures that each page is structured the same way.

CSS stands for Cascading Style Sheets.  CSS is what makes webpages look great - color, fonts, design and layout.  A fun website to see how CSS works is to explore csszengarden.com.  On this site, all of the content is the same, but the CSS gives each example a unique look.  CSS is very powerful and a creative way to style the web and improve the user experience.

This past week, we've been using PHP to validate our forms, sanitize and check our data for errors and return a confirmation statement or error - with an array to list those errors.
Check out the error functionality I created using PHP code:
https://wbohmann.w3.uvm.edu/cs008/assignment3.1/form.php

The PHP coding for form validation took over 10 hours to write and included more than 300 lines of code.  This has been a challenging class with UVM - mostly due to the PHP.  However, I've been learning a lot about creating more functional websites.  For my final project, I plan to create a website for my summer food truck - StreetGreens.

Sunday, March 20, 2016

Working with Xbee's - Week 10 open project

I've been putting off my xbee project for awhile.  When I was working with it early on, I failed to document many of my resources, my failures and successes.  Recently I attended a session at the SXSWedu conference on Open Portfolios.  Essentially by not documenting my process, I failed to complete a portfolio of my learning. So, for Week 10 of Create with Code, I decided to go back and spend some time re-curating my resources and finally trying to get my damn Xbees working with a real sensor.
Here's a list of great resources for Xbees and Arduinos:

The first is from TunnelsUp.  There are 5 videos in this series that go over some excellent material on how to set up the Xbees with XCTU software, learn about Coordinator and Routers and setting up a network.  I also learned how to jump my chip on the arduino and make a serial connection hack - which saves about $25 on a device that does the same thing.
 
The next best resource from the same author is the Xbee Cheat Sheet he made to better understand all of the pin locations, settings and basics.   I use this sheet often.

Both AdaFruit and Arduino Forums have a fair amount of information on the Xbees and even better, information on sensors, especially Adafruit.   The Arduino forum has a couple of members that are pretty curt with responses.  One member responds to most queries in the forum, but I've noticed a pattern around how poorly he treats people with questions.

YouTube has been really valuable.  There are a lot of people building interesting things with the Arduino.  I found someone who is doing something similar to what I want to do, except he is using a temperature and humidity sensor to measure his chicken coop.

Well, on to my project.  Step one was to get the two Xbees to communicate.  Check!  Using the XCTU software on two computers, a student in CST, an instructor of the same course and me set up a xbee network and communicated on the same channel through a terminal window.  I recreated this same "Chat" this past weekend just to make sure both my Xbees were working correctly.

Step two:  hook up a temp sensor (I just bought a fresh TMP36) from Amazon as well as a DHT11 sensor.  Both worked well, running the Sketch #7 in the SIK Sparkfun Guidebook for the TMP36 and the AdaFruit Sketch for the DHT11.

Step three:  Draft up my sketch (see my video below) and plan my network.  So far, it made sense on paper.  I built the sensor, configured the xbees and used some sample code from TunnelsUp (found in Video 4 of his series).

Step four:  Frustration.  After an hour, I finally got my xbees to communicate.  I think either the router went to sleep, or the wrong port was called for communication.

 

This video shows my progress so far.  I've been able to set up a connection and reliably communicate from the router back to the coordinator.  However, I cannot seem to get the voltage right, as it does not appear that the Code is sending the right information packet for the sensor to grab.  I spent about six hours debugging, re-coding and troubleshooting.  I am totally at a loss on what might be happening.  I am going to meet with the CST department for some new direction.  Ultimately I want to hook a digital sensor (ds18b) to send temp information.  If I can't get the analog to work, I don't know how I am going to attack my compost temperature project.

Here is the code I am using to call the sensor.

float temp;
void setup() {
 
  Serial.begin(9600);
};


void loop() {
  if (Serial.available() >= 21) {
    if (Serial.read() == 0x7E) {
      for (int i = 1; i < 19; i++) {
        byte discardByte = Serial.read();
      }
      int analogMSB = Serial.read();
      int analogLSB = Serial.read();
      int analogReading = analogLSB + (analogMSB * 256);
      temp = analogReading / 1023 * 1.23;
      temp = temp - .5;
      temp = temp / .01;
      temp = temp * 9/5 + 32;
      Serial.print(temp);
      Serial.println("degrees F");
    }
  }
}
 

Saturday, March 19, 2016

Playing with the Wink robot from PlumGeek

Wink is an arduino fan delight - I've enjoyed playing with the code and the lessons from PlumGeek are pretty good too.  I posted the following on the Robot Rodeo blog:

Introducing Ferris, a WINK robot from Plumgeek


"Ferris" a Wink robot from PlumGeek Software
Meet Ferris.  Ferris is actually the Wink robot from PlumGeek Software.  The Wink robot has been designed to introduce programming to people who are interested as an entry point to learn how to write code and for experienced coders alike.  Using the Arduino IDE open source platform, code can be written to activate a host of exciting features that are built into the robot. These features include blinking RGB lights, actuators for movement, proximity sensors for obstacle detection, light sensors for following light and line detection and for some Winks, a IR remote to control those behaviors.

I named my robot Ferris, because I had some challenges getting him to school each day.  The challenge of setting up reminded me that sometimes Ferris just needed a day off.  Now that I've broken him in, he's been pretty dependable and can do some exciting things.

The first hurdle has been introducing the Arduino programming to High School students who've never written code in the Arduino environment.  PlumGeek has helped bridge the gap by providing a series of usable lesson plans and pre-loaded behaviors available for download on their website.

Fortunately, I've been working with a couple of classes at the Center for Technology in Essex.  The Computer Systems technology class and PreTech classes have been able to play with Ferris.  We've started doing basic coding, like learning how the lights operate, adjusting Ferris eyes to blink, change colors and emit different light levels.  I'm working with a student at the moment on obstacle detection, which Ferris is really good at.  The light detection sensor is very good, as Ferris seems to have a strong will to find a nice sunny space to relax in (don't we all).  Here's a little of Ferris in action (my dog does not care for Ferris - you might hear her whine).

Tuesday, March 15, 2016

Internet down... 'Say What?, Say my teenage daughters"

Ella working on a LED Flower with cotton balls
Recently I changed my modem as Comcast changed their support for certain generation devices.  Ever since the changeover, my internet has been pretty slow.  Turns out, Comcast has been having trouble in my area since around the time I activated my new modem.  However, today - no internet.  My teenage daughters were in rare form.  All of a sudden, they had homework that required the internet.

So, to make the time pass with my younger one, I broke out the Arduino.  She was reluctant at first, but then jumped right in.  We made multiple lights blink in different patterns, added alligator clips and more lights to the circuit to make lights on a stick (with glowing cotton balls) and we hooked up a TMP 36 temp sensor and measured who's breath was hotter.  We also rigged up a photoresistor and and made an attempt at a battery operated night light.  It was pretty fun and finally my daughter got a better idea what was in the piles of Arduino gear on the family dining room table.

Arduino Gear on dining room table
Maybe I didn't create too many complicated sensors, but I did enjoy the break and a chance to talk about the code with my daughter.  She got a kick out of changing the code and adding new code for new lights.  Sometimes there is good reinforcement in the basics.

Now back to my failing Xbee project....

Sunday, March 13, 2016

Student says "Cool"

The first day back from winter break turned out to be a snowday for many of our sending schools.  For those few souls in PreTech that made it to school that day, we had a fun day planned with robots and programming.  Many robots were in play that day, we had the Ozobot, an Sphero, the Finch as well as my robot - the Wink.  

After a troubling installation of the software and nearly having my paired student lose interest, I finally got the Arduino software mapped to the correct directories.  Teaching myself has mostly been a trial of mistakes and practice, and I knew that working with this student was not going to be so easy, as I had to explain what Void Setup, Void Loop and other programming features of working with the Arduino based platform.  We decided to run a program on the WINK just to manage the eyes.  Our code looked like this:

void loop(){

  leftCyan(100);    //make left eye cyan color
  delay(20);        //stay on for a short time
  eyesOff();        //turn eyes off
  delay(100);       //delay between blinks
  leftCyan(100);    //begin second blink
  delay(20);        //stay on for a short time
  eyesOff();        //turn eyes off again

  delay(2000);      //time before 2nd eye blinks

  rightCyan(100);   //make right eye cyan color
  delay(20);        //stay on for a short time
  eyesOff();        //turn eyes off
  delay(100);       //delay between blinks
  rightCyan(100);   //begin second blink
  delay(20);        //stay on for a short time
  eyesOff();        //turn eyes off again

  delay(2000);      //time before repeating 


Once the student learned what the delays were and what colors he could call out, he started to change the code, copy the code and add to the code to run the WINK through a series of color changes and brightness stages.  Adding brightness, the code looked like this:

void loop(){

  eyesBlue(25);     //set both eyes to blue, at brightness 20
  delay(200);       //wait a short time
  eyesBlue(75);     //set both eyes to blue, at brightness 75
  delay(200);       //wait a short time
  eyesBlue(125);    //set both eyes to blue, at brightness 125
  delay(200);       //wait a short time
  eyesBlue(175);    //set both eyes to blue, at brightness 175
  delay(200);       //wait a short time
  eyesBlue(225);    //set both eyes to blue, at brightness 225
  delay(200);       //wait a short time

  eyesOff();        //turn eyes off
  delay(1000);      //wait 1 second then repeat
}


Again, he repeated the code, changed the colors, brightness levels and so on.  Eventually we called out RGB color by using his favorite colors from Color Scheme Designer.    While just remixing, the student who was initially not too excited, responded and said "Cool".  Which I'll confirm as a small success.

Sunday, February 14, 2016

Working with Python and Wink robot

Wink Robots - all finally working!
I'm at an interesting place with coding at the moment.  I've been challenged by an Arduino project that I mentioned in my last post - which was to build a wireless sensor that communicates via Xbee zigbee network.  In addition, I have the Wink robot from PlumGeek (thanks to Learning with Lucie )that is coded in the Arduino environment using the same coding language as the Arduino - Python.  On top of those two projects, I enrolled in a Web Design course this year because it's been awhile since I've done some web design work.  We've been doing a lot of PHP which was not something I learned years ago.  Also, HTML5 is now nearly standard, so most of the structure of websites now uses abridged elements and PHP for easy updating and universal design.  I've been challenged with writing PHP arrays.  However, I've seen some good crossover from the for and foreach statements as well as the conditional statements in Python.  I'm feeling "all in" at the moment.  Many projects, lots of coding, lots of reflection.
My desk - littered with fun toys
Fortunately, there are so many great web resources for helping out folks like me who like to stumble around in the dark and figure things out:

PlumGeek and the PlumGeek forums has been really helpful.  I joined the forum and asked for some support and the community quickly responded. 

On an Arduino forum, I found an interesting project similar to mine and emailed the poster.  Within a day a retired man from Florida who authored the post shared some resources and some advice for how to proceed with my Xbee project. 

Lastly, I've been using the web developer toolbar, firebug and W3Schools for learning all kinds of information for web design, including tutorials on PHP.