XBee Exploration

 

 

Summary

In this experiment we utilized Xbee radios; an analog radio transmitter and receiver that can be incorporated into a mesh network. Through this experiment there is an exploration of XBees and  initiating an interaction with an arduino component. This is communicated through ‘L’ or ‘H’ low or high to send and receive data and control pins in arduino. XBees can talk to each other by setting the channel and id’s. Incorporating the use of tones with this project I was curious to see how to program music and how that would coincide with sounds from other projects.

 

Process

Configuring the XBees through the software Coolterm to confirm the XBees are communicating was my first step. I did this by making sure ATID,ATMY and ATDL in Coolterm were properly configured.

ATID: This is the ID of the channel both XBees are talking on

ATMY: This is the ID that defines the Xbee you are using

ATDL : This is the ID of the Xbee you are transmitting to.

Using just an LED with Arduino Mirco and Xbee I tested to make sure the ‘L’ and ‘H’ commands were working. Using the sample Arduino file Physical Pixel and uploading to the controller I was able to turn my LED on and off through the serial monitor.  Then I connected my Xbee and changed the Arduino code from ‘Serial’ to ‘Serial1’. I could see my LED turning on and off so I was ready to progress and attach new components to my bread board.

While setting up my Xbee with my breadboard it’s important to note that the XBee cannot run on 5V it has to be connected to the 3V power pin in the controller.

Physical Pixel Code

const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into

void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}

void loop() {
// see if there’s incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it’s a capital H (ASCII 72), turn on the LED:
if (incomingByte == ‘H’) {
digitalWrite(ledPin, HIGH);
}
// if it’s an L (ASCII 76) turn off the LED:
if (incomingByte == ‘L’) {
digitalWrite(ledPin, LOW);
}
}
}

 

Never having used a speaker with arduino before I started to research how to use tones. From the Arduino website I found pitches.h. This file contains all the pitch values for typical notes. For example, NOTE_C4 is middle C. NOTE_FS4 is F sharp, and so forth. So instead of writing the frequency in the tone( ) function, we’ll just have to write the name of the note. This note table was originally written by Brett Hagman. I wanted to make use of the Piezo Speaker in order to play melodies. It produces PWM signals in order to play music. While using and testing with the Piezo speaker I learned can’t use tone() while also using analogWrite() on pins 3 or 11. That’s because the tone() function uses the same built in timer that analogWrite() does for pins 3 and 11.

 

 

With time being a factor I realized creating my own music wasn’t viable but I did discover a lot of pre existing music. I decided to use the music from the video games Super Mario Brothers. I correlated the music tones with the ‘L’ and ‘H’ command through the XBee. I added an LED to initiate with the speaker. While testing with this version of the breadboard the ‘L’ function would only sometimes work. I think this has to do with the sequencing of the tones.

 

Conclusion

With this collaborative project, I learned about the different affordances of creating an abstract orchestra through different sounds with others. The aspect of testing with others and seeing their projects was a positive experience and provided a good foundation in radio analog communication. Experiencing each project as a collective with these components is something that could be expanded upon later and with a larger network now that we know how to test and troubleshoot with the XBees.

https://github.com/aliciablakey/speakerxbee.git

References

http://www.arduino.cc/en/Tutorial/PhysicalPixel*/

https://learn.adafruit.com/adafruit-arduino-lesson-10-making-sounds/playing-a-scale

Play simple melodies with an Arduino and a piezo buzzer

 

Experiment 1 Xbee Talking

In this experiment, we explored the Xbee communication protocols.  The Xbee is a wireless radio device which can be used to communicate to each other with or without microcontrollers.

Mind Map

You can download the entire mindMap as a PDF from the image above.

The above is the basic ecosystem of how the Xbee works based on Kate Harmans Slides and Digi.Com website.

The Main Concepts:

  • The basic idea is the same as a Walkie Talkie, where one device can send and receive signals, they are transceivers.
  • The device runs on 3.5V and can damage the device if you use a higher Voltage.
  • The Xbee is configured and not programmed, you cannot add new commands to it only configure the properties set in the Data Sheet.
  • The Pin spacing is different for a breadboard so you have to use a breakout adapter.
  • It also operates in two modes transparent Vs Command Mode, transparent is the data mode to send and receive and command mode is activated with +++ where you configure the device.

