Tag Archives: capacitor_sensor

Final Project Blog Post: Fortune Teller

Presentation: https://docs.google.com/presentation/d/1sUYrrKJgouIBgrMRpbiFp6CLde5otBWy1A05Q2PdyU4/edit?usp=sharing

Concept + Goals. What is your concept? What were your goals? Why did you decide on this project form for your concept and goal?

The Fortune Teller: Using an arduino, arduino printer, and a copper capacitive sensor I want to be able to give people a fortune based on the “random” amount of particles the sensor reads. Inspired by Mary Poppins measurement tape that collects the input of height and gives a corresponding description, “Perfect in everyway” and Zoltar, I want to design a fortune teller that reads its participants touch and subsequently gives them a corresponding fortune.

Intended audience. Who is this for? Why did you choose this audience?

Given that my idea of a fortune teller utilizes a non-invasive sensor my intended audience is anyone who is conveniently available and interested in getting a fortune.

Precedents. Share any precedents that inspired you.

Since one of the main components, if not the, of my project is to be able “sense” some aspect of my participant(s) I needed a sensor that could do just that in a relatively quantifiable way. I considered using a TMP36 Temperature Sensor so when a participant would get near/ touch the fortune teller depending on the temperature the fortune would change. Upon further deliberation, I believe most people range within the same body temperature so I wanted to use a component that could sense something with more range. Tubah (a tutor) recommended a capacitive sensor.

  • TMP36 Temperature Sensor: Based on the principle; as temperature increases, the voltage across a diode increases at a known rate. By amplifying the voltage change, a output proportional to temperature can be produced.

The capacitor is a component which has the ability or “capacity” to store energy in the form of an electrical charge producing a potential difference (Static Voltage) across its plates, much like a small rechargeable battery. Capacity is very sensitive and can be affected from a variety of environmental factors making it’s output very inconsistent.  Accordingly, using this aspect to my advantage when touched all individuals can produce a unique capacitance… therefore fortune.

 

Description of the project. Discuss the process of creating this project. How does it work? What is the desired interaction?

This project is simple in its composition. It utilizes a single sensor, capacitive,  and a single mode of output, a printer. I started the project with the physical components; the capacitive sensor and then the thermal printer. I found different tutorials for physical component that related to the outcome I needed. For example the capacitive code I used had a pre-set threshold of a 1000 and utilized an LED to show that the capacity was being read correctly. These details came in handy when it was no longer plugged into a monitor that could read the resistance since the LED would alert me to if the capacity was being read correctly. My next step after the physical setting up that was connecting the two through the code; have the printer respond to a capacitance that passes a threshold and have ranges equal different “fortunes.” I originally wanted to design two plaster hands that had metal wire running through them thus becoming the capacitor. With this idea, the participant would put their hands in the fortune teller’s hand, mimicking the interaction of a stereotypical gypsy fortune reading, and get their fortune. Though after the Parsons 2 building accident, which affected the wet lab, I used garden wire wrapped together as the hand instead. Ultimately, the project was successful. I made a capacitive sensor that was able to read capacity through a metal-wire-hand and subsequently read that input and print the corresponding fortune through code in the Arduino. 

 

