Categories
TUTORIALS

PUSH SENSOR DATA ONTO ADAFRUIT IO

The term Internet of Things (IoT) is somewhat fuzzy but gets thrown around a lot – at the end of the day, it’s really just the idea of connecting things to the Internet and each other. This tutorial will cover how to do the former – connecting things (i.e. your Arduino board) to the Internet. By the end of this tutorial, you will be able to connect your Arduino to the Internet and publish photoresistor sensor data onto the Adafruit IO system.

*This tutorial is adapted from Adafruit tutorials.  (Part I + Part II)

WHAT YOU NEED:

  • ADAFRUIT ATWINC1500 WIFI BREAKOUT (GET IT HERE)
  • ARDUINO UNO R3
  • BREADBOARD
  • SOLDERING KIT
  • PHOTORESISTOR
  • 10K OHM RESISTOR
  • A BUNCH OF JUMPER WIRES

PART I | CONNECT TO THE INTERNET

1.1  ATWINC1500 WIFI BREAKOUT BOARD | ASSEMBLY
Adafruit ATWINC1500 WiFi Breakout will come with a header strip.

a) Insert the header strip onto your breadboard – long pins down  (you may also choose to snap off the header strip to the length to match that of the breakout board)

long pins down

b) Place the breakout board over the pins so that the short pins poke through.

add the breakout board

c) Set up your soldering kit (for instructions on how to solder, read  adafruit’s awesome guide to soldering or watch this video, brought to you by, yes, adafruit again.

set up soldering kit

d) Solder all the pins to corresponding breakout pads. Check your solder joints. (if you messed up, dw – watch adafruit’s  desoldering video)

solder all the pins
check your joints (may need desoldering)
1.2 ATWINC1500 WIFI BREAKOUT BOARD | WIRING
ATWINC1500 wiring

*wiring/pin assignments assuming you are using Arduino UNO

  • Vin – connect this to 5V
  • GND – connect to common ground
  • SCK – Connect to SPI clock.                              (pin #13)
  • MISO – Connect to SPI MISO.                         (pin #12)
  • MOSI – Connect to SPI MOSI.                         (pin #11)
  • CS – Connect to any digital I/O pin               (pin #8 by default)
  • EN – connect this to 5V (if you’re using UNO)
  • IRQ – Connect to any digital I/O pin, preferably one with an interrupt capability.                                               (pin #7 by default)
  • RST – Connect to any digital I/O pin.            (pin #4 by default)
1.3 ATWINC1500 WIFI BREAKOUT BOARD | CODE TO SET UP AND TEST CONNECTION TO THE INTERNET

a) Download and install the WiFi101 library.

b) Open Arduino IDE and load  File/Examples/WiFi101/CheckWifi101FirmwareVersion sketch

c) Add the line of code below to the beginning of void setup()

d) Upload to Arduino, open up serial monitor, set baud rate to 9600 baud. You should able to see your firmware version. If you get Check result: NOT PASSED, hang in there. Else, skip to f).

e) Follow this tutorial to update your firmware to get your ATWINC1500 firmware back in sync with newer versions of the WiFi101 library.

***Note: If your firmware is still out of date even after following the steps in the tutorial above, download the latest (as of 11/11/17) release of the WiFi-Firmware-Updater-Plugin from this link, unpack the zip archive into tools folder – create one if it doesn’t exist yet – within your Arduino folder. It should look something like /Arduino/tools/WiFi101/tool/WiFi101.jar. Restart Arduino IDE and redo the tutorial in step e) again.

f) Yay! Your ATWINC1500 firmware is in sync with the WiFi101 library. You should see Check result: PASSED.

g) Your ATWINC1500 is ready to scan for available networks. Open the ScanNetworks sketch in the examples folder. Add the line of code below to the beginning of void setup()

Upload the code to your Arduino and open up serial monitor. You should see a list of available networks.

h) Now you can finally connect your Arduino to the Internet! Open up the WiFi101WebClient sketch in the examples folder. Add the line of code below to the beginning of void setup()

Replace the ssid and pass variables with your network name and password.

Upload code to Arduino and open up serial monitor.

SUCCESS! 

Now that your Arduino is connected to the Internet, you can continue on to Part II, where you can start pushing photoresistor sensor data to Adafruit IO.

PART II | PUSHING PHOTORESISTOR SENSOR DATA TO ADAFRUIT IO

2.1   SET UP YOUR PHOTORESISTOR
  • Connect one side of the photoresistor to 5 Volts (5V)
  • Connect the other side of the photoresistor to ANALOG pin
  •  Connect a 10K Ohm resistor between ANALOG pin 0 and GND

Your breadboard should look something like this:

To make your own breadboard diagram with adafruit parts (e.g. the ATWINC1500),  download this folder and import part to fritzing.

2.2   ADAFRUIT IO LOGISTICS

a) Go to Adafruit IO and sign up for an account.

b) Log in, click on Feeds left column, click on the Actions dropdown to create a new feed called “photoresistorVal”

c) On the left column, click on View AIO Key. Copy the key and keep it handy. We will need this in a bit.

2.3   ADAFRUIT MQTT CODE

a) Download and install the Adafruit  MQTT library (place folder into your Arduino/libraries folder)

b) Open up Arduino IDE, copy and paste following code:

***Remember to replace ssid, pass, AIO_USERNAME, and AIO_KEY variables with your own network name, password, Adafruit IO username and Adafruit IO Key.

c) Upload to Arduino, open up serial monitor to check photoresistor sensor values. Log on to Adafruit IO, click on Feeds/photoresistorVal to see data logged. (Try shining a light at or covering the photoresistor to check if serial monitor/Adafruit IO is registering variations in light levels)

Tip: Under the Actions dropdown, there are options to download data as JSON or CSV.

SUCCESS!

aaaaand that’s it folks.

Leave a Reply

Your email address will not be published. Required fields are marked *