This is an old revision of the document!
Table of Contents
Sensors and Communication
Welcome to Day 2 of our IoT Workshop! Today, we'll take a closer look at sensors, the backbone of IoT data collection. You'll gain insights into how sensors operate and discover key protocols like Analog, OneWire, and I2C that facilitate communication between devices and sensors. This foundational knowledge will empower you to effectively utilize sensors in your IoT projects.
1. Output - PWM
Now, we're stepping into the practical aspect of our workshop, focusing on Pulse Width Modulation (PWM) output with the ESP8266. PWM isn't just about adjusting the brightness of an LED; it's a versatile method of communication. Through this segment, you'll grasp how PWM operates as a form of control, allowing us to transmit information using varying pulse widths. This will come to life as we demonstrate PWM in action, using an attached LED as an illustrative example.
Fig. 1: ESP8266 with LED - Schematic
Fig. 2: ESP8266 with LED - Breadboard
2. Libraries
In the dynamic landscape of Arduino development, libraries play a pivotal role, especially when it comes to effective communication with sensors. These compact packages of pre-written code provide an invaluable resource, simplifying the process of interfacing with various sensors and components.
For IoT enthusiasts and makers, libraries serve as a bridge between complex hardware and user-friendly coding. By abstracting the intricate details of sensor communication, libraries empower you to focus on the application logic rather than low-level protocol intricacies.
Remember, in the Arduino world, libraries are your trusted companions, facilitating smooth communication and opening doors to limitless possibilities.
3. Inputs / Protocols
3.1. Analog sensors (ex. capacitive soil moisture sensor)
Through a special circuit, the sensor is able to translate from the soil moisture around it to an analog output voltage. The sensor consists of a PCB with a long thick trace on one end. If you want to learn more about this sensor you should read the following article: How Capacitive Soil Moisture Sensors Work by rbaron.
With these common sensors, we don´t need to reinvent the wheel. There are plenty of good tutorials out there on how to use this sensor. One we link here: Capacitive Soil Moisture Sensor - DFRobot Wiki There you will be able to learn how to integrate the sensor into your software as well as how to use it in the real world. Just keep in mind the electronics on top are not protected from the environment. Water shouldn't touch that part!
3.2. 1-Wire (ex. temperature sensor)
One-Wire is a protocol that is heavily used by the company Maxim Integrated. One of the most popular sensors using this protocol is the (deprecated) DS18B20. It is an easy-to-use temperature sensor, that is available in multiple different form factors. In this workshop we use two different variants:
- Water-Proof DS18B20
- DS18B20 on a PCB
3.3. I2C (ex. ToF sensor)
- Here you can find a library for the sensor: Adafruit VL53L0X