0

NEED HELP WITH CODE
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

NEED HELP WITH CODE

by sarahbellum on Mon Jan 09, 2017 9:06 am

I am trying to make the wifi weather station with the ATWINC1500 wifi chip instead of the CC3000 chip (which is discontinued). I can't get the code to work though. I am trying to use the code from the tutorial and replace the CC3000 code with the ATWINC1500 code but again it's not working. Here is what I have so far.



Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_Sensor.h>



/*
   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
*/
// Number of variables & functions

// #include <Adafruit_Sensor.h>
// Include required libraries for breakout
#include <SPI.h>
#include <WiFi101.h>

// Include required libraries for DHT sensor
#include <DHT.h>
#include <DHT_U.h>

#include <SPI.h>
#include <string.h>
#include "DHT.h"

// WiFi network (change with your settings !)
char ssid[] = "CLSLabs"; //  your network SSID (name)
char pass[] = "password";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "www.google.com";    // name address for Google (using DNS)
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;



// DHT22 sensor pins
#define DHTPIN 2
#define DHTTYPE DHT22

// Create CC3000 & DHT instances
DHT dht(DHTPIN, DHTTYPE); //just the DHT instance is needed here


void setup()
{
  //Configure pins for Adafruit ATWINC1500 Feather
  WiFi.setPins(8, 7, 4);

  // Start Serial
  Serial.begin(9600);

  // Initialise the serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: http://www.google.com");
    client.println("Connection: close");
    client.println();
  }
  {
    // Initialize DHT sensor
    dht.begin();

    Serial.begin(115200);
  }
}



void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();

    // do nothing forevermore:
    while (true);
  }

  {
    // Measure the humidity & temperature
    float h = dht.readHumidity();
    float t = dht.readTemperature();
   
    // Transform to String
    String temp = String((int) t);
    String hum = String((int) h);
   
    Serial.print("Temperature: ");
    Serial.println(temp);
    Serial.print("Humidity: ");
    Serial.println(hum);
    Serial.println("");
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}
Last edited by sarahbellum on Mon Jan 09, 2017 9:47 am, edited 2 times in total.

sarahbellum
 
Posts: 23
Joined: Mon Oct 03, 2016 1:56 pm

Re: NEED HELP WITH CODE

by sarahbellum on Mon Jan 09, 2017 9:39 am

I don't know if I need to include the aRest library and have an instance for the ATWINC1500 chip

sarahbellum
 
Posts: 23
Joined: Mon Oct 03, 2016 1:56 pm

Re: NEED HELP WITH CODE

by franklin97355 on Mon Jan 09, 2017 1:35 pm

Take a look at some of the WINC1500 example code to get a feel of how it is done and then build on that rather than the other way around.

franklin97355
 
Posts: 19227
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: NEED HELP WITH CODE

by sarahbellum on Mon Jan 09, 2017 9:05 pm

I have tried doing that already but thank you.

sarahbellum
 
Posts: 23
Joined: Mon Oct 03, 2016 1:56 pm

Re: NEED HELP WITH CODE

by sarahbellum on Thu Jan 12, 2017 4:56 pm

Does anyone know if I need to use the aRest library even though it's with the WINC1500 chip?

sarahbellum
 
Posts: 23
Joined: Mon Oct 03, 2016 1:56 pm

Please be positive and constructive with your questions and comments.