The Experiment 01

For this experiment, we had to receive signal from one Xbee in the form of a PULSE, H would turn the power to the Pin On and L would turn the Pin to Low/OFF.

My idea was to use the signal to drive a fan which would be a tube and levitate a ball. I got the pieces together, but the fan was not strong enough to drive the ball into the air.

img_3491

What can I do to change this up?
I can get this to work if I use a Mosfet and use a higher powered fan and use a lighter ball. I did not have time to go back to get the parts and change my design.

img_3490

I went back to the drawing board and went with the simplest solution of programming a buzzer to receive the signal and creates a simple pulse.

img_3492

Gitcode: 

https://github.com/imaginere/Ubiquitous-Computing

References:

Digi.Com: https://www.digi.com/resources/documentation/Digidocs/90001456-13/Default.htm

Process Journal #1: XBee + Metronomes

Xbee Metronome
Process Journal #1
Olivia Prior

LCD screen

 

In this class, our assignment was to explore XBee radio communication through the concept of high (“H”) and low (“L”) commands as incoming data. Our class was each given an XBee radio, and an XBee breakout board to experiment transmitting and receiving radio commands. Our final assignment was to set up our XBee radios to control an actuator of our choice on Arduino that would respond to a “metronome” that was transmitting a count from an accompanying  XBee.

Part 1: Testing with the XBee Radios

Step 1: Internally sending and receiving

The first step was to connect my XBee radio to CoolTerm to test if my Arduino Micro would respond to high and low commands. I opened up CoolTerm, connected to the serial port that my Arduino was hooked up to, and tested typing “H” and “L” commands to turn on and off an LED. I had no problem with this working.

Using CoolTerm as serial communication, I type H to turn the LED on and L to off the LED.
Step 2: Connecting to a friend
Upon my initial testing, many students in the class had upfront issues with connecting to another XBee radio. I paired with a classmate in the studio and we switched our ATID to be on the same channel, and I changed my ATDL to match their ATMY. At first, my LED light was not responding immediately so we were unsure if the connection was working. We then realized there was a small lag within the communication, but were satisfied with the results knowing that we were able to transmit and receive commands to each other’s Arduinos.
To ensure that this was completely wireless, I changed the Serial library in the code to use “Serial1” to allow my Arduino to be disconnected from the machine.

A classmate and I testing out our transmitting and receiving with each other. They are transmitting “H” and “L” to control the LED light on the Arduino. 

 Step 3: Playing with new actuators
I removed the single LED and connected a small strip of addressable LED lights to my circuit. I jumped 5v to on side of the circuit as to not overpower the breakout board for the XBee on the other side which requires 3.3V. Using the same “H” and “L” commands as before, I used this data to turn on and off the strip lights. I used the AdaFruit NeoPixel library to control these LEDs.

Turning the LED lights on and off using “H” and “L” commands. 

Step 4: Changing the code

I was inspired by the realization that the Philip’s Hue Lights use a type of radio communication as controls. I have a few within my own possession and wanted to see if I could create a very simplified version. I copied the “H” and “L” command code, but rather than simply turning on and off the lights, I used different keys to change the colour of the strips. Here in the video below, I use the commands “R” for red, “G” for green, “B” for blue, “P” for pink, “Y” for yellow, “O” for orange, and “W” for white.

Creating a simplified version of Philip’s Hue Light by transmitting simple letter commands to control the hue of the LED strip. 

Part 1 overall outcome

At this point in my radio experimentation journey, the most exciting part is the ability to control one, or multiple other, devices through transmitting commands. I feel quite inspired through the mock “Philip’s Hue Lights” test to create smaller bespoke lamps for my own bedroom.

When testing by myself, the simple commands for turning the actuators on and off do not feel that different from what I have the ability to do with an Arduino solely.

When testing with others, I found that it was interesting to see the differences in “lag” depending on the radio. The classmate I was testing with had about a second delay on their commands, which led for confusion when attempting a proof of concept. The lag only went one way; when I would send commands their LED would turn on and off almost instantly. I wonder if this has anything to do with the machine speed on either side.

