tou2 / iop Goto Github PK
View Code? Open in Web Editor NEWThe Internet of Plants workshop
Home Page: http://cairomakerspace.org
The Internet of Plants workshop
Home Page: http://cairomakerspace.org
Hi I can't get the code running.
Ethernet.2 seems to have an issue when compiling I can't figure out on my own.
Here is my error log:
Arduino: 1.8.1 (Mac OS X), Board: "Arduino/Genuino Uno"
/Users/Dirk/Desktop/IoP Audrino Projekt/Arduino_code/IoP_firm_v1_DHT/IoP_firm_v1_DHT.ino: In function 'void loop()':
IoP_firm_v1_DHT:95: error: 'client' was not declared in this scope
if (client.available())
^
IoP_firm_v1_DHT:102: error: 'client' was not declared in this scope
if (!client.connected() && lastConnected)
^
IoP_firm_v1_DHT:102: error: 'lastConnected' was not declared in this scope
Multiple libraries were found for "Dhcp.h"
if (!client.connected() && lastConnected)
Used: /Users/Dirk/Documents/Arduino/libraries/Ethernet2
^
Not used: /Applications/Arduino.app/Contents/Java/libraries/Ethernet
IoP_firm_v1_DHT:110: error: 'client' was not declared in this scope
Not used: /Applications/Arduino.app/Contents/Java/libraries/Ethernet
Not used: /Applications/Arduino.app/Contents/Java/libraries/Ethernet
if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
Not used: /Applications/Arduino.app/Contents/Java/libraries/Ethernet
^
IoP_firm_v1_DHT:110: error: 'lastConnectionTime' was not declared in this scope
if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
^
IoP_firm_v1_DHT:110: error: 'updateThingSpeakInterval' was not declared in this scope
if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
^
IoP_firm_v1_DHT:116: error: 'failedCounter' was not declared in this scope
if (failedCounter > 3 ) {startEthernet();}
^
IoP_firm_v1_DHT:117: error: 'lastConnected' was not declared in this scope
lastConnected = client.connected();
^
IoP_firm_v1_DHT:117: error: 'client' was not declared in this scope
lastConnected = client.connected();
^
/Users/Dirk/Desktop/IoP Audrino Projekt/Arduino_code/IoP_firm_v1_DHT/IoP_firm_v1_DHT.ino: In function 'void updateThingSpeak(String)':
IoP_firm_v1_DHT:121: error: 'client' was not declared in this scope
if (client.connect(thingSpeakAddress, 80))
^
IoP_firm_v1_DHT:121: error: 'thingSpeakAddress' was not declared in this scope
if (client.connect(thingSpeakAddress, 80))
^
IoP_firm_v1_DHT:126: error: 'writeAPIKey' was not declared in this scope
client.print("X-THINGSPEAKAPIKEY: "+writeAPIKey+"\n");
^
IoP_firm_v1_DHT:132: error: 'lastConnectionTime' was not declared in this scope
lastConnectionTime = millis();
^
IoP_firm_v1_DHT:138: error: 'failedCounter' was not declared in this scope
failedCounter = 0;
^
IoP_firm_v1_DHT:142: error: 'failedCounter' was not declared in this scope
failedCounter++;
^
IoP_firm_v1_DHT:151: error: 'failedCounter' was not declared in this scope
failedCounter++;
^
IoP_firm_v1_DHT:156: error: 'lastConnectionTime' was not declared in this scope
lastConnectionTime = millis();
^
/Users/Dirk/Desktop/IoP Audrino Projekt/Arduino_code/IoP_firm_v1_DHT/IoP_firm_v1_DHT.ino: In function 'void startEthernet()':
IoP_firm_v1_DHT:163: error: 'client' was not declared in this scope
client.stop();
^
IoP_firm_v1_DHT:171: error: 'mac' was not declared in this scope
if (Ethernet.begin(mac) == 0)
^
exit status 1
'client' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Here is the code from the project I try to use:
//loading libraries
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet2.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp2.h>
#include <util.h>
#include <SPI.h>
#include "DHT.h"
// Local Network Settings
#ifdef ETHERNET
byte mac[] = { 0xF4, 0x2B, 0xEF, 0xFF, 0xA0, 0xA1 }; // Must be unique on local network
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = "";
const int updateThingSpeakInterval = 16 * 1000; // Time interval in milliseconds to update ThingSpeak (number of seconds * 1000 = interval)
// Variable Setup
long lastConnectionTime = 0;
boolean lastConnected = false;
int failedCounter = 0;
// Initialize Arduino Ethernet Client
EthernetClient client;
#endif
//Defining arduino pins
#define DHTPIN A2 // what digital pin we're connected to
#define DHTTYPE DHT22
int moistsensPin0 = A1; // select the input pin for the moistuer sensor
int moistsensVal = 0; // variable to store the value coming from the sensor
int litsensPin0 = A0;
int litsensVal = 0;
// Initialize DHT sensor.
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
// Start Serial for debugging on the Serial Monitor
Serial.begin(9600);
dht.begin();
#ifdef ETHERNET
// Start Ethernet on Arduino
startEthernet();
#endif
}
void loop()
{
/*humidity and temperature/
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
float h = dht.readHumidity();
String humid = String (h);
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
String temp = String (t);
// Read temperature as Fahrenheit (isFahrenheit = true)
// float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
//if (isnan(h) || isnan(t) ) {
//Serial.println("Failed to read from DHT sensor!");
//return;
//}
/*Moistuer sensor/
//moistsensVal = analogRead(moistsensPin);
int moistsensVal = map(analogRead(moistsensPin0),0,1024,0,100);
String moistsensPin = String(moistsensVal);
//delay(1000);
// Serial.print("soil moistuer = " );
//Serial.println(moistsensVal);
/*light sensor/
//litsensVal = analogRead(litsensPin);
int litsensVal = map(analogRead(litsensPin0),0,1024,0,100);
String litsensPin = String(litsensVal);
// delay(1000);
// Serial.print("light sensor = " );
// Serial.println(litsensVal);
/////////////////////////////////////////////////////////////////////////////////////
// Print Update Response to Serial Monitor
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="+moistsensPin+"&field2="+litsensPin+"&field3="+temp+"&field4="+humid);
}
// 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\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+writeAPIKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");
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);
}
Any tips would be highly appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.