Process + Prototypes. Discuss the process of creating this project. Show your prototypes, playtests, sketches, interaction diagrams, and any other files that illustrate the tools you used. What challenges did you faced?

  • Capacitor: I began assembling my project starting with the capacitor. While I waited for the thermal printer to arrive this component was pretty simple to construct. Using online sources for the code and the Arduino capacitive library, I successfully was able to read the capacity of myself using aluminum foil as the sensor.
    • As seen through the video featuring the serial monitor, when the capacity passes a certain threshold (1000) the LED will turn on. Alone the capacity of the aluminum foil and the environment have stayed under the threshold, nevertheless the capacity has been changing frequently from 60s-90s to 250s-290s.
    • Materials:
      • Resistor (100k ohm)
      • LED (Red)
      • Breadboard
      • Arduino + USB cord
      • 3x Jumper Wires
      • Metal: Aluminum foil
    • Code:

 

  • Thermal Printer: Once the thermal printer arrived I was able to get started. Getting the thermal printer functioning using the example code and downloading the printer library was a success. Using the set-up tutorial Thermal Printer Setup went smoothly as well. As seen in the video I got the example receipt to print and the capacitor to work individually.
    • As iterated in the video, the next step for me is to combine the two codes and get the arduino to read the capacitor’s input and in response print the output.
    • Materials:
      • A mini thermal receipt printer
      • thermal receipt paper
      • 5V 2A power supply
      • 2.1mm DC jack adapter
      • supply to the printer
      • 3x MM jumper wires
    • Code:

  • Code: As someone who doesn’t know how to code I went to the LC for help getting started. Off the bat, I had 3 major goals; 1)Get the printer and the capacitor onto the same code 2) Get the printer to print when the threshold is met 3) Print a fortune based on the different ranges of capacitance. Starting with step 1, I met with Tubah and by the end of the session we got the capacitor, arduino, and printer connected. However, the printer was unable to print the correct symbols (we were testing with the arduino test barcode). Matter of fact it was printing an infinite series of illegible symbols. With this I added new goals to my list; figure out why the 4) illegible symbols was printing 5) why the printer is continuously printing.
    The following session I met with Aarati and we found that the illegible symbols was due to baud-rate and or Arduino syntax between softwareserial/ mySerial.begin and Serial.begin. This was also connected to why the serial monitor wasn’t responding. Once we got the printer to respond to the capacitor we found that the printer will continuously print because capacity is read in milliseconds when touched. A solution to this was to add a timer for when the capacitance passes the threshold. We did this and got the connecting code working perfectly. The next step was to make ranges of capacitance with corresponding fortunes and with the help of Aarati that was easy. We even included a component that changed the fortune depending on whether the capacitance number read was odd or even.

  • Finishing Touches:
    The soldering, wire hand, chipboard silhouette, and the robe were simple add-ons that made the final product look more polish.
  • What would you do in a future iteration?
    Towards the end of my project my arduino code was nearing the maximum memory capacity ergo a future iteration might use a Raspberry Pi and may also have a cleaner and more artful design on the print.
  • Assembly:
    • Capacitor & LED:
    • Starting with the capacitor and LED find the highest resistor you can grab, (I used 150.5K) and put it on the Arduino ~4pin and ~8pin
    • Use the dedicated power cable and connect it positive side of the LED and plug the other into ~7pin
    • Use the dedicated ground cable and connected it to the ground end of the LED and plug the other into GND on the Arduino.
    • Place the LED in the breadboard connecting them with the GND and power wires. 
      • Optional; Include 220 ohm resistor in breadboard. I ended up using one when I soldered the board, but it’ll work without it. 
    • Printer: Using the Arduino Thermal Printer Pack
    • Plug in the GND (black) and VH (red) F wires into the printer
      • Cut off the open end of the Red and black wires to expose the metal inside.
      • Using the DC adaptor put in the exposed black and red end of the wires
      • Make sure they are oriented correctly
    • Plug in the GND (black), RX (yellow) and TX (Green) wires into the printer
    • Using the 3 MM jumper wires attach them to the open end of the GND, RX and TX cord.
    •  components_cableextend.jpg
      • Insert the TX (green) wire into the digital ~5 pin of the Arduino
      • Insert the RX (yellow) wire into the digital ~6 pin of the Arduino
      • Insert the GND (black) wire into the GND (any of them) of the Arduino
      • components_printer-wiring.jpg
      • Download the necessary Libraries:
      • Code:
      • Copy and Paste my Code: (Feel free to edit how you like)
      • Thermal Printer and Capacity Code Final
        • #include <CapacitiveSensor.h>

          CapacitiveSensor cs_4_8 = CapacitiveSensor(4, 8); // 1M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
          #include “Adafruit_Thermal.h”
          #include “adalogo.h”
          #include “adaqrcode.h”

          int LED = 8;
          int buttonpin = 3;
          //FIND A 10K resistor! Check if this is still relevant.

          #include “SoftwareSerial.h”
          #define TX_PIN 6 // Arduino transmit YELLOW WIRE labeled RX on printer
          #define RX_PIN 5 // Arduino receive GREEN WIRE labeled TX on printer

          SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
          Adafruit_Thermal printer(&mySerial); // Pass addr to printer constructor
          // Then see setup() function regarding serial & printer begin() calls.

          // Here’s the syntax for hardware serial (e.g. Arduino Due) ————–
          // Un-comment the following line if using hardware serial:

          //Adafruit_Thermal printer(&Serial1); // Or Serial2, Serial3, etc.

          // ———————————————————————–

          void setup() {
          cs_4_8.set_CS_AutocaL_Millis(0xFFFFFFFF);// turn off autocalibrate on channel 1 – just as an example
          pinMode(7, OUTPUT);
          // pinMode(7, OUTPUT); digitalWrite(7, LOW);
          // This line is for compatibility with the Adafruit IotP project pack,
          // which uses pin 7 as a spare grounding point. You only need this if
          // wired up the same way (w/3-pin header into pins 5/6/7):
          pinMode(5, OUTPUT); digitalWrite(5, LOW);
          pinMode (buttonpin, INPUT);
          // cs_4_8.set_CS_AutocaL_Millis(0xFFFFFFFF);// turn off autocalibrate on channel 1 – just as an example
          // Serial.begin(9600);
          // pinMode(7, OUTPUT);
          // NOTE: SOME PRINTERS NEED 9600 BAUD instead of 19200, check test page.
          pinMode(LED, OUTPUT); digitalWrite(LED, LOW);
          Serial.begin(9600);
          mySerial.begin(19200); // Initialize SoftwareSerial
          //Serial1.begin(9600); // Use this instead if using hardware serial
          printer.begin(); // Init printer (same regardless of serial type)

          }
          void box(char *string) {
          uint8_t i, len = strlen(string);
          //printer.write(0xDA);//upper-left corner
          for (i = 0; i < len; i++)printer.write(0xC4);// Top Edge
          // printer.write(0xBF);// Upper-right corner
          printer.setSize(‘S’); //Size
          //printer.println();//NewLine/Feed
          //printer.write(0xB3); //left edge
          printer.print(string);
          //printer.println(sensor1); How to print the capacity ?
          //printer.println(0xB3);
          // printer.println(0xB3);
          //printer.println();//Newline/Feed
          // printer.write(0xC0); //Lower-Left corner
          for (i = 0; i < len; i++) printer.write(0xC4);//Bottom Edge
          //printer.write(0xD9); //Lower-right Corner
          printer.println();//NewLine/Feed
          }

          void loop() {
          long sensor1 = cs_4_8.capacitiveSensor(50);

          Serial.println(sensor1); // print sensor output
          //if(4999 % 3 == 0)

          if (sensor1 >= 4000) {
          digitalWrite(7, HIGH);
          delay(100);
          digitalWrite(7, LOW);

          if (sensor1 % 2 == 0) {
          // printer.println(F(“The world is your oyster+”));
          box(“The World is Your Oyster+”);
          } else {
          box(“You Are Special-“);
          }

          printer.println(F(“”));
          printer.println(F(“”));
          printer.println(F(“”));
          printer.feed(2);

          printer.sleep(); // Tell printer to sleep
          delay(3000); // Sleep for 3 seconds
          printer.wake(); // MUST wake() before printing again, even if reset
          printer.setDefault(); // Restore printer to defaults

          } else if (sensor1 >= 2950) {
          digitalWrite(7, HIGH);
          delay(100);
          digitalWrite(7, LOW);

          if (sensor1 % 2 == 0) {
          box(“Have Empathy+”);
          } else {
          box(“Don’t Be Too Manipulated By Emotions-“);
          }

          printer.println(F(“”));
          printer.println(F(“”));
          printer.println(F(“”));
          printer.feed(2);

          printer.sleep(); // Tell printer to sleep
          delay(3000); // Sleep for 3 seconds
          printer.wake(); // MUST wake() before printing again, even if reset
          printer.setDefault(); // Restore printer to defaults

 

 

Fortune Teller (Week 13)

Goal: The goal of this project, to create the fortune teller using an arduino, thermal printer and capacitive sensor is still the same. The last time I posted I had achieve connecting the capacitive sensor and the printer into a single code. However, I still had no been able to figure out how to get the printer to print is accordance to when the capacity passes the 1000 point threshold, or in other words, when the capacity is touched. Ergo, for this past week my 3 major goals/ obstacles to overcome.

  1. Figure out how to have the printer read and print according to when the capacitive sensor is touched.
  2. Code the arduino to be able to read the capacity and give fortune according to different ranges in the capacity. For example; 1000-1499 (“The world is your oyster”) and also be able to code for if the capacity read is even or odd for another layer of fortune telling.
  3. Have the printer print the fortune.

Assembly: So I made two appointments (knowing that I probably wouldn’t complete this in one day) at the Learning Center. Originally I was trying to connect the printer to print in accordance to the push of a button, but Tubah and I had a lot of difficulties with the button so we jumped straight into using capacity. Eventually by the end of the session we got it connected. However, the printer was unable to print the correct symbols (we were testing with a barcode) matter of fact it was printing an infinite series of illegible symbols. So with task #1 taken off the list I had simultaneously created 3 more.

I was able to conclude from my experience with the Serial monitor that a possible cause of the symbol affliction was due to baud-rate and or Arduino syntax between softwareserial/ mySerial.begin and Serial.begin. I also would have to code a way to make the Arduino read the first number of capacity and then pause so that it wasn’t continuously printing fortunes for the milliseconds a participant may be touching the capacitor. Lastly, the serial monitor was no longer printing the read capacity. I wanted to be able to see the capacity change on the serial monitor so that I could make capacity ranges for fortunes.

  1. Find out how to get the printer and the Arduino speaking the same language.
  2. Code the arduino to be able to read the capacity and give fortune according to different ranges in the capacity.
  3. Code the Arduino to read only the first number of capacity past the threshold and then sleep.
  4. Get the serial monitor to print the capacity
  5. Have the printer print the fortune.

The following Monday I met with another tutor at the Learning Center, Aarati. She was amazing and helped me find the problems in my code. My intuition was right, the baudrate for the printer was changed from 9600 to 19200, which allowed the printer to be able to read the code and print correctly. Tangent from this, with small changes to the syntax of the code we were able to get the Arduino and the serial monitor to connect on the right level, thus presenting the capacity in the monitor. Lastly we even finished early enough to add in an “odd and even” if-else statement to the fortune code allowing for if the capacity if even an “evil fortune” if the capacity is odd a “nicer fortune.”  

How it works:

This is intro code to how the Fortune Teller tells it fortune. By defining several specific ranges of capacity I am able to tell the printer to print an according fortune.

The ranges I have thus far:

Capacity >= 1999 — Fortune
Capacity >= 1750 — Fortune
Capacity >=1499 — Fortune
Capacity >=1250 — Fortune
Capacity >= 1000 — Fortune
Capacity == 666 — Fortune

Materials:

  • A mini thermal receipt printer – with cables and plastic mounting shims
  • A roll of 50′ long thermal receipt paper – the perfect amount for the thermal printer. BPA-free.
  • 5V 2A power supply – an ideal supply for powering the thermal printer (and anything else that can use 5V power
  • 2.1mm DC jack adapter – makes it easy to attach the power supply to the printer
  • 6x MM jumper wires –
  • 1x LED
  • High Powered Resistor

My next step of this process is now to construct the the fortune Teller itself, solder a new clean board and clean the code up a little.

Some of my new goals are:
1) Find a way to add a text box around the code
2) Possibly make the presentation of the fortune a little more aesthetic
3) Build a nice sturdy stand to hold to box up right.
4) Make a robe and hand.

