Star Trek Tricorder

My main project at BlueStamp Engineering, a STEM summer camp for kids and teenagers in New York, is modeled after the Star Trek Tricorder. Basically, the Tricorder has multiple sensors whose data are interpreted by an Arduino Nano and sent/displayed to a TFT touchscreen. The user can interact with it to view current conditions to learn more about their environment.

Engineer

Mark C.

Area of Interest

Programming

School

Regis High School

Grade

Incoming Sophomore

Reflection

Before I went to BlueStamp Engineering camp, I had some robotics and general coding experience. However, I had little electrical engineering knowledge nor any idea on how to code an Arduino. I also knew little about what Arduinos did and nothing about breadboards. At BlueStamp Engineering, I first learned about soldering, which I also knew little about before. I then learned from experience and from my instructors how to get better at wiring sensors and coding an Arduino. Soon I got better at coding in the Arduino IDE and completing circuits between peripherals (such as sensors or the screen) and the Arduino Nano. Eventually, I also got more real-world experience with troubleshooting, debugging, and problem-solving. My student-defined sci-fi Star Trek Tricorder required a lot of wiring, coding, and problem-solving, which definitely expanded my view and experience/confidence/familiarity with working with similar parts/engineering/coding. I had a fun learning experience at BlueStamp and I will probably continue to utilize my skills in engineering and coding similar projects. Since I am only a rising sophomore, I am still not sure whether I will pursue electrical engineering, mechanical engineering, coding/computer science, or a similar field professionally in the future. I am certain whether I do electrical engineering or something similar, I will enjoy what I do. I will remember what I learned and experienced at BlueStamp Engineering about coding, engineering, and perseverance.

Final Milestone

Hardware 100%
Code* 95%
Design* 90%
Functionality 100%
Overall 95%

Major Details:

My final milestone for the Star Trek Tricorder at BlueStamp Engineering camp was displaying more sensors’ data to the screen and wiring and testing a thermal camera to display to the screen (see Figures 1 through 4).  The screen now will display data from the photocell and UV sensor and is color coded based on their readings. The screen will also display data from the GPS. I can also display the thermal camera to the screen (see Figure 4) by uploading a different code* (see Figure 6) to the Nano. The thermal camera and the UV sensor both require the same pins on the Arduino Nano (the SCL – clock – and SDA – data – pins), so I wired them to a CD4053BE multiplexer and wired the multiplexer to the Arduino. Multiplexers or muxes are devices that have multiple inputs connected and sends them into one output by switching between them according to how it is coded. To learn more about multiplexing in general, click here and click here for a tutorial for multiplexing with an Arduino (slightly different multiplexer, similar concept). This multiplexer is a triple two-channel multiplexer, meaning that it can have up to three sets of two inputs and wire each set into one output. For my purposes, I have it wired so that one sensor can be read at a time based on the value of a certain pin that I coded correspondingly to select the corresponding sensor.

About the code:

Similarly to the third milestone, the code (see Figure 5) will initialize with the same home screen that detects for whether the touchscreen was pressed and run a function corresponding to what was pressed. Additionally, the code will change the screen color based on the UV index for the UV sensor and brightness for the photocell. The thermal camera code (see Figure 6) will run the thermal camera and print colors to the screen based on the temperatures the camera detects. I coded the Nano to switch between reading the thermal camera and the UV sensor by writing:

pinMode(6,OUTPUT);
digitalWrite(6,value); //value can be LOW or HIGH - low for thermal camera, high for UV

Overcome Challenges:

  1. One problem I encountered was working with the multiplexer. When I was trying to switch between the two sensors, I would get a completely incorrect reading – sometimes it would read 0 and sometimes random numbers. I solved this by initially manually switching the mux select pin between positive and negative until I coded the Nano to do this for me, including right before the sensor is initialized.
  2. Another problem I encountered was that I wrote too much code. The Nano only has a limited amount of memory, so too much code would be problematic. This was highly problematic because I still decided to run this code despite the warning, “Low memory available, stability problems may occur” in the Arduino software compiler. “Stability problems” did occur – the program ran very slowly, strings (phrases that I programmed to print) were replaced with other strings, and eventually the Nano froze and would not accept any new code. I solved this by replacing the Nano and condensing the code before uploading it to the new Nano.
  3. A third problem I encountered was when I tested the thermal camera. When I adapted the example code to test the thermal camera with my screen (not the screen in their code), the screen refused to respond. Eventually I realized that when I changed the code for my screen, I forgot to add a line to initialize the screen, which fixed the problem.

*A note on the progress bar and what is next:

