> For the complete documentation index, see [llms.txt](https://docs.launchboard.app/cxd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.launchboard.app/cxd/cxd-2022-summer-workshops/programming-workshops/internet-of-things/program-for-iot-part-1.md).

# Program for IoT Part 1 ⏱

Getting Started with Programming the IoT Device

## Introduction

{% embed url="<https://www.loom.com/share/0fdf84f422274bb6827421523b66c483>" %}

## Claiming Your IoT Device

This video steps you through claiming a particle device and setting up WIFI. You will want your mobile phone to complete this with the Particle App installed. \
Apple: <https://apps.apple.com/us/app/particle-iot/id991459054>\
Android: <https://play.google.com/store/apps/details?id=io.particle.android.app&hl=en_US>

{% embed url="<https://www.youtube.com/watch?index=2&list=PLIeLC6NIW2tKvC5W007j_PU-dxONK_ZXR&v=xymSayKBGbg>" %}

## IoT Tutorial - Programming the Device

We will use the Particle tutorial for the IoT kit linked below to guide us, but the videos will deviate a bit to demonstrate things using the web programming environment. Ultimately we want to get familiar with the hardware, inputs, sensors, and programming. ★ **Post questions and successes in our Slack channel as you move along.**

{% embed url="<https://docs.particle.io/quickstart/isk-project/>" %}

{% hint style="warning" %}

#### **Understanding LED Status Signals**

**This link comes in very handy for interpreting the different status LED signals you may get from time to time.** [**https://docs.particle.io/troubleshooting/led/argon/**](https://docs.particle.io/troubleshooting/led/argon/)
{% endhint %}

### **Reading Temperature and Humidity**

We are covering concepts from the ***Particle Variables: measure temperature & humidity*** section of the tutorial. <https://docs.particle.io/quickstart/isk-project/#particle-variables-measure-temperature-amp-humidity>

{% embed url="<https://www.loom.com/share/34d091fc693f443096531d8b050f9b25>" %}

#### 1. Create a new program in Particle build.

#### 2. Connect the temperature and humidity sensor to D2, and have your Argon device connected.

![](https://3503815932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKaUwYmDa4QuxXnmkymd5%2Fuploads%2F1VCdeAN72adPeMHzsugf%2Fimage.png?alt=media\&token=954d256f-a49c-4f04-ae51-54341d8f4b84)

#### 3. Include the "**GROVE\_TEMPERATURE\_AND\_HUMIDITY\_SENSOR" library in your program.**

#### 4. Copy and paste the code below (except of the #include part) into your program.

```arduino
// This #include statement was automatically added by the Particle IDE.
#include <Grove_Temperature_And_Humidity_Sensor.h>

DHT dht(D2);

double temp_dbl, humidity_dbl;

void setup() {
    Serial.begin(9600);

    dht.begin();
    
    Particle.variable("temp", temp_dbl);
    Particle.variable("humidity", humidity_dbl);
}

void loop() {
    float temp, humidity;

    temp = dht.getTempFarenheit();
    humidity = dht.getHumidity();

    temp_dbl = temp;
    humidity_dbl = humidity;

    delay(10000);
}
```

**5. Save, Verify, and Flash the code to the Argon board.**

**6. Open the Console from particle build, select "my devices", and select your Argon.**

**7. Get the temp and humidity variables to check if all is working.**

![](https://3503815932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKaUwYmDa4QuxXnmkymd5%2Fuploads%2FyBlou7h0udTFm0QvdmrF%2Fimage.png?alt=media\&token=9c8edbde-cdf1-4a2f-9900-fbdd5f0f98ce)

#### That's it for this step 🎉. If you are having any problems, no worry, post in our slack channel. Please share your code when it makes sense or create videos.

### Controlling an LED

We are covering concepts from the ***Particle Functions: controlling a Chainable LED*** section of the tutorial. <https://docs.particle.io/quickstart/isk-project/#particle-functions-controlling-a-chainable-led>

{% embed url="<https://www.loom.com/share/e4a768da42d64a3f8a894f8be689437b>" %}

Instructions coming soon...

#### 1. Create a new program in Particle build.

#### 2. Connect the Grove Chainable LED to A4, and have your Argon device connected.

![](https://3503815932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKaUwYmDa4QuxXnmkymd5%2Fuploads%2Fw4COs8EjUYpr32gynZlK%2Fimage.png?alt=media\&token=4f907dd0-15d7-486a-92e6-accf578fb9db)![](https://3503815932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKaUwYmDa4QuxXnmkymd5%2Fuploads%2Ff1KuWXBRBTzNQJglkc9T%2Fimage.png?alt=media\&token=2a7c9739-886d-4df0-bdbc-48881b04a36d)

#### 3. Include the "Grove\_ChainableLE&#x44;**" library in your program.**

#### 4. Copy and paste the code below (except of the #include part) into your program.

```arduino
// This #include statement was automatically added by the Particle IDE.
#include <Grove_ChainableLED.h>
ChainableLED leds(A4, A5, 1);

void setup() {
    leds.init();
    leds.setColorHSB(0, 0.0, 0.0, 0.0);
    Particle.function("toggleLed", toggleLed);
}

void loop() {
    // toggleLed("");
}

int toggleLed(String args) {
    leds.setColorHSB(0, 0.0, 1.0, 0.5);
    delay(500);
    leds.setColorHSB(0, 0.0, 0.0, 0.0);
    delay(500);
    return 1;
}    
```

**5. Save, Verify, and Flash the code to the Argon board.**

#### **6. Open the Console from particle build, select "my devices", and select your Argon.**

#### **7. Call the** toggleLed function to pulse the LED one time.

![](https://3503815932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKaUwYmDa4QuxXnmkymd5%2Fuploads%2Fn1ClEBG4CvSa2HsJOGnj%2Fimage.png?alt=media\&token=2d5631ce-d94d-45bb-a702-1b39b4d8c32c)

#### That's it for this step 🎉. If you are having any problems, no worry, post in our slack channel. Please share your code when it makes sense or create videos.

### Reference Material for the IoT Kit Hardware

<https://docs.particle.io/quickstart/isk-project/#appendix-grove-sensor-resources>

{% embed url="<https://docs.particle.io/quickstart/isk-project/#appendix-grove-sensor-resources>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.launchboard.app/cxd/cxd-2022-summer-workshops/programming-workshops/internet-of-things/program-for-iot-part-1.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
