How to run multiple sketches?

First sorry if this is a crazy question but I am new at this language, I am used to RSlogics so this is kinda strange at the moment.

I have a temperature, current, and Ethernet sketch. How can I put them all together and upload it to the Arduino? I can upload them individually and the work but it just erases the previous one… I looked everywhere and people just talk about one sketch at time.

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.

DeviceAddress probe1 = { 0x28, 0xCC, 0xA2, 0x97, 0x05, 0x00, 0x00, 0x1E };
DeviceAddress probe2 = { 0x28, 0x8A, 0xF8, 0x97, 0x05, 0x00, 0x00, 0xF1 };
DeviceAddress dogHouseThermometer = { 0x28, 0x59, 0xBE, 0xDF, 0x02, 0x00, 0x00, 0x9F };

void setup(void)
  // start serial port
  // Start up the library
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(probe1, 10);
  sensors.setResolution(probe2, 10);
  sensors.setResolution(dogHouseThermometer, 10);

void printTemperature(DeviceAddress deviceAddress)
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(" F: ");

void loop(void)
  Serial.print("Getting temperatures...\n\r");
  Serial.print("Probe 1 is: ");
  Serial.print("probe 2 is: ");

// Current Only with multiple CT's

#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor emon11, emon12;          // Create an instance

void setup()
  emon11.current(1, 111.1);             // Current: input pin, calibration.
  emon12.current(2, 111.1);             // Current: input pin, calibration.

void loop()
  double Irms1 = emon11.calcIrms(1480);  // Calculate Irms only
  double Irms2 = emon12.calcIrms(1480);  // Calculate Irms only
  Serial.print("CT 1: ");
  Serial.print(Irms1*230.0);	       // Apparent power
  Serial.print(" ");
  Serial.println(Irms1);		       // Irms
  Serial.print("CT 2: ");
  Serial.print(Irms2*230.0);	       // Apparent power
  Serial.print(" ");
  Serial.println(Irms2);		       // Irms
 DHCP Chat  Server
 A simple server that distributes any incoming messages to all
 connected clients.  To use telnet to  your device's IP address and type.
 You can see the client's input in the serial monitor as well.
 Using an Arduino Wiznet Ethernet shield. 
 THis version attempts to get an IP address using DHCP
 * Ethernet shield attached to pins 10, 11, 12, 13
 created 21 May 2011
 modified 9 Apr 2012
 by Tom Igoe
 Based on ChatServer example by David A. Mellis

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = { 
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
IPAddress ip(192,168,1, 177);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255, 0, 0);

// telnet defaults to port 23
EthernetServer server(23);
boolean gotAMessage = false; // whether or not you got a message from the client yet

void setup() {
  // Open serial communications and wait for port to open:
  // this check is only needed on the Leonardo:
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only

  // start the Ethernet connection:
  Serial.println("Trying to get an IP address using DHCP");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // initialize the ethernet device not using DHCP:
    Ethernet.begin(mac, ip, gateway, subnet);
  // print your local IP address:
  Serial.print("My IP address: ");
  ip = Ethernet.localIP();
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(ip[thisByte], DEC);
  // start listening for clients

void loop() {
  // wait for a new client:
  EthernetClient client = server.available();

  // when the client sends the first byte, say hello:
  if (client) {
    if (!gotAMessage) {
      Serial.println("We have a new client");
      client.println("Hello, client!"); 
      gotAMessage = true;

    // read the bytes incoming from the client:
    char thisChar =;
    // echo the bytes back to the client:
    // echo the bytes to the server as well:

Thanks again!

..merge them

copy/ paste so that: all defitions and global variables are at top. then setup (from the schetches) ..followed by all functions.. ..and last.. the 'loop' ............ beware variable names/IO-pins, so parts don interfere with another..

Got it. Thanks. I just cut/paste the whole thing and it gave me errors. I thought I tried to clean it up but guess I missed some items. Thanks again!

good luck, you'll manage!