Sharks and Sticky Tape

Okay so to get started with I had to rewire the ethereten to the breadboard because I had to disconnect it when the etherten failed. I realized that I’ll probably use my etherten a lot even after I finish this server so I used some sticky tape to secure the pins in place in order. This means I can unplug the board easily.

Sticky tape

The slightly more secure wiring

The second cool thing that I want to show you before we delve into the server’s code is this awesome old shark pen that I found in my room. It’s got an awesome LED that lights up all different colors automatically.

Here’s a short demonstration showing what I mean:

shark light

A very cool pen

So that basically solves the problem of making my server look awesome at night. And the best thing is that it doesn’t need any PWM or any other fancy stuff because it has it’s own internal chip and acts just like a normal LED in circuit so I can just plug it straight into digital pin 8.

Code

Set it up

Let’s start with the arduino configuration (setup) code:

void setup(){

  /*Analog pin configurations*/
pinMode(A0, INPUT); //TILT SENSOR

/* LED number display control*/
pinMode(A1, OUTPUT);//DIGIT CONTROL
pinMode(A2, OUTPUT);//DIGIT CONTROL
pinMode(A3, OUTPUT);//DIGIT CONTROL
pinMode(A4, OUTPUT);//DIGIT CONTROL
pinMode(A5, INPUT);//DIGIT CONTROL

  /*Digital pin configurations*/  
pinMode(1, OUTPUT);//SEGMENTS
pinMode(2, OUTPUT);//SEGMENTS
pinMode(3, OUTPUT);//SEGMENTS
pinMode(4, OUTPUT);//SEGMENTS
pinMode(5, OUTPUT);//SEGMENTS
pinMode(6, OUTPUT);//SEGMENTS
pinMode(7, OUTPUT);//SEGMENTS

/*Digital pin 8 is not in use at the moment being left spare 
so it can serve as an ethernet
host for other arduino devices in my room. 
Or to turn on and off the cool LED that I found in an old pen.*/
pinMode(9, OUTPUT);//PIEZO
pinMode(8,OUTPUT); //awesome shark pen.
}

So that stuff basically tells the chip what each pin on the chip is going to do. I also added what is connected to each chip for easy reference when writing the code.

HTML

This part was pretty easy to do as I have experience in web development. Here’s what the output of the server looks like:

Screenshot of the server

Screenshot of the server's HTML output

As you can see I went for a very “hacker” kind of look because the thing is 8 bit and primitive. I’m not going to claim I can play flash games on an arduino like this guy: http://www.instructables.com/id/Arduino-Flash-game-streamer/

I mean all he did was use iframe HTML tags. Meh.

And here’s the code that powers the server output:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ardu Server</title>
	<style type=text/css>
	body{
		font-family: Courier;
		color: green;
		background-color: black;
		font-size: 30px;
	}
		h1{
		font-family: Courier;
		color: green;
		background-color: black;
		font-size: 60px;
	}
	</style>
</head>
	<body>
		<h1>Welcome to ardu serve v1.0</h1>
		<p>Server has not been stolen recently</p>
		<p>Lighting is on</p>
		<p>Temp = 36.15 degrees celsius</p>

	</body>
</html>

But to simplify things when we are putting our HTML into our arduino code I deleted all the indents. There’s not much point repeating that here.

I tried to unindent my code and it didn’t quite work as planned. Don’t just try cramming the webpage into on a line because the Arduino IDE only allows certain number of characters in a line before it cuts them off. I’m not about to write client.println() for every line in my HTML. So I guess I might have to go and do it like this guy.

// HTTP Request message
PROGMEM prog_char content_404[] = "HTTP/1.1 404 Not Found\nServer: arduino\nContent-Type: text/html\n\n<html><head><title>You Fail</title></head><body><h1>Looks like Lochie Ferrier has failed in his duty to maintain the arduserver</h1></body>";
PGM_P page_404[] PROGMEM = { content_404 }; // table with 404 page