Thermal Printer Library

Thermal Printer

Thermal Printer Setup  

  • Assembly:
  • Plug in the GND (black) and VH (red) F wires into the printer
    Cut off the open end of the Red and black wires to expose the metal inside.
    Using the DC adaptor put in the exposed black and red end of the wires
    Make sure they are oriented correctly
    Plug in the GND (black), RX (yellow) and TX (Green) wires into the printer
  • Using the 3 MM jumper wires attach them to the open end of the GND, RX and TX cord.
  • Insert the TX (green) wire into the digital ~5 pin of the Arduino
  • Insert the RX (yellow) wire into the digital ~6 pin of the Arduino
  • Insert the GND (black) wire into the GND (any of them) of the Arduino
  • Highest Resistor (150.5K) ~4pin and ~8pin
  • Power Cable LED ~7pin
  • Ground Cable LED GND.
  • Download the Thermal Printer Library
    Change the baud rate from 19200 to 9600 by accessing the source code.
    If your printer test page shows ‘BAUDRATE: 9600’, you’ll need to make a small change to the library source code.
    Go into your computer files where the  Thermal Printer Library is being stored and using a text editor (Notepad, etc.) open the file Adafruit_Thermal.cpp
    Ctrl-F ‘BAUDRATE’ and change this line from 19200 to 9600.
    Save and exit.

