element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Home Sensing Station: Sending data from Ethernet Shield to Xively
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 1 reply
  • Subscribers 391 subscribers
  • Views 168 views
  • Users 0 members are here
  • xively
  • ethernet
  • shield
  • arduino
Related

Home Sensing Station: Sending data from Ethernet Shield to Xively

Former Member
Former Member over 11 years ago

Hi,

 

i am doing this project on Home Sensing Station from Dummies's Arduino Projects. After i have finished everything stated there, it only shows the reading for light sensor on the serial monitor and it did not continue reading afterwards. What's worse is that it did not send the data to Xively. Here's the coding:

#include <b64.h>
#include <HttpClient.h>


#include <CountingStream.h>
#include <Xively.h>
#include <XivelyClient.h>
#include <XivelyDatastream.h>
#include <XivelyFeed.h>


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


#define API_KEY "zuivpbOAGm6DnvmbWzKifFhcAaLwxozmw9GRu4saiFfjNHsT" 
#define FEED_ID 388783128 




byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };






const int lightSensorPin=2;
const int tempPin1=3;
const int tempPin2=4;


unsigned long lastConnectionTime = 0;                
const unsigned long connectionInterval = 15000;      








char sensorId1[] = "light";  
char sensorId2[] = "temp1";  
char sensorId3[] = "temp2";  



XivelyDatastream datastreams[] = {
  XivelyDatastream(sensorId1, strlen(sensorId1), DATASTREAM_FLOAT),
  XivelyDatastream(sensorId2, strlen(sensorId2), DATASTREAM_FLOAT),
  XivelyDatastream(sensorId3, strlen(sensorId3), DATASTREAM_FLOAT),
};




XivelyFeed feed(FEED_ID, datastreams, 3 );




EthernetClient client;
XivelyClient xivelyclient(client);


void setup() {
  Serial.begin(9600);
  Serial.println("Initializing network");
  while (Ethernet.begin(mac) != 1) {
    Serial.println("Error getting IP address via DHCP, trying again...");
    delay(15000);
  }
  Serial.println("Network initialized");
  Serial.println("Ready.");
}


void loop() {
  
  if (millis() - lastConnectionTime > connectionInterval) {
    
    float lightLevel = map(analogRead(lightSensorPin),0,1023,0,100);
    
    sendData(0, lightLevel);  
   
    
    getData(0); 
    
    float temperature1 = ((getVoltage(tempPin1) -.5) * 100L);
    

    
    sendData(1, temperature1); 
   
    
    getData(1);
    
    float temperature2 = ((getVoltage(tempPin2) -.5) * 100L);
    
    sendData(2, temperature2); 


    
    getData(2);
    
    lastConnectionTime = millis();

    Serial.println("Waiting for next reading");
    Serial.println("========================");
  }
}




void sendData(int streamIndexNumber, float sensorValue) {
  datastreams[streamIndexNumber].setFloat(sensorValue);~~~~


  Serial.print("Sensor value is: ");
  Serial.println(datastreams[streamIndexNumber].getFloat());


  Serial.println("Uploading to Xively");
  int ret = xivelyclient.put(feed, API_KEY);
  
}




void getData(int stream) {
  Serial.println("Reading the data back from Xively");


  int request = xivelyclient.get(feed, API_KEY);
  


  if (request > 0) {
    Serial.print("Datastream: ");
    Serial.println(feed[stream]);


    Serial.print("Sensor value: ");
    Serial.println(feed[stream].getFloat());
    Serial.println("========================");
  }
}


float getVoltage(int pin){


return (analogRead(pin) * .004882814);
}

i tried to verify the code and it does not have any problems and i can't find any solutions for it...

I also post this question on another forum: Sending data from Ethernet Shield to Xively - Arduino Forum


  • Sign in to reply
  • Cancel
Parents
  • Former Member
    0 Former Member over 11 years ago

    Forgot to say that the codes were not by me, it's from the Dummies book

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 11 years ago

    Forgot to say that the codes were not by me, it's from the Dummies book

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube