Steeph's Web Site

Go To Navigation
Show/Hide Navigation

Entries tagged 'cat:DIY'

Case Modding

I used to be somewhat of a casemodde in the early to mid 2000s. That's kind of the style of casemodding that I still like today. We used to shun people who buy ready parts or cases instead of building parts and modding cases themselves. I especially was an advocat of building things from materials that could be found on the street or in scrap containers or were otherwise free to aquire. Maybe just because i didn't have any money, didn't know many people who had enough money to simply buy materials and tools and didn't foresee a future where I was able to simply buy anything I needed to build something. To this day I like using leftovers, scrap and otherwise free materials to build things. I think I wasn't aware of that in the 2000s; but which case mods I like how much is to a large degree determined by how scrappy the building materials were and how simple the tools were. I wasn't usuially trying to build something that looks slick and exactly like planned, but something that looks unique and cool, and maybe extraordinary.

Here are a few examples of things that I did to cases of mine that I liked.

(I'll pick out photos of these examples at some point, maybe. I haven't yet.)

Coloured foil window

Making a whole in the left wall of a tower case is probably the most common case mod. There were various window kits to make it easy to get to a clean-looking result. I didn't care for those for a long time. Instead of bying any material to create a window in my case, I used what I had: a dremel-like tool with a cutting disk and some red polymere foil an old text book used to be covered with. If I remember correctly, my mother bought this book used one year for my new school year instead of getting the current version. The previous owner had a red protectie cover around it. Eventually one of the seams ripped and the cover slid off every day. So I left the cover off. It was translucent. A unique material, I thought. So I kkept it in case I wanted to build something with it some day. The case I used it for used to house a generic 286. I put a 586 in it, I think. In the early 2000s that was just an old, very slow computer, not a #RetroComputing statement. I glued the sheet to the steel case from the inside after removing the burr and abraded the edges with a used corner of some sand paper. With bright cold lights inside you could sort of look inside the case. But it was mainly for style. The rest of the case was covered in some tape that I found at some building site once. That way the cut edges didn't look too rough. It certainly was a unique look. I still like the style of that case.

Plastic hose IDE and floppy cables

Ribbon cables, such as they were used for IDE, floppy drives and SCSI, used to be impossible to tuck away nicely. Round cables, such as pretty much all cables that are connected externally, can be clipped almost anywere. Wide ribbon cables need to be folded to wire them cleanly. That doesn't even work well if the case and all parts are designed for it, which they never are. In most PCs those cables used to be just left hanging around, blocking airflow and view. Some PC manufacturers used to cut the ribbons into five or six parts and fixed them with a stacked position with cable ties. That looked much cleaner. And suddenly round IDE and floppy cables became a thing. The connectors were the same. But inbetween they weren't ribbon cables anymore because the individual wires were split up and shrouded in a plastic tube. Those cables were more flexible and usually more colourful than conventional IDE cables. Again, you could buy them. But until the day I got a set with a motherboard that I bought, I didn't want "factory made" round IDE and floppy cables. I made my own by splitting up ribbon cables and stuffing them through an old shower hose or a piece of a garden hose. Not as flexible, but just as practical as bought ones.

Aluminium tape wrap

I don't know where I got it. But I had enough wide aluminium tape to cover an entire mini tower on the sides and the top. To cover up the imperfect edges I used red electric tape. So almost the entire case was striped red and silver at an unusual. Simple, no cost for me in that case, and quickly giving a nice, retrofuturistic look to a before boring, grey mini tower.

IC exterior

