WORKSHOP: DIY sensing assemblage for designers
This workshop is intended for designers with the particular interest in collecting urban/environmental data with Arduino-based, low-tech sensing assemblage. The workshop will assume the attendants without any previous knowledge and experience with coding and electronics. Only basic concepts and examples will be introduced during the workshop, but online tutorials and resources will be provided: the workshop is more about methodology rather than skill.
Laptop/computers with Arduino IDE installed.Download and install from https://www.arduino.cc/en/Main/Software
- Chicago Electronic Distributors
- This is a big distributor who would buy sensors/boards from other platforms such as Adafruit. They also have a cheaper shipping fee.
- Adafruit sells the most of the sensors and boards you can think of. The best part about Adafruit is that every product they sell has extensive tutorials and examples in the forum. And they also make breakout boards, which have already been customized to be more user-friendly by Adafruit. So, before trying anywhere else, check out adafruit first. You don’t want to buy a sensor without knowing how to use it unless you are an expert or work with one.
- Besides the Arduino boards and regular sensors, DFRobot has a good number of air-related sensors such as CO2, CO, pmm2.5 and etc.
- You know what it is. Amazon does have a good number of wires and sensors you can buy, but do watch for crappy replicas.
- Adafruit IO
- A user-friendly IOT developing platform for beginners.
Section 1: Basics and Sensing Example
Arduino board designs use a variety of microprocessors and controllers. The boards are equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to various expansion boards (shields) and other circuits. –Arduino Wikipedia Page
- Arduino is different from Raspberry Pi, the latter is a fully functional computer, but Arduino is a micro-controller. It means that it can run only one program at a time, over and over again. But this program can be really complex, and we can upload different programs with Arduino IDE.
- Aruidno IDE is where we write our program and communicate with the Arduino boards. A program is called a “sketch” in Arduino world. It’s not unlike a .gh file in grasshopper.
- Power: The board can be supplied with power either from the DC power jack (7 – 12V), the USB connector (5V), or the VIN pin of the board (7-12V). The sensors will draw power from the boards, either 3V or 5V.
Input vs. Output and Analog vs. Digital
- Arduino has inputs and outputs. A pin can either be an output pin, or input pin. We can specify that in the code.
- There are two types of input: analog and digital. An output is digital only, but we can simulate analog outputs.
- Accordingly, there are analog sensors and digital sensors. An analog sensor will only give you numbers from 0-1023. You need to calibrate the analog sensor or find equations from the sensor’s data sheet/online tutorial to figure out what the numbers represent.For example, an analog temperature sensor will give you a piece of data “556”. You can use a thermometer to measure the actual temperature, say 75 °F, then you can know 556 = 75 °F. Or you can check if someone else online has the function for this analog temperature sensor to calculate the real temperature.
- Arduino uses a language that based on C and C++.
- Digital sensors usually have a more complicated library (we will learn this concept later) come with it. Using the libraries, you can directly read the data you want.
- Library: a library is a set of pre-defined functions created by other people (like components in Grasshopper). Once you have referenced a library, you can use the functions in it without writing your own. In Arduino world, we rely heavily on libraries and their examples. You don’t have to write your own code at all to create a sensing device. All you need to do is just copying and pasting codes from multiple examples: not unlike what you do in Grasshopper.
- Wire up your DHT11 sensor module and your Arduino as shown in the diagram below. Note: on the DHT11 sensor, GND is connected to GND pin, VCC is connected to power pin, and DATA is connected to pin 8. Usually, a sensor has a power pin (VCC), a ground pin (GND), and a data pin. Some sensors are using I2C protocol, using SDA and SCL pins. We will talk about I2C in the future workshops.
- If you are not using a DHT module, you need a 1k resistor and wire up as in the diagram below. (Google “resistor color code” to figure out the resistor value.)
- Connect your Arduino to your computer through USP port. Open Arduino IDE. Go to Tools > Board and select Arduino/Genuino Uno, this is the board you are currently using now.
- Then go to Tools > Port and select your board. The name might be different between Windows and Mac. On a Windows, it may be COM4, COM3, etc.
- After that, you can write your code! But we are not going to write anything by ourselves today. Go to Sketch > Include Library > Manage Libraries… Search “DHT” in the new window. And install DHT sensor library by Adafruit. It will install the library and example sketches. Similarly, search and install “Adafruit Unified Sensor” library. It should be the last on in the search list.
- Then go to File > Examples > DHT sensor library > DHT_Unified_Sensor.
- In the code, change the following lines:
- “#define DHTPIN 8 // Pin which is connected to the DHT sensor.” Change 2 into 8, which is the digital pin you connected in the first step.
- Comment “#define DHTTYPE DHT22 // DHT 22 (AM2302)” and Uncomment “//#define DHTTYPE DHT11 // DHT 11”. In Arduino language, type in “//” in front of a line to comment a line of code. Lines being commented will not be compiled to the Arduino.
- Now click the upload button to upload the code to the Arduino board’s memory. Once done, the Arduino will start running automatically.
- Click Serial Monitor button and make sure it is 9600 baud (this is the one you specified in the code). Now you should see the data is being collected. We are only monitoring the data through serial monitor now. We will talk about how to log the data onto an SD card in the future workshops.