// HTML Header for pages
PROGMEM prog_char content_main_header[] = "HTTP/1.0 200 OK\nServer: arduino\nCache-Control: no-store, no-cache, must-revalidate\nPragma: no-cache\nConnection: close\nContent-Type: text/html\n";
PROGMEM prog_char content_main_top[] = "<html><head><title>Arduino Web Server</title><style type=\"text/css\">table{border-collapse:collapse;}td{padding:0.25em 0.5em;border:0.5em solid #C8C8C8;}</style></head><body><h1>Lochie Ferrier's arduserver</h1>";
PROGMEM prog_char content_main_menu[] = "<table width=\"500\"><tr><td align=\"center\"><a href=\"/\">Home</a></td><td align=\"center\"><a href=\"page2\">Page 2</a></td><td align=\"center\"><a href=\"page3\">Page 3</a></td><td align=\"center\"><a href=\"page4\">Page 4</a></td></tr></table>";
PROGMEM prog_char content_main_footer[] = "http://www.lochieferrier.com</body></html>";
PGM_P contents_main[] PROGMEM = { content_main_header, content_main_top, content_main_menu, content_main_footer }; // table with 404 page
#define CONT_HEADER 0
#define CONT_TOP 1
#define CONT_MENU 2
#define CONT_FOOTER 3

// Page 1
PROGMEM prog_char http_uri1[] = "/";
PROGMEM prog_char content_title1[] = "<h2>Page 1</h2>";
PROGMEM prog_char content_page1[] = "<hr /><h3>Content of Page 1</h3><p>Nothing... yet.</p><br /><input type=\"text\" name=\"prova\">";

Basically he stores the webpages as part of the chip’s program memory. He has a five page system that even has get and post functions. When it gets a request it does some freaky deaky stuff that I don’t understand and gets the requested webpage along with a template (headers etc) and spits it out to the user. This was the original server infrastructure that I was going with but I wanted to try and build my own but now I think I’m just going to try and extend his masterpiece. Here’s the full version:

http://www.arduino.cc/playground/Code/WebServer

That guy is a god.

And I’ve still got to test that the circuit is even working……

Chips

Okay so seeing as I gave away my ebay arduino to my electronics teacher and my etherten is kind of going to be occupied I’ve started looking around for some new silicon.

Here’s the first cool one:

Chipkit uno32

Chipkit uno32

PIC32 board that's compatible with all things Arduino. Enough said.

This handy little board costs the same as a regular arduino, has a lot mor outputs and costs $32. That’s pretty good. But it’s worth mentioning that this board doesn’t run a full PIC32. It only runs a limited one that doesn’t have Ethernet, USB hosting or CAN. So you get 32bit and a lot of inputs but not much else. http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,893&Prod=CHIPKIT-UNO32

Specs:

  • Microchip® PIC32MX320F128 processor
    • 80 Mhz 32-bit MIPS
    • 128K Flash, 16K SRAM
  • Compatible with existing Arduino™ code examples, reference materials and other resources
  • Can also be programmed using Microchip’s MPLAB® IDE (along with a PICkit 3 and our PICkit3 Programming Cable Kit, seen below)
  • Arduino™ “Uno” form factor
  • Compatible with Arduino™ shields
  • 42 available I/O
  • User LED
  • Connects to a PC using a USB A -> mini B cable (not included)

The good news is that this thing has a big brother that is predictably named the Chipkit max32

Chipkit max32

Chipkit max32

This one has ethernet and a lot of outputs.

How is this one worth $20 more? It has ethernet and USB hosting and everything else you need. And Arduino compatibility. This thing could run a disco with ease. I want one. http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,894&Prod=CHIPKIT-MAX32

Specs:

  • Microchip® PIC32MX795F512 processor
    • 80 Mhz 32-bit MIPS
    • 512K Flash, 128K RAM
    • USB 2.0 OTG controller
    • 10/100 Ethernet MAC
    • Dual CAN controllers
  • Provides additional memory and advanced communications peripherals
  • Compatible with existing Arduino code examples, reference materials and other resources
  • Can also be programmed using Microchip’s MPLAB® IDE (along with a PICkit 3 and our PICkit3 Programming Cable Kit, seen below)
  • Arduino™ “Mega” form factor
  • Compatible with Arduino™ shields
  • 83 available I/O
  • User LED
  • Connects to a PC using a USB A -> mini B cable (not included)

So those are the digilent pic32 boards.

I’ll show you some more tomorrow that I have been pondering over like the mbed, cool ebay boards, chumby, beagle and the Cerebot 32MX7.

 

I haven’t really had time to check all this over because I did all this in half an hour so don’t kill me for spelling or factual errors.