Another idea that I once had was to use all the ICs (at least those that were at least 1 cm wide) from all those defective motherboards and extension cards that accumulated over the years. People would bring and I would pick up so much old PC hardware that others didn't need anymore. Often the reason was that at least some part had a hardware defect, in which case I usually gave up my hopes to get it working again. I had an entire wall covered in old motherboards at one point. Much of this stuff was from the mid-90s or older and therefore not worth keeping intact even if it was in a great condition when I got it. Eventually there were just too many unused and defective cards and other boards and I decided to recycle their ICs before I got rid of what I thought I'd never want to even look at again. I cut off all those ICs with a knife (only SMD chips), covered the right side of a big tower in double-sided adhesive tape and neatly placed one next to another. Sometimes I used chips smaller than a cm to fill gaps. Not even half of the side got covered. I tried to get more from other people who wanted to throw stuff away. But what I got didn't bring me close to covering even the one side. My idea was to cover all the sides. I realised I had to pay money to get enough even broken electronics to finish the case. That wasn't beside the idea. Also it didn't feel right to use just any old ICs. It was supposed to be a PC chip case. I never finished the case. Unfortunately I didn't have the idea to make the IC field transition into something else, like a solid colour, even just the gray the case was before. Or maybe I didn't want to dso that. Nowadays I have some ideas where I could possibly get trunkloads full of ICs that I assume aren't recyclable otherwise. Maybe I wouldn't use a big tower if I'd ever started this again.

Sofa PC

I had a sofa in my room. I don't remember where I got it. I probably picket it up from the street after somebody got rid of it. At the time I was thinking about andd experimenting with getting a PC very quiet, if not silent, without compromising on performance. This was a much more prevalent topic at the time, because CPUs used more and more power with every new model (peaking in the Pentium 4, which is famous for needing much more than 100 W at the clock speeds it was marketed for being able to run at). CPUs power consumption wasn't throttled in as many ways as they are today. Coltage was usually fix, so it needed to be as high as you needed it to be at peak performance moments. Clock usually couldn't be changed dynamically. The CPU couldn't switch parts of itself off when it didn't need them. And the power it consumed it needed for its single core; so there was no core to shut down, either, in idle moments. Other components usualy also used more power than they do today. Motherboards were built by more individual ICs, chipsets didn't idle well either, voltage regulation wasn't as efficient for performance CPUs, hard disks needed more power than even today's spinniung hard disks. Automatic, temperature-based fan control wasn't as advanced either when you wanted to regulate it for a chip's temeperature, and you had to place the sensor not only outside of the chip, but usually outside of the cooler. And I wanted to have a surver run 24/7. I was actually running a few services on the internet from my bedroom at the time, of which one was used and relied on at a daily basis. So, what I came up with was to build a PC into my Sofa. It had thick foam padding and a cotton filling, which made it sound proof at least to lover frequencies. I removed enough of the cotton to give it a large room with wich to interchange air. And it sort of worked. It got hotter in there than I hoped. But it was pretty quiet. Now that I'm thining of it again, I could've done some things to improve aitflow to the outside withou opening the sofa up too much to leak sound. There were no frequencies, apparently, at a multipe of the resonance frequencies of any of the wood panels of the sofa. Sitting on it wasn't affected in any way. And the whole thing was easily accessable from the front. There was a cut-put right above the floor with a handle, with which you coulde pull out a board, that slid out on small wheel. On the board all the components were mounted. I used parts from a relatively cheap ATX case to make the motherboard and drives mount easily. I never got it down to the temperature I set out to get. And I couldn't use high-rpm hard disks because then that was the only noise in the room and it was very annoying. But it worked, and the sliding mechanism was fancy, even though it was so simple to build. The cutout and handle were actually easy to overlook in the pattern of the fabric that the sofa already had. I got the ideaa for the sofa mod after I ran the server inside my wooden desk for a while. That is another story. The sofa mod was kind of the enhanced version of the desk PC.

I wonder why I don't make things like these anymore. Because making something in a unique style that you like feels extra good on top of the feeling of making something yourself.

Fred - Part 3 - Power Supplies
This entry is a reply to or continuation of the entry 'Fred - Part 2 - The Case Lid And Cooling'.