Part 2: Metronome

For this part of the experiment, I wanted to count how many “beats per a minute” the metronome was outputting. I decided upon this after choosing as my output, which was an LCD display.

Step 1: Choosing an output

For this experiment, I rifled through my toolkit to see what I had that would be newer and interesting to play with. I found an LCD LiquidDisplays that I had inherited from my Dad’s electronic supply and decided the use it.

LCD LiquidDisplay
LCD LiquidDisplay

I found readily available documentation for the LCD screen on AdaFruit. I followed the tutorial and connected the screen to my Arduino Uno. I was able to get a “hello world” screen up and counting the seconds that have passed.

LCD screen displaying the LiquidCrystal example which prints out “hello, world!” and on the second line counts how many seconds the program has been on.

Step 2: Connecting the XBee and LED lights

I then moved the connections to my Arduino Micro. I used the same code that worked for initial experimentation that made the addressable LED lights turn on and off. Rather than simply turning the LEDs on and off, I changed the brightness of them. I found that if I turned them on and off fully, it was too much of a drain of the power in the circuit. This would cause the LCD screen to flicker. As well, on the high command, on the screen I printed out “high” and on the low command I printed out “low”.

LCD screen connected to CoolTerm, and receiving “High” and “Low” commands to change the input of the screen, and as well the brightness of the LED strip. 

Step 3: Counting the beats

Because I was testing this at home, I wrote a pseudo metronome in my code to mimic different speeds of a count.

Mock metronome for testing purposes
Mock metronome for testing purposes

I would change the value of the metronome to get varying results. I would count the passing millisecond’s in-between counts, take 60000 and divide the result, and multiply by two to take into account the offbeat. I took this count and printed it out to the LCD screen.

LCD screen displaying a rudimentary BPM of the program

Step 4: What are you dancing too?

I took the BPM of the mock metronome, and then created statements that would print out what type of music correlated to the actual bpm that was listed. If the BPM was lower than 60 or higher than 200, messages of “slow is also good” come up, or a warning saying “Don’t dance too fast!” appear.

 

LCD screen showing the bpm of the program & what type of dance music is associated with that beat.

The one bug I have yet to fix is that the program initially detects that the bpm is half of what it is within the first couple of counts. It quickly fixes itself upon the second round of metronome counts.

Part 2 overall

I found this program to be interesting because it was not simply turning something “on” or “off”. It dynamically takes in data and will be able to print out the data accordingly so.

Testing out the screen with the metronome did not give as specific data as I thought. The range for the metronome was 100 – 5000 milliseconds, while my code is optimized for a range 200-1500 milliseconds. This is not necessarily a bad thing, as it requires someone to slowly go through the range as opposed to just cranking the potentiometer in either direction.

Overall the experiment was an interesting exercise in communication. It was interesting to see what other folks did with the metronome data in the class. Some interpreted the data to count every fourth beat, while others used the data to control servo-motors. The work altogether was interesting to see, and because of the nature of the rhythm of the metronome, it seemed to all connect in a collage-like way.

Liquid Crystal: https://www.arduino.cc/en/Reference/LiquidCrystal

Tutorial for LCD screen: https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1

Different music types: https://accusonus.com/sites/default/files/media/blog/Electronic_music_tempo-.pdf

 

XBee + Metronome – Birthday Box

 

Have your own birthday accompaniment with the Birthday Box!

1.

The introduction to the XBees for our first assignment was exciting for me, as I enjoy being introduced to different ways to connect/network with low-fidelity setup. It felt as “magical” as using pub-nub in terms of seeing its potential used in many instances that require devices to talk to one another.

In testing the chat through radio, I had a bit of a challenge setting up the XBee due to problems with the serial port installation. I swapped my radio kit to the Lilypad but CoolTerm still had problems recognizing my usb port. Soon after I realized that I had to install an older FTDI drive for my Mac OSX. It was a miss-step on my part (Always remember to check your operating system!) and once that was set up, the chat worked, albeit with some missing letters when it appeared on my peer’s screen. Using this as primarily a chatting tool might prove to be faulty. Regardless of the overlap when typing simultaneously with another person, it was simple and straightforward to use. I can see myself preferring to use this in future connectivity projects.

