Hardware Reference
In-Depth Information
Make sure that whenever you touch any part of the project, the power plug is disconnec-
ted from the wall socket. There could be a bare cable exposed on your project and it can
become very dangerous if you work on your project while it's on.
Note
Of course, all the code for this first test sketch is available on the GitHub repository of the
project at https://github.com/openhomeautomation/arduino-home-automation/tree/master/
chapter2 , inside the relay_test folder.
We can now work on the next step, which is actually building the final sketch for our pro-
ject. At this point, we are simply going to test if the CC3000 Wi-Fi chip is working, and
check if we can command the relay wirelessly.
We start by declaring the correct libraries for our project:
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <CC3000_MDNS.h>
#include <aREST.h>
We also need to specify which pins the CC3000 chip is connected to. If you followed the
hardware configuration section, you should have nothing to change here:
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
Then, we have to declare the CC3000 chip instance from the CC3000 library, along with
the right pins that we just defined:
Adafruit_CC3000 cc3000 =
Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ,
ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);
Then, there are some parameters you actually need to modify so the chip knows which
Wi-Fi network to connect to. You have to enter your Wi-Fi network SSID and password:
Search WWH ::




Custom Search