I followed the Wifi Weather station tutorial with the CC3000 and it works great. Only issue I have is after a couple of minutes, the arduino just hangs. It starts working if I power it down and back up. Any ideas?
Arduino Uno
Wifi CC3000
DHT22
Thanks,
Zalez
Wifi Weather Station Help
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Wifi Weather Station Help
Could you post clear pictures of your board and the connections to it?
Could you post your code and a description or drawing of your connections between it all?
Please use the code button "</>" as shown below.
Could you post your code and a description or drawing of your connections between it all?
Please use the code button "</>" as shown below.
- Attachments
-
- Code Button.jpg (4.49 KiB) Viewed 352 times
- zalez
- Posts: 4
- Joined: Tue Jul 29, 2014 4:18 pm
Re: Wifi Weather Station Help
Sorry for the picture. The code works, I get the information from the arduino. The arduino just stops sending after a couple minutes. Like it gets hung up trying to connect. I followed Marco's tutorial and the connections should all be good.
Code: Select all
/*
* Simple WiFi weather station with Arduino, the DHT11 sensor & the CC3000 chip
* Part of the code is based on the work done by Adafruit on the CC3000 chip & the DHT11 sensor
* Writtent by Marco Schwartz for Open Home Automation
*/
// Include required libraries
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include "DHT.h"
// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
// WiFi network (change with your settings !)
#define WLAN_SSID "Testing" // cannot be longer than 32 characters!
#define WLAN_PASS "123456789a"
#define WLAN_SECURITY WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
// DHT11 sensor pins
#define DHTPIN 7
#define DHTTYPE DHT22
// Create CC3000 & DHT instances
DHT dht(DHTPIN, DHTTYPE);
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIV2);
// Local server IP, port, and repository (change with your settings !)
uint32_t ip = cc3000.IP2U32(192,168,0,1);
//uint32_t ip = 0;
int port = 80;
String repository = "/tech/";
#define WEBSITE "www.mysite.org"
void setup(void)
{
// Initialize DHT sensor
dht.begin();
Serial.begin(115200);
// Initialise the CC3000 module
if (!cc3000.begin())
{
while(1);
}
// Connect to WiFi network
cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
Serial.println("Connected to WiFi network!");
Serial.println(ip);
// Check DHCP
Serial.println(F("Request DHCP"));
while (!cc3000.checkDHCP())
{
delay(100);
}
ip = 0;
// Try looking up the website's IP address
Serial.print(WEBSITE); Serial.print(F(" -> "));
while (ip == 0) {
if (! cc3000.getHostByName(WEBSITE, &ip)) {
Serial.println(F("Couldn't resolve!"));
}
delay(500);
}
cc3000.printIPdotsRev(ip);
Serial.print(ip);
}
void loop(void)
{
// Measure the humidity & temperature
float h = dht.readHumidity();
float t = dht.readTemperature();
// Transform to String
String temperature = String((int) t);
String humidity = String((int) h);
// Print data
Serial.print("Temperature: ");
Serial.println(temperature);
Serial.print("Humidity: ");
Serial.println(humidity);
Serial.println("");
// Send request
String request = "GET "+ repository + "sensor.php?temp=" + temperature + "&hum=" + humidity + " HTTP/1.1\r\n";
send_request(request);
// Update every second
delay(5000);
}
// Function to send a TCP request and get the result as a string
void send_request (String request) {
// Connect
Serial.println("Starting connection to server...");
Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);
// Send request
if (client.connected()) {
client.print(request);
client.print("Host: mysite.org\r\n");
client.print("User-Agent: arduino-ethernet\r\n");
client.print("Connection: close\r\n\r\n");
Serial.println("Connected & Data sent");
}
else {
Serial.println(F("Connection failed"));
}
while (client.connected()) {
while (client.available()) {
// Read answer
char c = client.read();
}
}
Serial.println("Closing connection");
Serial.println("");
client.close();
}
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Wifi Weather Station Help
One thing to look at is you are connecting and disconnecting your device every 5 seconds. You might consider not connecting and using checkConnected to make sure you are and if not reconnect. Also, for the data you are sending (temp humidity) 5 seconds between readings is way too often. 1 to 5 minutes would be enough unless you were wanting to catch that solar flare incident where the world is finally destroyed.
- zalez
- Posts: 4
- Joined: Tue Jul 29, 2014 4:18 pm
Re: Wifi Weather Station Help
I did increase the time for the interval on sending data. I guess if I really wanted to check for that armageddon solar flare, It would be too late any way! lol. In the end, I finally found the posts about enabling the watch dog and that has done the trick so far.
Please be positive and constructive with your questions and comments.