NOTES:
ATRE – to RESET configuration.
ATID – to determine the radio channel.
ATMY – to determine your radio ID.
ATDL – to set the ID of the radio you are sending information to.

2.

Before jumping into the output sensor for the experiment, I had to make sure that my XBee can send and receive data from other radios. We all sat together and made sure that we can accomplish connections between our radios by changing the atdl configuration. After multiple tests, I realized that there was a problem with my XBee, as it can send values but cannot receive. Even with my Arduino uploaded with the changed “PhysicalPixel” example, (adding 1 after Serial) it would not activate the LED. I tried debugging it multiple ways from resetting my settings on CoolTerm to changing the circuit and trying my XBee on different breakout boards.

What turned out to be the problem was my soldering technique. I was rather sloppy in soldering the pins to my XBee breakout board and had some solder connecting pins next to each other. After fixing the problem, it was Finally able to receive values from another, with “H” turning on the LED while “L” turned it off.

img_7263
Breakout board after fixing the soldering

To complete this experiment, I decided to use the speaker as I am quite familiar with it from previous projects. I wanted to look for a tune that is more familiar with others and can be used for social events. As a result, I found a tune for the Happy Birthday song and implemented that in the toneMelody code. The Arduino code for this experiment can be found here: https://github.com/antariksacp/Birthday-Box. When the XBee receives an H, the speaker will play the Happy Birthday tune.

In regards to testing it with the metronome coordinator Kate provided, the potentiometer can be used to set how frequently the song will play. Once the values are sent, the song will play until it completes and once it receives another “H”, it will then play again. The slowest duration would be it repeating every few seconds, and the longest would have a delay of about 5-10 seconds.

In forming the circuit, I had first placed the components on the breadboard but managed to place it in the box with a smaller one. A few things I had to note were to make sure that the GND on the Arduino connected to ground, otherwise the circuit would not work(!) I tested a variety of ways to place the breadboard in the box to make sure that when closed, the radio can still receive the signal. I found that by placing it nearer to the lid proved to work (as shown in the video), as opposed to just placing it in the bottom of the box. I also used a different 8 ohm speaker than the one provided the kit as it had a slightly louder volume.

img_7267
Using the normal breadboard
box-01
Placing the smaller breadboard inside the box

There were also other possibilities to play around with the “H” and “L” values in terms of controlling the Happy Birthday melody. Perhaps once the “L” value is sent, the tune can stop instead of playing until the end, or as the potentiometer is turned to the slower values, the speed of the song can be altered instead of the frequency. For now at least, we have the traditional Birthday Box.

 

Metronome Gong

What’s an orchestra without a percussion section? This little robot bangs a gong with aplomb, filling the air with an irritating ring.

The XBee Chat exercise in class was, for me, an opportunity for play. Being able to communicate directly, free of the constraints of networking via the internet, felt like discovering the magic of chatting with a friend over walkie-talkie. Omid and I goofed around like kids, sending jokes and ASCII images back and forth through the XBees.

The freedom of being able to communicate relatively code-free, without having to worry about packets or JSON (which I must admit are a concept I still have trouble wrapping my head around) is relevatory and I’m excited to explore.

The Metronome Receiver device was an opportunity to explore an idea I’ve had since early in the first semester. I had an idea for exploring sensor-controlled percussion instruments way back in the This + That experiment of Creation & Computation that I had to shelve at the time. I had conceived of an Arduino-powered device that struck a  singing bowl when certain criteria were met. When we were given this assignment, I was excited for the chance to try it out.

I started by considering exactly what I wanted to make: a small arm that would bang a gong. Having worked with solenoids last semester I felt comfortable with their coding and operation. I bought a cheap one and tested it out.

Here was my first pass on the code, for testing the solenoid:

int incomingByte; // variable for incoming serial data
int solenoidPin = 2; //control the solenoid
void setup() {
    Serial.begin(9600);
    pinMode(solenoidPin, OUTPUT);
    }