You may have noticed that some of the values (code and design) were not set to 100%. I planned on making a container 3D printed with the 3D files from the previous milestone to hold the Tricorder. However, because of time restraints, I could not complete this yet and I will do this or make a similar container later. I also planned on making the thermal camera accessible through the main code. Unfortunately, there is too little memory on the Nano to do this. Therefore, I will condense the code later to allow for room for more functionality, including the thermal camera.

Figures:

Figure 1: final milestone at bluestamp engineering

Figure 1: this shows the various sensors (including the new thermal camera), the Arduino Nano, and the screen powered by the battery.

Figure 2: schematics

Figure 2: this is the new schematic of the Tricorder. This schematic now features the thermal camera and the UV sensor wired to the multiplexer, which is connected to the Nano.

Figure 3: thermal camera and multiplexer

Figure 3: this shows the thermal camera (left) and the CD4053BE multiplexer (right).

Figure 4

Figure 4: this is the thermal camera’s output displayed on the screen when my hand is held above the thermal camera.

Click here to view my Bill of Materials (BOM)

Third Milestone

Hardware 60%
Code 60%
Design 80%
Functionality 65%
Overall 65%

Major Details:

My third milestone for the Star Trek Tricorder at BlueStamp Engineering camp was coding a touchscreen interface that displays temperature/humidity data when pressed (see Figures 1, 3, and 4), 3D CADing (computer-aided designing) a body to hold everything (see 3D models below), and attaching to the screen and testing a microSD card (see Figure 2). The 3D CAD files will be 3D printed and assembled by the Final Milestone. All parts will be placed within the 3D printed objects.The sensors will be able to work correctly with doors that will be able to open and close. The CAD files were mainly from https://www.thingiverse.com/thing:1701113 , but I did modify them, especially for size, using Blender.

About the code:

This code will display a white screen with green boxes and blue text that is centered (see Figure 4). Since there is no default way to center text, I created a function that takes in its location relative to the boxes and the length of the text to center the text:

unsigned long cursor1(int numb_right,int numb_up, int stringlength){
//numb is number of rectangles, stringlength is length of text
tft.setCursor(BOXSIZE_w *(numb_right-0.5) -(3*stringlength*3), BOXSIZE_h *numb_up);
//only works with default font, change (textsize*stringlength*3) for different text size (currently size is 3)
}

The code has the touchscreen detect for touch in any of the boxes. Here is an example for detecting for the box for the temperature/humidity (DHT) sensor:

