No data on graph | Arduino | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
No data on graph
Avatar
SolarEst
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
1
November 17, 2016 - 6:33 am
sp_Permalink sp_Print

 Hello,

I'm trying to monitor my solar system usage with arduino, i can see that thingspeak is getting data by number on enteries, but there are no dots on graphs?

 

What might be wrong, here is the code:

 

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xD4, 0x28, 0xB2, 0xFF, 0xA0, 0xA1 };
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = "*************************;
const int updateThingSpeakInterval = 20 * 1000;
long lastConnectionTime = 0;
boolean lastConnected = false;
int failedCounter = 0;
EthernetClient client;

//Amprite lugemine ACS712

const int analogIn = A9;
int mVperAmp = 66;
int RawValue= 0;
int ACSoffset = 2500;
double Voltage = 0;
double Amps = 0;

//Voltide lugemine 68k/10k divider

int analogInput = A8;
float vout = 0.0;
int vin = 0.0;
float R1 = 68600.0;
float R2 = 10000.0;
int value = 0;

//Watid

int watid = 0;

/////////////////////////////////////////////////////////////////

void setup(){
pinMode(analogInput, INPUT);
Serial.begin(9600);
startEthernet();
}

/////////////////////////////////////////////////////////////////

void loop(){

watid = (Amps * vin);

RawValue = analogRead(analogIn);
Voltage = (RawValue / 1024.0) * 5000;
Amps = ((Voltage - ACSoffset) / mVperAmp);
if (Amps<0.1){
Amps=0;
}
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
if (vin<0.09) {
vin=0.0;
}
if (client.available())
{
char c = client.read();
Serial.print(c);
}

// Disconnect from ThingSpeak
if (!client.connected() && lastConnected)
{
Serial.println("...disconnected");
Serial.println();

client.stop();
}

// Update ThingSpeak
if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
{
updateThingSpeak("field1="+vin);

updateThingSpeak("field3="+watid);
}

// Check if Arduino Ethernet needs to be restarted
if (failedCounter > 3 ) {startEthernet();}

lastConnected = client.connected();
}

void updateThingSpeak(String tsData)
{
if (client.connect(thingSpeakAddress, 80))
{
client.print("POST /update HTTP/1.1
");
client.print("Host: api.thingspeak.com
");
client.print("Connection: close
");
client.print("X-THINGSPEAKAPIKEY: "+writeAPIKey+"
");
client.print("Content-Type: application/x-www-form-urlencoded
");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("

");

client.print(tsData);

lastConnectionTime = millis();

if (client.connected())
{
Serial.println("Connecting to ThingSpeak...");
Serial.println();

failedCounter = 0;
}
else
{
failedCounter++;

Serial.println("Connection to ThingSpeak failed ("+String(failedCounter, DEC)+")");
Serial.println();
}

}
else
{
failedCounter++;

Serial.println("Connection to ThingSpeak Failed ("+String(failedCounter, DEC)+")");
Serial.println();

lastConnectionTime = millis();
}
}

void startEthernet()
{

client.stop();

Serial.println("Connecting Arduino to network...");
Serial.println();

delay(1000);

// Connect to network amd obtain an IP address using DHCP
if (Ethernet.begin(mac) == 0)
{
Serial.println("DHCP Failed, reset Arduino to try again");
Serial.println();
}
else
{
Serial.println("Arduino connected to network using DHCP");
Serial.println();
}

delay(1000);
}

Avatar
Vinod

Forum Posts: 183
sp_UserOfflineSmall Offline
2
November 18, 2016 - 10:16 am
sp_Permalink sp_Print

What is your channel number? 

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: jacktheripper125, pudderz
24 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

bbruno22

pudderz

Utkya

Poornak26

LindasHed

reddysiva

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee