Fabrication: Entry 2

Warm-up project.

I spent most of the past three weeks learning about how Arduinos work and howTwitter’ss API can be utilized. Unfortunately, I underestimated the amount of debugging that would be required for the final assembly as well as the consistency of learning materials out there. Initially, I attempted to build from Sparkfun’s LED-connected Cloud but I decided against that and instead tried to recreate a twitter reader using the same setup. I was able to get the code to where I believed it would work and relegated the Twitter API and parsing to a web server.

The web server was actually the easiest part as most of the code was already written by someone else here. (Thank God for good documentation). Unfortunately, I cannot put it in here due to WordPress being written in PHP as well.

For the Thing, I used the HTTPClient and WiFi libraries from ESP8266, the chip on the Thing. The Thing would ping my web server every 5 seconds and the server would respond with the number of seconds since the last twitter I sent.

// Included Libraries
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

void setup() {
     // put your setup code here, to run once:
     // Set up Wifi
     Serial.begin(9600); //Serial connection
     WiFi.begin("", ""); //WiFi connection
     while (WiFi.status() != WL_CONNECTED) { //Wait for the WiFI connection completion
          delay(500);
    }
}
void loop() {
     // put your main code here, to run repeatedly:
     if(WiFi.status()== WL_CONNECTED){ //Check WiFi connection status
          HTTPClient http; //Declare object of class HTTPClient
          http.begin("http://api.akierson.com"); //Specify request destination
          http.addHeader("Content-Type", "text/plain"); //Specify content-type header
          int httpCode = http.GET(); //Send the request
          String payload = http.getString(); //Get the response payload
          http.end(); //Close connection
          // Send out to LED
         Serial.write(payload.toInt());
         Serial.write("\r\n");
    }
    delay(5000);
}

The Mini would then take the Serial input and put it to the LEDs as the number of lit up LEDs.

#include 

// Pin definitions
#define CLOUD_A_PIN       6

// Number of lights, pin number (6), 
Adafruit_NeoPixel strip_a = Adafruit_NeoPixel(60, CLOUD_A_PIN, NEO_GRB + NEO_KHZ800);

int ledsLit;

void setup() {
  Serial.begin(9600);
  
  // Configure LED pins
  pinMode(CLOUD_A_PIN, OUTPUT);
  pinMode(8, INPUT);
  
  // Clear LED strips
  strip_a.begin();
  strip_a.show();
}

void loop() {
  char outputLED[3];
  char inChar;
  int index = 0;
  while(Serial.available() > 0)
  {
      if(index < 2) // One less than the size of the array { inChar = Serial.read(); // Read a character outputLED[index] = inChar; // Store it index++; // Increment where to write next } outputLED[index] = '\0'; // Null terminate the string } String input = String(outputLED); if (input.toInt() > 0){
    ledsLit = input.toInt();
  }
  int i;
  for(i=0; i < ledsLit; i++){
    strip_a.setPixelColor(i, 127, 127, 127);
  }
  for(i=ledsLit; i < 60; i++){
    strip_a.setPixelColor(i, 0, 0, 0);
  }
  delay(2500);
}

The physical creation was surprisingly easy to create from the supplied schematics and I assumed that the original creators would use some standard practices with their schematics. Unfortunately, they didn’t use the attached serial pins and opted for digital ones and their images of the project didn’t match the schematics. The final problem I ran into was the power supply. A 5V 4A power supply is hard to find. Luckily, I was able to find one at the last second in my junk drawer.

Ultimately, this project was a failure for me as I have no experience with electronics and the jargon surrounding it. I also severely underestimated how long debugging would take when using physical components. I think, given another few attempts, I will be able to create a functioning prototype.