void loop() {
    digitalWrite(solenoidPin,HIGH);
    if (Serial.available() > 0) {
       incomingByte = Serial.read();
       if (incomingByte == 'H') {
//strike the gong then recede
           digitalWrite(solenoidPin, LOW);
           delay(100);
           digitalWrite(solenoidPin, HIGH);
            }
        }
    }
}

Animated GIF - Find & Share on GIPHY

This worked nicely, though I was alarmed at how hot the solenoid got as it was required to stay engaged at HIGH for the majority of the time the circuit was active. I checked my wiring repeatedly and found no mistakes. I looked it up and found multiple sources reporting that this was normal, as long as the heat stayed uniform and did not continually increase. I resolved to keep an eye on it and not keep the circuit engaged for extended periods.

Rather than seek out a drum or gong, I decided to use the singing bowl I own. However, I noticed that the bowl had a high-pitched and long ringing peal, which I thought might be irritating. So I rewrote the code so the solenoid only fired on the third beat:

int incomingByte; // variable for incoming serial data
int solenoidPin = 2; //control the solenoid
int beat = 0; //an integer for monitoring the beat
void setup() {
   Serial.begin(9600);
   pinMode(solenoidPin, OUTPUT);
   }

void loop() {
   digitalWrite(solenoidPin,HIGH);
   if (beat >= 4) {
     beat = 0;
     }

   if (Serial.available() > 0) {
     incomingByte = Serial.read();
     if (incomingByte == 'H') {
       beat++;
     if (beat == 3){
//strike the gong then recede
       digitalWrite(solenoidPin, LOW);
       delay(100);
       digitalWrite(solenoidPin, HIGH);
       }
     }
   }
}

ubiqgong-fritz_bb

Finally, to keep the solenoid in place, I made a little stand out of a coffee cup.

Some issues still to explore and solve:

The XBee only gets reliable reception when it is physically close to the transmitter.

Even when close, it seems to miss or drop beats occasionally.

Parts:

  • Arduino Micro
  • XBee and XBee Breakout Board
  • Barrel Jack
  • 12V 2A AC/DC Adaptor
  • TIP120 Darlington Transistor
  • 1K Ohm Resistor
  • IN4001 Diode
  • Solenoid
  • Alligator clips x2
  • Wiring

Process Journal 1- Jingpo

XBee Chat Exercise:

Step1: Download software(CoolTerm) and driver(FTDI USB).

Step2: Change the configurations of the radio in command mode.

We need to configure XBees to enable the communication. These radios are configured with AT commands, so we learnt some basic AT commands from AT command set:

ATRE = factory reset – this will wipe any previous settings
ATMY = my address – the label on your radio
ATDL = destination low – the label on your partners radio
ATID = pan ID – the agreed upon “channel” both radios are using to communicate
ATWR = write to firmware – this will make sure the configurations are saved even when the radio loses power
ATCN = end command mode

Open CoolTerm:

Go to Options → Serial Port

Go to Terminal → Select Local Echo

Step 3: Let’s chat!

screen-shot-2019-01-14-at-3-50-36-pm

img_0164


Metronome Receiver Device:

Arduino Code:

Use “Serial” to test the code. Change “Serial” to “Serial1” when arduino is connected to xBee and send the “H” and “L” commands via the serial monitor.

Sample Code is from Arduino example, Physical Pixel. It is an example of using the Arduino board to receive data from the computer.

screen-shot-2019-01-14-at-3-57-39-pm

Add a servo and change the Arduino code:

screen-shot-2019-01-14-at-4-00-09-pm

img_2832-2

Fabrication:

img_3528

I want to have a fan connected to the servo, so I went to dollar store and got this candy toy for 2 dollars, along with an unexpected free motor, a button and a battery.

img_3289img_2411

img_2597

 

 

 

 

Process Journal 1-April

  1. Design pattern 

design-pattern

Since Serial1 would not work on Serial Monitor on Arduino, to make sure the pattern works as expected, “Serial” was used in programming. The expected result is that when “H” is entered, the blue led (ledPin), green led (green) and white led (white) quickly blink in order and then all light up. When “L” is entered, all three led light out. 

Please click here to view the pattern.

password: pattern

 

2. Configure the radio

radio