After getting rid of the fan wall, the power supply was the main source of noise. The original PSU was a 3U redundant (2+1) server power supply. Noise does not matter with machines like that. I wanted to be able to have it running in my living room though, so the noise had to drop a fucking lot. Seriously, that's said so many times for people who don't work with servers like this. But people are still surprised when they hear a server fan for the first time. One of original 60 mm fans in the back is louder than my vaccum cleaner. And there were two of those, four 80 mm fans and five 40 mm fans. Three of the latter in the power supplies. Because I have no means to control the fans in software and don't need all the power the power supply can supply, I tried how much I can lower the noise by adding resistors in series to the fans. That did reduce noise a lot. But not only aren't these fans optimated for quiet operation, they are 40 mm fans. They will nver be quiet enough.

So I looked online for a power supply that

  1. fits in the case (it's not completely an ATX case)
  2. can supply enough current for everything and
  3. is trustworthy/doesn't appear to be too cheaply built

I found a Newton Power Model NPS-300AB B, which doesn't meat points 2 and 3 but fits so perfectly into the case that it was a weird feeling to accept that it is mostly coincidence. I got it for a couple of euros on ebay. Most sellers seem to think it's some piece of premium equipment because it's used in some Fujitsu servers or something. But it's really just a cheap ATX power supply in a non-standard case. But because of that non-standard case fitted so well into my non-standard server case, I got it anyway. I only had to drill the screw holes and that was it. It's hardly enough for 14 HDDs and the internet says it's really cheap and not trustworthy. But I went with it anyway in order to pay tribute to r/thingsfittinginthings.

Not a year later the PSU died. Probably overstressed it for too long. I replaced it with a better SFX unit. I had a nice and thick plate of stainless steel lying around, from which I cut an adapter plate.

I'll attach some photos below. Maybe I'll continue this series of entries on Fred some other day with experiences of dust and heat and such over time.

File Attachments (5 files)
The old power supply after it died_ (The unplugged fan and the missing screws do not resemble how it looked while it was in use_)
The old power supply after it died. (The unplugged fan and the missing screws do not resemble how it looked while it was in use.)
Maybe it would have lived longer if I had cooled it better_ It wasn't efficient_ It would have been too loud_
Maybe it would have lived longer if I had cooled it better. It wasn't efficient. It would have been too loud.
The new power supply_ Fits well in height and leaves more than enough room for its modular cables (even for the ones that aren't used) and airflow_
The new power supply. Fits well in height and leaves more than enough room for its modular cables (even for the ones that aren't used) and airflow.
I'm happy with the adapter plate and how it turned out, even though I originally made it for a different SFX unit and the fan cutout now seems redundant_ But it actually looks kind of professional_ That's rare enough with me_ I bet you can't tell which part I made myself_ (Or is this because the photo is so bad?)
I'm happy with the adapter plate and how it turned out, even though I originally made it for a different SFX unit and the fan cutout now seems redundant. But it actually looks kind of professional. That's rare enough with me. I bet you can't tell which part I made myself. (Or is this because the photo is so bad?)
I made my own modular cables with old molex connectors for the HDD backplane_ The unused cables in the plastic bag has its place at the back of the PSU_
I made my own modular cables with old molex connectors for the HDD backplane. The unused cables in the plastic bag has its place at the back of the PSU.
Fred - Part 2 - The Case Lid And Cooling
This entry is a reply to or continuation of the entry 'Fred - Part 1 - Modding The Quiet Into A Server Rack Case'.

In this entry I'll describe how Fred's components are air cooled.

So, after removing the fan wall and unplugging the two fans in the back of the case there was no active cooling left. That's good for reducing noise, but not enough cooling for the hard drives, the CPU and the SAS controller cards. Since the case is not mounted in a rack and nothing is placed on top of it, I decided to use the space in the case lid to place larger fans.

The CPU

My idea was to replace the CPU cooler with a larger one that just fits into the case and have a fan above it suck out its hot air (also pulling in ait from the RAM modules next to the CPU socket). I fount a heat sink from Scythe called Iori (SCIOR-1000). Mounted on the socket there would be just enough space for a 15 mm fan above it. As it turns out though, the heat sink is large enough to cool the CPU passively and the RAM doesn't need any additional cooling, too. So the fan above it is not even plugged in.

The Extension Cards

Since the HBA and the RAID card that I'm using are designed for servers with a proper airflow, they need at least some additional cooling. Their heat sinks are quite small for the amount of heat they produce. But there was enough room above them to place a fan that sucks the hot ait directly from the extension card area out of the case. I was told these cards usually don't have any problems getting extremely hot. But I rather don't want to have them do their things for hours or days streight without any active cooling. Replacing their heat sinks with larger ones would only be a sufficiant option if there was room for much much larger heat sinks.

The Hard Drives

I don't want to have have hard drives run continuesly without any active cooling, especially when they are sitting in enclosures that don't allow for any aitflow without some amount of pressure. There is just no-where for the heat to go on its own in these tight drawers. I decided for three 140 mm fans that would neatly in a row behind the hard drive compartment and backplane. Since the motherboard isn't that large, there was nothing but a few cables in that area of the case. I've mounted an aluminium bar that I had lying around and tucked two pieces of flat plastic between this bar and the bar that originally held the fan wall at the bottom. That way, the air that is pressed in from above gets directed only into the hard drive compartment where it has no way to escape without passing the hard drives.

Unfortunately the room around the hard drives is so small that quite a lot of air preassure is needed to cool them as much as I wanted to. Running the fans at full speed all the time is hardly enough to keep them at a temperature that I deem acceptable. I tried to increase the cooling effect by sealing all the edges and other tiny spaces where some air could escape without cooling the hard drives. But this didn't lead to a measurable difference. I ended up taking out two of the 16 hard drives to increase the size of the duct. I chose two drives in the centre so that there now is a large surface where the air cools the remaining drives. That lowered the temperatures of the surrounding drives a lot. The temperature of the drives at the edges was of course hardly effected. But those weren't the problem anyway.

I'll probably continue about the rest of the case mod in a followup entry.

File Attachments (12 files)
Making the holes for the fans was easier than I expected_ I marked the borders with a pencil by following the outlines of the actual fans, cut the rough holes with an angle grinder with a cutting disk, then did the finishing with a rotary tool (a not Dremel)_
Making the holes for the fans was easier than I expected. I marked the borders with a pencil by following the outlines of the actual fans, cut the rough holes with an angle grinder with a cutting disk, then did the finishing with a rotary tool (a not Dremel).
I used up several cheap grinding bits for the finishing_ The remaining borders between the fas are only a few millimeters wide_ But the ~2 mm thick steel holds up surprisingly well_ They don't make regular home computer cases from that material_
I used up several cheap grinding bits for the finishing. The remaining borders between the fas are only a few millimeters wide. But the ~2 mm thick steel holds up surprisingly well. They don't make regular home computer cases from that material.
First coat: primer, second coat: matte black, thirdly added sparkly sprinkles_ In the picture I started taping the sides for what comes next_
First coat: primer, second coat: matte black, thirdly added sparkly sprinkles. In the picture I started taping the sides for what comes next.
Then I painted the middle part pink_ After the tape was removed I noticed the paint came off in one spot_ Well, that's how it goes if you don't do it right_ I can just cover this with a sticker_ For now I just added a matte clearcoat_
Then I painted the middle part pink. After the tape was removed I noticed the paint came off in one spot. Well, that's how it goes if you don't do it right. I can just cover this with a sticker. For now I just added a matte clearcoat.
In between cooling systems_ I tested the modded lid as it was in the picture but closed_ It did do something and it was better than the open case with scattered fans in the next picture, but not by much_
In between cooling systems. I tested the modded lid as it was in the picture but closed. It did do something and it was better than the open case with scattered fans in the next picture, but not by much.
That's how it looked for a day while I used the NAS before finishing the new cooling system_ Notice the large space in the middle_ That will be used in the next pictures_
That's how it looked for a day while I used the NAS before finishing the new cooling system. Notice the large space in the middle. That will be used in the next pictures.
This is how the case looked inside now_ (I'll write about the power supply in the next entry_)
This is how the case looked inside now. (I'll write about the power supply in the next entry.)
And from the outside_ The fan on the bottom right cools the RAID card and the HBA_ I don't know if it's cooling it enough because I don't know what the cards/processors are made to withstand_ But they still ran a few years after that picture was taken_ The CPU fan is off because it stays cool enough during a hours-long burn test_
And from the outside. The fan on the bottom right cools the RAID card and the HBA. I don't know if it's cooling it enough because I don't know what the cards/processors are made to withstand. But they still ran a few years after that picture was taken. The CPU fan is off because it stays cool enough during a hours-long burn test.
The cooler mount wasn't made for that socket_ I think it was for an AMD socket_ The bracket was really strong and tight and eventually broke in two_ The CPU lid didn't take any damage though and I simply used a few zipties to hold the cooler in place without much preasure on the CPU_ That still was enough to cool the CPU passively and the machine ran three quarters of a year that way_
The cooler mount wasn't made for that socket. I think it was for an AMD socket. The bracket was really strong and tight and eventually broke in two. The CPU lid didn't take any damage though and I simply used a few zipties to hold the cooler in place without much preasure on the CPU. That still was enough to cool the CPU passively and the machine ran three quarters of a year that way.
Eventually I made my own bracket (not in the picture) and now that is held down by zipties_ It's quite sturdy_
Eventually I made my own bracket (not in the picture) and now that is held down by zipties. It's quite sturdy.
Fred - Part 1 - Modding The Quiet Into A Server Rack Case

Fred is an old Supermicro rack server that I got as an attempt at building a NAS that replaces all the smaller NASs that I already had. But I like to collect stuff and it's never going to be enough. So it ended up being just another extension of my home network.

Overview

It's an old 3U Supermicro server case with 16 3.5" hard drive drawers, a good but not too bulky Asus motherboard and a nice low-power Intel CPU. I kept the motherboard, CPU and 32 GB ECC RAM. It's more than enough.

I wanted to do some mods on the case though to make it more comparible to my home and my visual taste in computer cases. In short, what I did was: Switch the PSU to a quieter one, build fans into the lid for quieter drive and card cooling, painted the case, switched the CPU cooler for passive cooling, added two HBA cards and 14 8 TB hard drives (two drawers left intentionally free).

I will tell about/may document these mods in more detail in separate entries.

File Attachments (5 files)
The case before I started (but not before I added some stickers)
The case before I started (but not before I added some stickers)
The pretty much finished case
The pretty much finished case
PIN Changer

I had to change the default PINs of over 200 SIM cards once. And such a situation could arise again. So I've built a PIN changer in which I just have to insert the card, wait a few seconds and it's done.

The Card Slots

SIM cards in their natural form factor aren't as fiddly to handle as they are in the form factors most people know, which is Mini SIM, Micro SIM and Nano SIM. Classical SIM cards are the same size as other smart cards. I found a card slot with an end switch on eBay. I like it when I find industry grade parts for cheap on eBay as part of some remaining stock. Additionally I've used a slide-in mini SIM slot and another, separate end switch from my parts collection in case I to change the PINs of smaller cards.

The Baseband Processor

Other parts that I've used is an Arduino Nano sized Arduino Nano nearly-clone and an A6 modem module. There are many similar modem modules designed around different but similar ICs. Many of them are cheap and widely used for DIY IoT projects. So example code for the Arduino and other help can be easily found on the web. I don't know why I went with a module with an A6. But it works fine and there are an Arduino library for it as well as cheap modem modules with it available.

(tba:voltage supply)

The Controller

Yes, Arduino may be kind of the noob go-to board and could look up how to use microcontrollers on their own finally and even if I don't want to I could finally start to use ESP32s like everybody else. But I know Arduinos and by now I'm familiar with it and it works, so, whatever. Arduino Nano is kind of my go-to form factor now because they have integraded USB, are Uno compatible and small. Unless I need more or something very specific I use Arduino Nano almost-clones with USB-C port.

The Code

The code is a real mess. It had been a long time since I had written any even halfway serious C. It may have been the first time, actually. The sketch surely is very easily improved by somebody who knows what they are doing. I intended to improve it myself. But the project is currently abandoned and The code is doing what it should in a way I initially had in mind as the goal. But I'll leave the mess of the comments in for the case that somebody wants to make out what I was thinking.


// Funktionen umschreiben: Beim Empfangen wird erwartet: 1. der AT-Command zurück, 2. eine Antwort, 3. OK oder ein ERROR.
//                         Daher sollte abgefragt werden, bis entweder OK oder ERROR kam oder 20/50/9001(?) Abfragen lang weder OK noch ERROR an kam.
//                         Die Antwort in Variable speichern? Naja, String zurückgeben halt.
//                         Antworten, die mit "^" anfangen brauchen nicht gehandlet zu werden, da keine Kommandos, die mit AT^ beginnen gesendet werden.


#include  

SoftwareSerial A6MODULE(6,7);
int intled = 13; // Internal LED
int successled = 8; // Green LED
int failled = 9; // Red LED
int wrongpinled = 10; // Orange LED

boolean debug=true;

//String commands[5] = { "AT", "AT+CPINC2", "AT+CPIN?", "AT+CLCK=\"SC\",2", "AT+CPIN=\"3010\"" };
//int command = 0;

const byte maxmsglength = 32;
char received[maxmsglength];
boolean newData = false;
String response = "";

int i=0;

/*
To check/do:
1  AT: OK?
2  is PUK required - abort
3  are less than 3 PIN attempts left? - abort AT^CPINC=?
4  is PIN disabled
       5  enable it: 0000
6  is PIN enabled
       7  unlock
8  is card unlocked
       9  change PIN: 1996
              was PIN wrong - report and leave it
*/


void setup() {
  pinMode(intled, OUTPUT);
  pinMode(successled, OUTPUT);
  pinMode(failled, OUTPUT);
  pinMode(wrongpinled, OUTPUT);
  // All LEDs turn on at the beginning and stay on during the wait period at the beginning, then turn off before communication with the A6 module starts.
  digitalWrite(intled, HIGH);
  digitalWrite(successled, HIGH);
  digitalWrite(failled, HIGH);
  digitalWrite(wrongpinled, HIGH);
  Serial.begin(9600);
  delay(500);
  digitalWrite(intled, LOW);
  digitalWrite(successled, LOW);
  digitalWrite(failled, LOW);
  digitalWrite(wrongpinled, LOW);
  A6MODULE.begin(9600);
  delay(500);
  digitalWrite(intled, LOW);
}

void loop() {
  sendtoa6("AT");
  if(getfroma6("OK")) {
//    sendtoa6("AT+CPIN?");
//    if(getfroma6("+CPIN:SIM PUK")) { fail; }         // If the required password is PUK, abort.
//    sendtoa6("AT+CPIN?");
//    if(getfroma6("+CPIN:SIM PIN2")) { fail; }        // If the required password is PIN2, abort.
//    sendtoa6("AT+CPIN?");
//    if(getfroma6("+CPIN:SIM PUK2")) { fail; }        // If the required password is PUK2, abort.

// WAIT FOR SWITCH RELEASE FIRST
    sendtoa6("AT+CPIN?");
    getfroma6("+CPIN:SIM PIN");                      // The last non-empty response will be stored in the global response variable. Problem with this: If the A6 module sends an unsolicitated message before the response to the CPIN command, nothing gets done and the card needs to be re-inserted again.
    if(strcmp(response, "OK") == 0) {                // If already no PIN is required

//      sendtoa6("AT+CLCK=\"SC\",2"); // Ist PIN-Abfrage eingeschaltet? Oder ist es "SC"?
//      if(getfroma6(???)) { PIN-Abfrage einschalten mit 0000; }

      // ENABLE PIN HERE
      d("I don't know how to enable the PIN.");

    }
    if(response = "+CPIN:SIM PIN") {                 // If the required password is PIN, continue.
      sendtoa6("AT^CPINC=?");
      if(getfroma6("^CPINC: 3")) {                   // If not exactly 3 attempts are left, abort. (should be larger than or equal to 3, shouldn't it?)
        sendtoa6("AT+CPIN=\"0000\"");                // Freischalten mit 0000
        delay(50);
        if(!getfroma6("OK")) { fail; }               // If that was not the right password, abort.
        sendtoa6("AT+CPWD=\"SC\",\"0000\",\"1996\"");// PIN ändern
        delay(500);
        if(getfroma6("OK")) { Serial.println("Looking good."); }

//      sendtoa6("AT+CMGD=0,4"); // Should delete all SMS
//      if(getfroma6(???)) { ; }
        d("I don't know how to delete SMS.");

        sendtoa6("AT+CPIN?");
        if(getfroma6("+CPIN:READY")) {
          
          // TURN OFF A& MODULE FOR SAFE CARD REMOVAL

          digitalWrite(successled, HIGH);
        }
      } else {                                         // If not exactly 3 times left
        fail;
      }
      delay(1000);
    }
  }
}

void fail() {
  digitalWrite(failled, HIGH);               // Turn red fail LED on and ...
  d("Something failed! Ending programme.");
  while(1);                                  // ... don't do anything anymore.
}

void wrongpin() {
  digitalWrite(wrongpinled, HIGH);           // Turn yellow LED on and ...
  d("Wrong PIN! Ending programme.");
  while(1);                                  // ... don't do anything anymore.
}

//boolean getfroma6(char str[32], char str1[32], char str1[32], char str1[32], char str1[32], char str1[32]) { // Returns true if the passed (expected) message was received, false if anything else was received.
boolean getfroma6(char str[32]) { // Returns true if the passed (expected) message was received, false if anything else was received.
  boolean asexpected = false;
    for (i = 1; i < 9; ++i) {
    receivelinefroma6();
//    d("d1 "+response);

    if(received[0] == '\0') {                            // If the received message is empty
      continue;
    } else {
      response = received;
    }
    if(strstr(received, "ERROR") != NULL) {              // If the received message contains "ERROR"
      d("Received an error: "+response);
      fail;
    }
    if(received[0] == '+') {                             // If the received message starts with a "+" sign
      d("Reseived response: "+response);
    } else {
      if(strstr(received, "OK") != NULL) {               // If the received message is "OK"
        d("Received OK.");
        asexpected = true;                               // Also treat OK like the expected message. No unexpected OK should ever be sent from the A6 module. So this is fine. No, it is, really.
//        if(asexpected) { return true; }
      } else {
        if(strncmp(received,"AT",2) == 0) {              // If the received message starts with "AT"
          d("Received AT: "+response);
        } else {                                         // For any other received message
          d("Received: "+response);
        }
      }
    }
    newData = false;
    if(strstr(received, str) != NULL) {
      d("Received expected message: "+response);
      asexpected = true;
    }
  }
  if(asexpected) { return true; }
  return false;
}


//void handleresponse() {
//  response = received;
//  if(received[0] == '+') {
//    d("               Response: "+response);
//  } else {
//    if(strstr(received, "OK") != NULL) {
//      d("               It's okay.");
//    } else {
//      if(strncmp(received,"AT",2) == 0) {
//        d("               I've sent: "+response);
//      }
//    }
//  }
//  newData = false;
//}



void receivelinefroma6() {
  delay(80);
  static byte counter = 0;
  char rc;
  
  received[0] = '\0';

  while (A6MODULE.available() > 0 && newData == false) {
    rc = A6MODULE.read();

    if (rc != '\n') {
      received[counter] = rc;
      counter++;
      if (counter >= maxmsglength) {
          counter = maxmsglength - 1;
      }
    }
    else {
      received[counter] = '\0'; // terminate the string
      counter = 0;
      newData = true;
    }
  }
}

void sendtoa6(String command) {
//  Serial.println(command);
  A6MODULE.println(command);
  d("Sent: "+command);
}

void d(String line) {
  if (debug == true) { Serial.println(line); }
}

(tba:connections,assembly,photos?)