Advertisements

The user interface

Getting the LCD to work…

LCD

The backlight works. Great. I can proceed further.

Okay so then I hooked up all the wires…

The wiring

Note that this image doesn’t show the right wiring exactly. I actually had to add a few more after I took a photo.

And I didn’t get much further than that. I have tried and tried again with this LCD and have not gotten it to work. I think I’ll have to put this off and play with it at a later date. I have double and triple-checked the wiring and it is all correct. It’s a pain and I think the problem is that I got it from a chinese ebay store. It’s the only thing in the box of parts that I got that doesn’t work.

Oh well.

Change of plan

Moving right along now…

So with the LCD scrapped I decided to implement a simple communication system for letting me know when people are online, the server’s status etc.

I went back to good old LEDs for this. I was going to use this funky  7 segment display (seen in the background of the photo below) until I discovered I didn’t have enough pins left because the ethernet had gobbled them up. I could use a multiplexer but that is just adding complexity and I like to keep it simple stupid (KISS).

Okay so here’s the basic electronics that the server has onboard. I didn’t put the wiring in because that would only confuse things for you guys.

  1. It’s got 3 LEDs – red for fail, green for good and yellow for connected or notifications (or SD card).
  2. An LM35 temperature sensor ( the transistor look-alike)  for logging weather.
  3. A green tilt sensor to detect whether the server has been stolen or manhandled.
  4. A button to turn it on or to dismiss a warning. There’s another on the protoboard.
  5. An IR receiver to read signals sent from my remote control.
  6. A piezo buzzer so I can annoy my parents from anywhere in the world.

So that’s pretty much all I need to get started on the code on Thursday. I won’t be able to work on it on Wednesday because I’m teaching kiddies how to build robots 🙂

Let’s start work.

Okay so here’s my list of things to do in an hour of work on the server-

  1. Get my LCD soldered to headers so I can actually use it.
  2. Find out about the python virtual machine.
  3. Can’t really do much ethernet testing cause I’ve got to figure out router’s ethernet IP’s.
  4. Figure out router’s IP addresses.
  5. Get a shit load of cable to get the internet connection to my room. Actually I’ve already got someone doing that for me because I gave them my duemilanove.
  6. Blog about it.

And that soldering iron’s just about heated up now…….

Arduino Server

server picture

Big ass server

Okay so I’m starting a new project.

I’ve wanted for a while to have a computer that I can utilise as a server on permanent duty in my home. My laptop runs a full apache server so I could use that but I often take it to school so there’s no point as it would be with me. It’s not a server if it’s not always on. But I had an old laptop so I thought that I would give that a try. It cost me about $400 5 years ago at a second hand computer fair thing. It’s actually a pretty cool little hacker style laptop  but it crashed a while ago. I tried to reboot  it but it’s external disc drive wouldn’t work so I couldn’t run the windows installation disks. I could have attempted to make a server in DOS but it would be pretty messy. I’ll try and revive it later.

The etherten’s role

As you guys know I recently purchased a freetronics etherten. This is an AVR board with onboard ethernet and microSD card storage. Sure, it’s an 8 bit chip but I don’t really need processing power for a little home server to use as a remote micro SD card. It has a up to 32GB of space (micro SD card) which should be enough to store images etc.

Examples

So I started to look around for web server examples for the arduino. There’s a lot out therer to cater for a lot of stuff (especially on the ethernet section of the official arduino site). But I guess I can only really call it a homegrown server if I do all the code myself. So I’m thinking I could just code it up in C++ or use a python virtual machine that I saw somewhere on Hackaday. I can’t really look up the details of the python virtual machine at the moment because I’m at school and school block out Hackaday and other cool sites with a Netbox Blue thingy.  Actually now that I think of it I could use the server as a proxy…..

What I want it to do

So I want my server to be able to do some basic things like serve my music and stuff so I can access a unique playlist from anywhere without having to lug a USB. I also want it to be able to use the micro SD card as a kind of file drop so I can drop larger files instead of having to transfer them through lousy microsoft exchange. Stuff like twitter temperature and all that sort of cool stuff would be awesome to have as well. I think I may go with the python option for coding as I have been wanting to learn it for a while now and this seems like a perfect excuse. But C++ does have some nice libraries…

So that’s what I’m going to be working on.