how to add digital pin status in json








 can any one help me to add status of digital pin to json string.

i have tried to add but emon sends status to emoncms only ones on startup and then repeat the same status, even if status has been changed

 

 

 

 

 

TrystanLea's picture

Re: how to add digital pin status in json

Hello bjalodia, Could you show me the code your using to send the status?

Are you generating a json string along the following lines:

if digital input is HIGH then json string = {status:1)

if digital input is LOW then json string = {status:0)

bjalodia's picture

Re: how to add digital pin status in json

 

 

 




Dear Tystan


I am using the following modified code of emon.

or if you can provide the code it will be very helpful

 

 

//--------------------------------------------------------------------------------------
// Mains AC Non Invasive 3 + Ethernet Example
// Last revision 30 November 2010
// Licence: GNU GPL openenergymonitor.org
// By Trystan Lea
//--------------------------------------------------------------------------------------
 
//--------------------------------------------------------------------------------------
// ETHERNET
//--------------------------------------------------------------------------------------
#include "EtherShield.h"
byte mac[] = {0x54,0x52,0x58,0x10,0x00,0x18};         //Ethernet shield mac address
byte ip[] = {172,16,1,9};                            //Ethernet shield ip address
byte gateway[] = {172,16,1,1};                       //Gateway ip
byte server[] = {172,16,1,4};                     //Server ip
#define port 80
char str[250];
 
const int buttonPin = 2;
//--------------------------------------------------------------------------------------
// SETUP
//--------------------------------------------------------------------------------------
void setup()
{  
  pinMode(buttonPin, INPUT);
  client_setup(mac,ip,gateway,server);    //Setup ethernet client
  
}
 
//--------------------------------------------------------------------------------------
// MAIN LOOP
//--------------------------------------------------------------------------------------
void loop()
{
  strcpy(str,"/emoncms/post.php?json=");                //URL
  srtJSON(str);                                 //Start JSON string
  addJSON(str,"D2",  digitalRead(buttonPin));    //Add a variable
  endJSON(str);                                 //End JSON string
  ethernet_send("",str);
}
 

 

bjalodia's picture

Re: how to add digital pin status in json








Dear Trystan,

I am trying to make school project in which I am trying to relate library room temperature and number of time door opened.

I am using temperature sensor LM35, arduino Duemilanove, enc28j60 ethernet module and enomcms

can you please help with this project

 

Guest's picture

Re: how to add digital pin status in json

Dear,

Where I found post.php for receive my ENC2860 informations ?

Please I need a Simple PHP receiver.

Best Regards,

JORGE ORENGO

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.