Play Test: Fortune Teller (Week 12)

Goal: The next part of my prototype for my fortune teller was to get the Arduino thermal printer functioning and I did. With that being said the components of just the play-test for the thermal printer include;

  • A mini thermal receipt printer – with cables and plastic mounting shims
  • A roll of 50′ long thermal receipt paper – the perfect amount for the thermal printer. BPA-free.
  • 5V 2A power supply – an ideal supply for powering the thermal printer (and anything else that can use 5V power
  • 2.1mm DC jack adapter – makes it easy to attach the power supply to the printer
  • 3x MM jumper wires

Assembling the thermal printer was a little challenging due to the site leaving out some essential pieces of information like how/where the F jumper cables for VH, GND, RX and TX are supposed to be oriented as well as the key instruction to strip the VH and GND wires to connect to the DC cable adaptor. However, lucky for me I had a friend who had experience with the Arduino thermal printer and was able to guide me through it.

Assembly:

  • Plug in the GND (black) and VH (red) F wires into the printer
    1. Cut off the open end of the Red and black wires to expose the metal inside.
  • Using the DC adaptor put in the exposed black and red end of the wires
    1. Make sure they are oriented correctly
  • Plug in the GND (black), RX (yellow) and TX (Green) wires into the printer

  • Using the 3 MM jumper wires attach them to the open end of the GND, RX and TX cord.

  • Insert the TX (green) wire into the digital ~5 pin of the Arduino

  • Insert the RX (yellow) wire into the digital ~6 pin of the Arduino

  • Insert the GND (black) wire into the GND (any of them) of the Arduino

  • Download the Thermal Printer Library
  • Change the baud rate from 19200 to 9600 by accessing the source code.
    1. If your printer test page shows ‘BAUDRATE: 9600’, you’ll need to make a small change to the library source code.
    2. Go into your computer files where the  Thermal Printer Library is being stored and using a text editor (Notepad, etc.) open the file Adafruit_Thermal.cpp
    3. Ctrl-F ‘BAUDRATE’ and change this line from 19200 to 9600.
    4. Save and exit.

Though since this code has components that conflict with my capacitive sensor code I needed to make some adjustments. I changed the RX (yellow) input pin from ~6 to ~3.

Problems/Issues: Originally when I did this (change the pin from ~6 to ~3) the LED light and the capacity was working however after I tested the printer the LED no longer responded to the capacitor. Though, as stated in the video, the LED light isn’t essential to the project it is still a sign that there might be a problem with the physical system itself. As of right now I am looking at ways to integrate the capacitive code into the thermal printer code, but as a novice in coding I’m not sure how to do this syntactically correct. I have an appointment Friday (4/20 lol.) with the Learning Center to help me over this part of the project.

Play-Test Feedback:

To think about:

  • Who will you playtest with? I will playtest with anyone who is available and willing. There is not criteria or prerequisite that needs to be met by the participants.
  • How will you get their consent? Their willingness to touch the capacitive sensor is all that is necessary.
  • What feedback do you want? I want people to experience a mediocre serendipity. It’s the equivalent to a fortune cookie so I have kind of low expectations on their reactions.
  • What questions will you ask? I will ask whether they enjoyed their fortune and if they have any ideas on how I could enhance the experience and output.
  • What information do they need to know before starting? None.
  • How much will you help them during the test? I will tell them to touch the pad.
  • How will you debrief them? I will tell them that this is my final project for a class and that is it an interactive art piece.

 

Thermal Printer Library

Thermal Printer

Thermal Printer Setup  

Week 10: Project Timeline

  • Refined project description:

 

The Fortune Teller: Using an arduino, arduino printer, and a copper capacitive sensor I want to be able to give people a fortune based on the “random” amount of particles the sensor reads. Inspired by Mary Poppins measurement tape that collects the input of height and gives a corresponding description, “Perfect in everyway,” I want to design a fortune teller that reads its participants touch and subsequently gives them a corresponding fortune.

 

  • Interaction/systems diagram

 

I realize that capacitive sensors are widely unstable and inconsistent due to the incessant need for recalibration, but that is why I chose them. I like the random number of capacity because it considers so much; height, weight, if you just ate a lot, rubber shoes, lots of metal jewelry, and it able to reduce all this information to a “clean” and “concise” number.

Since I haven’t made the capacitive sensor yet I do not know the range return of capacitance number, but I acknowledge that I will have to code different responses if the number passes different thresholds. I imagine creating a mad-libs like formula for variables to be inputed depending on the number.

YOU *(ARE vs. NEED)* *(NOUN)*
Dependent on if the return variable is an odd or even number. Hopefully I can find a noun/ word library and have certain return numbers correspond to a word.

 

 

  • Timeline with milestones

 

Week 10:

  • Buy materials
  • Meet with learning center to compose the code
  • Connect Capacitive Sensor with Arduino

Week 11:

  • Connect Capacitive Sensor & Arduino with the Printer
  • Look for work library (noun)
  • Code the library and printer
  • Make plaster hand(s)

Week 12:

  • Begin to compose the entire project
    • Get/make a cloak
    • Make a stand

Week 13:

  • Final Touches

 

  • Materials list:

 

 

  • Precedents or references

 

  1. Use smoothing in your code.

If you followed the tutorial in step 3, you’ll notice that the signal from a cap sensor can be highly erratic. Therefore it’s a good idea to use some kind of smoothing function in your code. We used this one and it did a great job in stabilising the signal.

  1. Control as much of the environment as possible.

Everything from air humidity to electromagnetic noise to someone touching a cable will affect the signal strength. Eliminate as many variables as you can. Using shielded cables and making sure no other electronic equipment is operating in the immediate vicinity are two easy precautions you can take. Solid grounding will also reduce interference.

  1. Bigger surfaces = bigger signals.

The bigger the surface area of your sensor, the stronger your signal will be. A big surface area is also better for triggering the sensor at a distance.

 

http://www.instructables.com/id/Capacitive-Sensing-for-Dummies/

http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense

https://www.arduino.cc/en/Reference/Libraries