To make sure two radios can chat.

3. Program Arduino

program1

program2

This time “Serial1” is used to allow Arduino to receive commands from the radio. It is okay that we do not test it after uploading since we did it in step 1. If there is any problem, it should not be the code.

4. Light!

After this step, we successfully lit my Arduino led using coolterm in Jing’s laptop. We did not succeed in once. Please see analysis in the next paragraph “Problems and Findings”.

Problems&Findings

  1. The RX and GND should be plugged in the very left two holes of the breakout board as the photo shows.solution1
  2. When a chat is successfully made, directly unplug the XBee from radio pad and plug it onto Arduino. There is no need to enter +++ again in coolterm.
  3. To make sure the command is delivered, use send string instead of directly typing it.
  4. Just send “H” or “L”, don’t go like “HHHHH” or “LLLL”.

 

Process Journal #1 – Radio Rabbit (Tyson)

Radio Rabbit

Video: pic.twitter.com/mjzqA4hqOe

Day 1:

We were introduced to the XBEE radio transceivers. My radio kit came with a Lilypad Arduino which conveniently could be used to configure the radios. I tested the device out with another student and we sent several strings back and forth between eachother.

Reminds me of the command terminal on computers / past arduino serial communication experiments. The XBEEs were relatively easy to setup with the aid of the lecture slides provided by our professors and the necessary firmare. Transmissions have been clean so far, but will have to watch out for dropped packets when testing in the future.

Since the XBEEs don’t natively fit on breadboards, I soldered the breakout board provided to us after class.

The important things to note:
– 3.3v power supply
– RX / TX pairing between the arduino micro and xbee on setup
– serial can be used to communicate with the XBEE for testing purposes, but ‘Serial1’ must be used in the Arduino code to denote communication with the 1 and 2 pins.

Day 2:

For the sake of our task to create a device to interact with a metronome signal I was inspired to use several servos I had leftover from last semester to create some sort of rabbit. I wanted the project to be relatively simple but demonstrate motion and have an entertaining appearance. I first tested out the servos with both a 9V power supply and a USB power supply. Supplying the four small devices that would be the legs worked as expected and operated fine with some demo code provided through Arduino’s IDE (Servo Sweep and Physical Pixel), although I discovered yesterday that the charge remaining in my battery supply seemed to have diminished overnight and lost its efficiency. The weight of the device on the breadboard began to concern me as I thought about how the device would be supported if it were to be an enclosed object.

When it came time to design lasercut parts for the device, I created two types of legs to test (forelegs and back legs), with multiple copies cut to allow them to be laminated for thickness. The servos were mounted beneath the device’s breadboard with Weldbond and a second panel and oriented as appropriate for the four-legged mammal. The legs were mounted to the servos with the kit attachments, some glue and screws; without the screws, the legs were unable to support the weight of the device.

20190109_174258 capture

Day 3:

The code has been designed to operate in two different states: a wide stance for a “High” signal and a narrow stance for a “Low” signal, in similar appearance to the visual look of a sprinting rabbit. The orientation of the servos required, for example, that the left back leg was positioned to a different angle than that of the right back leg in order to appear symmetrical. For my code, this meant that the angles for the respective servos were at opposite ends of a range between 0 and 180. Naturally, having the legs span the whole range of the servos looked peculiar and caused some technical hiccups with the leg behavior, so it was reduced to an appropriate span.

The back legs seem to perform more effectively than the forelegs, which often get caught in awkward angles causing disruptive behavior. This may also be due to my selection of servos for the forelegs, which are of a different, cheaper make than the hind ones supplied by last year’s Creation and Computation class kits.

20190109_181210fritz

Day 4: 

Along with several other classmates I tested out my device’s functionality with the radio signals of other XBEEs. It took a bit of troubleshooting to detect but it turns out the device works fine, if a bit finicky sometimes with receiving the data packets. This could be due to the amperage draw of the servos competing with the XBEE; given some of my past experiences with servos I’m fairly surprised how well the circuit has been working up to this point.

I did end up getting a replacement battery, which worked just once with the remote signal but afterwards lacked the capacity to support the circuit. Perhaps I will look into using 12V instead of 9V in the future.