Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

kan anyone help me ?

coding visual studio

  • Please log in to reply
2 replies to this topic

#1 ruan.conradie

ruan.conradie

    New Member

  • Members
  • Pip
  • 1 posts

Posted 17 July 2013 - 07:35 PM

using System;

using System.Net;

using System.Net.Sockets;

using System.Threading;

using Microsoft.SPOT;

using Microsoft.SPOT.Hardware;

using SecretLabs.NETMF.Hardware;

using SecretLabs.NETMF.Hardware.Netduino;

 

namespace hallopachube

{

  public class Program

  {

  public static void Main()

  {

  // write your code here

  const string apikey = "your pachube api key";

  const string feedid = "your pachube feed id";

  const int samplingperiod = 20000;

 

  const double maxvoltage = 3.3;

  const int maxadcvalue = 1023;

 

 var voltageport = new AnalogInput(Pins.GPIO_PIN_A1);

  var lowport = new OutputPort(Pins.GPIO_PIN_A0, false);

  var highport = new OutputPort(Pins.GPIO_PIN_A2, true);

 

  while (true)

  {

  waituntilnextperiod(samplingperiod);

  int rawvalue = voltageport.Read(500);

  double value = (rawvalue * maxvoltage) / maxadcvalue;

  string sample = "voltage," + value.ToString("f");

  Debug.Print("new message: " + sample);

  PachubeClient.send(apikey, feedid, sample);

  }

  }

 

static void waituntilnextperiod(int period)

  {

  long now = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

  var offset = (int)(now % period);

  int delay = period - offset;

  Debug.Print("sleep for " + delay + " ms/r/n");

  Thread.Sleep(delay);

 

 

 

  }

 

  }

}

 

im getting errors 

 

Error 1 No overload for method 'Read' takes 1 arguments
 
Error 2 The best overloaded method match for 'Microsoft.SPOT.Hardware.AnalogInput.AnalogInput(Microsoft.SPOT.Hardware.Cpu.AnalogChannel)' has some invalid arguments
 
Error 3 Argument 1: cannot convert from 'Microsoft.SPOT.Hardware.Cpu.Pin' to 'Microsoft.SPOT.Hardware.Cpu.AnalogChannel'
 
Error 4 Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)
 
Error 5 The name 'PachubeClient' does not exist in the current context
 
 

if annyone could please help



#2 Emilio x64

Emilio x64

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 13 August 2013 - 05:11 PM

Use the intellisense help to see the arguments expected by your method.



#3 nakchak

nakchak

    Advanced Member

  • Members
  • PipPipPip
  • 404 posts
  • LocationBristol, UK

Posted 14 August 2013 - 10:47 AM

Hi Ruan, welcome to the community

 

First of all please insert code using the code button in the message editor tool bar, makes it much easier to read and refer to as you have line numbers...

 

To fix issue #1 try removing the "500" from your call to Read. (should also fix issue #4)

 

It also looks like your missing a reference to the pachube library as well, try following the instructions on page 18 of the Hello Pachube sample pdf that should solve issue #5

 

Nak.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.