else if ((p.y < (BOXSIZE_w /1.57)) && (p.x < (2*BOXSIZE_h*1.5))){ //p.x and p.y are coordinates for where is pressed 
    Serial.print("DHT");
    dht_selected = true;

The boolean “dht_selected=true;” triggers this statement –

while (dht_selected == true){
  dht_c();
}

– running the function “dht_c();” which displays DHT sensor data on the screen with color changes based on the heat index. As of now, I only programmed the screen to display DHT data.

Overcome Challenges:

  1. One problem I overcame was drawing objects to the screen and then detecting touch from those coordinates. The problem was the graphics originated from the top left corner while touch originates from the bottom left corner. I accounted for this by changing the code accordingly.
  2. Another problem I encountered was when the code checked if a particular part of the screen was touched. The problem was wherever I pressed on the screen, it pulled up the DHT sensor (even when it was not hit).I solved this bug by changing while statements from
    while (dht_selected = true){
      dht_c();
    }

    to

    while (dht_selected == true){
      dht_c();
    }

    (changing “=” to “==” fixes this code).

Milestone Reflection:

Overall, this was an interesting and fun milestone to complete. I coded a lot for the interface of the touchscreen, which I enjoyed but still can continue progressing and modifying the code. Also, I had to deal a lot with numbers and calculations when I CADed, even though I did not start from scratch with CADing.

Figures:

Figure 1: screen

Figure 1: this is the screen with the new code

Figure 2: updated schematics

Figure 2: this is the updated schematics, updated for accessing the microSD card slot

Figure 3: DHT sensor data with new code

Figure 3: this is example data from the temperature/humidity sensor with the new code

This is the back.

This is the bottom.

This is an outer side panel.

This is the front door pull tab.

This is the frame.

This is the hood.

This is the hood’s side plug.

This is the large front door.

This is the left side panel.

This is upper horizontal support.

This is another side panel.

This is the top vertical wall.

This is the small front panel.

This is the screen holder.

This is the right side panel.

This is the middle divider.

Second Milestone

Hardware 60%
Code 30%
Design 25%
Functionality 55%
Overall 45%

Figures:

Figure 1: my 2nd milestone at BSE STEM camp

Figure 1: The Tricorder from milestone 1 wired up and powered by a battery can be seen above.

Figure 2: schematics

Figure 2: The updated schematics above now includes the PowerBoost 1000C and the LiPo battery.

For my second milestone for the Star Trek Tricorder at BlueStamp STEM coding and engineering camp, I attached a rechargeable LiPo battery to the Tricorder (see Figures 1 and 2) so that it can be powered without being connected to a computer. The lithium ion polymer battery (Adafruit 328; see Figure 3)  can give an output between 3.7V and 4.2V. The battery has a maximum capacity of 2500 mAh for a total of ~10Wh. The battery has a 2-pin JST-PH connector that connects to the Adafruit PowerBoost 1000 Charger (see Figure 3). The PowerBoost accepts power from the battery and powers the Tricorder via a USB connected to the Arduino Nano. The PowerBoost can be turned on/off with a single-pole, double-throw (SPDT) slide switch (see Figure 3) via the PowerBoost’s enable (EN) pin.  The switch will signal the EN pin to turn the PowerBoost on/off and therefore the switch will not have to carry any power. Since the switch has three pins, the other two can attach to VS (load shared output from the battery) and GND (ground). A separate micro USB port at the back of the PowerBoost can charge the battery and/or power the Tricorder.

I moved along very quickly with this milestone – I finished it within an hour or two. I discovered that it was very easy to make something, such as this project, powered by a battery. This milestone did not even require any coding – it was simply soldering header pins, attaching a slider switch, and connecting the PowerBoost via a USB to the Arduino Nano. This also shows how I have become more used to working with hardware and circuits in a timely manner.

Figure 3

Figure 3: Above is the LiPo battery connected to the PowerBoost 1000C. The battery is currently charging, as indicated by the orange light on the bottom of the PowerBoost. The PowerBoost 1000C is attached to the Tricorder via a USB. The switch is set to the off position; therefore, the Tricorder is not receiving any power.

First Milestone

Hardware 50%
Code 30%
Design 25%
Functionality 50%
Overall 40%

Figures:

Figure 1: my 1st milestone at BSE coding and robotics camp

Figure 1: This picture shows my first milestone for the Star Trek Tricorder, including the TFT screen, UV sensor, temperature/humidity sensor, photocell, GPS, and Arduino Nano.

Figure 2: sensors

Figure 2: This picture shows a close-up of the UV and GPS sensors and the photocell.

Figure 3: Arduino Nano

Figure 3: This picture shows a close-up of the Arduino Nano.

Figure 4: DHT

Figure 4: This picture shows a close-up of the DHT22 temperature/humidity sensor.

Figure 5: schematics

Figure 5: This is the schematics for the Star Trek Tricorder.

Major Details:

My main project at BlueStamp Engineering STEM summer camp is the Star Trek Tricorder, which features many sensors displaying data to a screen. For my first milestone, I connected GPS, UV, photocell, and temperature/humidity sensors to an Arduino Nano (see Figures 1 through 5). I programmed all sensor data except for the GPS to display to a TFT Screen. The Arduino Nano (see Figure 3) interprets data from the sensors and controls the screen by storing and executing code that I wrote. By default, many of these sensors transmit/receive data at the speed of 9600 baud, or 9600 bits per second, so I programmed the Nano accordingly. I prototyped the circuit on a breadboard. The Nano provides 5V of power to everything and accepts both power and data from a USB B mini cable. For the Nano, many of the sensors, and the screen, I had to solder header pins to them to make wiring/prototyping them with a breadboard easier. The Adafruit DHT22 (see Figure 4) is a digital temperature and humidity sensor that uses a capacitive humidity sensor and a thermistor. The capacitive humidity sensor detects and measures the conductivity of air, and the thermistor is a resistor that changes resistance based on temperature. The temperature sensor then sends out a digital, not analog, signal back to the Arduino Nano. Unfortunately, the temperature sensor only updates every two seconds with new data. The Adafruit photocell (see Figure 2), also called an LDR – Light-Dependent Resistor – or a photoresistor, is a resistor whose resistance varies based on the amount of light shining on it. The photocell’s data is sent back to the Nano via an analog pin. An analog pin can read the photocell’s infinite values, while if it were digital, only a certain range of values could be read. The Adafruit SI1145 UV Sensor uses visible and IR light from the sun to calculate the UV index. UV light, or ultraviolet light, is invisible to human eyes but affects people by allowing us to produce vitamin D. However, exposure to excessive amounts of UV light can lead to sunburn. The UV index is a measure of UV; a reading of 0-2 is low, 3-5 is moderate, 6-7 is high, 8-10 is very high, and 11+ is extremely high. This UV sensor uses the I2C communication protocol, also called the Inter-integrated Circuit Protocol, The I2C protocol allows a “master” chip to communicate with multiple “slave” chips. I2C is mainly intended only for short distance communication within one device and only requires two signal wires to exchange data/information. To utilize the I2C protocol, I connected the UV sensor’s SCL pin to the I2C clock master pin on the Nano (A5) and SDA to the I2C data master pin (A4). The SCL pin is the UV sensor’s I2C clock pin and is used to send signals at specific times. The UV sensor’s SDA pin is its I2C data pin. The Adafruit Ultimate GPS Breakout Version 3 (V3) tracks up to twenty-two satellites on sixty-six channels to determine its location. I connected the GPS’s TX pin to transmit data from the GPS to the Arduino Nano and RX to transmit data from the Arduino to the GPS. The Adafruit 3.5” TFT 320×480 + Touchscreen Breakout Board w/MicroSD socket (HXD8357D) is a color touchscreen LCD with a microSD socket and has two modes. The first mode is 8-bit mode, which is faster but requires more data pins with this screen. The other mode is SPI mode, which is slower but requires less pins for this screen and allows access to the microSD socket. I decided to use SPI mode to be able to access the microSD socket. I soldered the screen’s IM2 jumper closed to tell the screen to use SPI mode. Then I wired the touchscreen (see Figure 5).

About The Code

To read data/test each sensor, I mainly used the provided example code in the Arduino IDE provided by Adafruit (see Figure 6). To do this, I also had to download and install the provided libraries and import them into the Arduino IDE. However, for the main code that displays most sensor data to the screen, I combined and heavily edited example code, as seen in Figure 7 (currently collapsed).

Overcome Challenges:

  1. I encountered one problem when displaying new data, since printing this data to the screen will overlap with previous prints and will overlap. After several other failed attempts, I set the screen to fill with the background color and then print new data. The screen currently refreshes with new data every two seconds because the temperature sensor updates every two seconds and because otherwise it would be too fast for anyone to see.
  2. Another problem I ran into was how to display data from the sensor onto the screen. The problem I encountered was I referenced variables defined in one function in another function which the program would not recognize, so I defined the variables at the top of the code outside of any conflicting functions.
  3. I encountered a third problem when I tested the GPS. Unfortunately, it probably does work but I discovered that since I was testing indoors, the GPS couldn’t “fix” on any satellites. I’ll have to test it outdoors/somewhere else another time.
  4. A fourth problem I encountered was with the touchscreen functionality. When I ran the example code, it only said it was detecting touch near the bottom of the screen even when not being used. I eventually determined that the pins used for wiring it were important even if I changed it in the code correspondingly and therefore I had to rewire it to fix it. I therefore learned to follow the documentation correctly since each pin may have a specific and necessary function for something to work.
Figure 6

Figure 6: This is an example serial output of UV sensor data.

Figure 7 (collapsed): This is the source code used in the first milestone.

MiniPOV4

My starter project at BlueStamp coding and robotics camp was the MiniPOV4 (Mini Persistence of Vision/Light Painting Kit). This project has 8 LEDs that create an image visible when moved quickly through the air. LEDs are diodes – electrical components that only allow electrical current to flow in one direction – that specifically emit light (Light Emitting Diodes). One major component that allows this device to function is a programmed 8-bit microcontroller with a 28 pin socket that accepts an image from a computer via the USB B-type Jack and controls the LEDs. Resistors (2.2k and 47 ohm resistors) are used to control/resist the flow of electricity, which is useful for the LEDs. This device also uses capacitors, which are electric components that store charge. The ceramic and two electrolytic capacitors used in the MiniPOV4 stabilize the input and output voltages (electrical potential energy). Transistors are semiconductive devices that either amplify or switch electric signals/power. The three transistors used in this project control the three colors (red, green, and blue) of the LEDs. This device also has a potentiometer, which is a type of resistor that rotates to adjust the voltage; here, it is used to adjust the speed of the LEDs. A crystal oscillator has a crystal vibrating at a certain frequency, which is used in this project as a timekeeper for the LEDs. This project specifically used a 12 MHZ crystal. There are also two zener diodes, which reverse voltage at a critical value and here keep voltage stable for the USB interface. Finally but very importantly is the battery pack that has three AAA batteries to power the device.

Overall, this project was a fun intro to soldering. However, I did run into several problems in assembly. One problem was the 8th LED did not turn on. At first I checked  with a multimeter to see if it was getting power – it was. Next I replaced the LED without any results. Finally I looked at the microcontroller and realized several legs were bent and not connected to the socket, so I detached and reattached it. Another problem was the wires connecting the device to the battery broke, so I had to desolder and resolder it together.

Leave a Comment

Start typing and press Enter to search

Bluestamp Engineering