 {
   if ( Ethernet.begin( mac ) == 0 )
   {
-    std::cout << F( "Failed to configure Ethernet using DHCP" ) << std::endl;
+    Serial.println( F( "Failed to configure Ethernet using DHCP" ) );
     Ethernet.begin( mac, ip );
   }
 
   // give the Ethernet shield a second to initialize:
-  std::cout << F( "Connecting to network..." ) << std::endl;
+  Serial.println( F( "Connecting to network..." ) );
   delay( 1000 );
 
   // Initialise network API to use Ethernet
-  qsense::net::initNetworkType( qsense::net::Ethernet );
+  SimpleSidecarClient::initNetworkType( SimpleSidecarClient::Ethernet );
 }
 
 


  const int measurePin = 6;
  float voMeasured = analogRead( measurePin ); // read the dust value

  const int deltaTime = 40;
  delayMicroseconds( deltaTime );
  digitalWrite( ledPower, HIGH ); // turn the LED off

  const int sleepTime = 9680;
  delayMicroseconds( sleepTime );

  // 0 - 5.0V mapped to 0 - 1023 integer values
  // recover voltage
  const float calcVoltage = voMeasured * ( 5.0 / 1024 );
  const float dustDensity = 0.17 * calcVoltage - 0.1;

  qsense::net::DateTime& dt = qsense::net::DateTime::singleton();
  const QString& date = dt.date();
  const QString& time = dt.currentTime();

  qsense::Event event;

  // Add the readings
  event += qsense::Reading( "SV", voMeasured, time );
  event += qsense::Reading( "V", calcVoltage, time );
  event += qsense::Reading( "DD", dustDensity, time );

  // Add tags to the event.  To demonstrate we add current date to help
  // easily retrieve readings by day
  event += date;

  qsense::net::SidecarClient client;
  if ( client.publish( event ) )
  {
    std::cout << "Published " << event << " to sidecar" << std::endl;
  }
  else
  {
    std::cout << "Error publishing " << event << " to sidecar" << std::endl;
  }
}


int freeRam()
{
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}



/*
Copyright 2015 Sidecar 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <SPI.h>
#include <Ethernet.h>
#include <WiFi.h>

#include <StandardCplusplus.h>
#include <SimpleSidecarClient.h>
#include <serstream>

namespace std
{
  ohserialstream cout(Serial);
}

const int ledPower = 12;

// A proper unique mac address is critical to having a stable UUID generated
// for events published to Sidecar service.  Please use the MAC address
