User Tools

Site Tools


latinet:unicaes:workshops:sensors-23

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
latinet:unicaes:workshops:sensors-23 [2023/08/29 23:40] jan.sonntaglatinet:unicaes:workshops:sensors-23 [2023/08/30 00:22] (current) jan.sonntag
Line 16: Line 16:
  
 Remember, in the Arduino world, libraries are your trusted companions, facilitating smooth communication and opening doors to limitless possibilities. Remember, in the Arduino world, libraries are your trusted companions, facilitating smooth communication and opening doors to limitless possibilities.
 +
 +Good-To-Know: Most libraries come with examples that can get you started quickly.
  
 ===== 3. Inputs / Protocols ===== ===== 3. Inputs / Protocols =====
Line 27: Line 29:
 <imgcaption image3|Wiring of the analog sensor>{{ :latinet:unicaes:workshops:capacitive-soil.png?400 |}}</imgcaption> <imgcaption image3|Wiring of the analog sensor>{{ :latinet:unicaes:workshops:capacitive-soil.png?400 |}}</imgcaption>
 <imgcaption image4|Schematic>{{ :latinet:unicaes:workshops:capacitive-soil_schem.png?600 |}}</imgcaption> <imgcaption image4|Schematic>{{ :latinet:unicaes:workshops:capacitive-soil_schem.png?600 |}}</imgcaption>
 +
 +We also prepared a little sketch for you. Try to understand it. A good way to do so is to look up function documentation in the Arduino Documentation:
 +
 +<file ino read-analog.ino>
 +// the setup routine runs once when you press reset:
 +void setup() {
 +  // initialize serial communication at 115200 bits per second:
 +  Serial.begin(115200);
 +}
 +
 +// the loop routine runs over and over again forever:
 +void loop() {
 +  // read the input on analog pin 0:
 +  int sensorValue = analogRead(A0);
 +  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 3.2V):
 +  float voltage = sensorValue * (3.2 / 1023.0);
 +  // print out the value you read:
 +  Serial.println("voltage: " + voltage);
 +  Serial.println("value: " + sensorValue);
 +  
 +  delay(1500);
 +}
 +</file>
  
 ==== 3.2. 1-Wire (ex. temperature sensor) ==== ==== 3.2. 1-Wire (ex. temperature sensor) ====
  
 +One-Wire is a bus 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
 +
 +The DS18B20 needs in a minimal setup at least one resistor between its data line and the high potential. The first variant we mentioned doesn´t come with this included so it needs to be added on the breadboard. The second one has it already on its PCB included so it is a bit easier to integrate.
 +
 +Here you can find some information that might be interesting for you, including a Datasheet for the sensors (if you get a new sensor -> READ THE DATASHEET), a more detailed look at the OneWire Protocol, and last but not least a Library that you can use to integrate the sensor in your system:
   * [[https://datasheets.stg-maximintegrated.com/en/ds/DS18B20.pdf | DS18B20 Datasheet ]]    * [[https://datasheets.stg-maximintegrated.com/en/ds/DS18B20.pdf | DS18B20 Datasheet ]] 
   * [[https://www.youtube.com/watch?v=lsikcaA7q-c | 1-Wire Technology Overview ]]   * [[https://www.youtube.com/watch?v=lsikcaA7q-c | 1-Wire Technology Overview ]]
   * [[https://github.com/milesburton/Arduino-Temperature-Control-Library|Library]]   * [[https://github.com/milesburton/Arduino-Temperature-Control-Library|Library]]
 +
 +Task: Try to get to research how to use the sensor with your MCU, regardless of which variant you have available.
  
 ==== 3.3. I2C (ex. ToF sensor) ==== ==== 3.3. I2C (ex. ToF sensor) ====
  
 +I2C is one of the most common sensor bus interfaces used. It requires 2 cables for communication. One is called SCL and the other is SDA. I2C in general is a serial interface. SCL is the serial clock. This is needed to synchronize the communication between two components. SDA is the actual serial data line. Here is where all the magic is happening. On one I2C bus, 127 slave devices can be attached. Therefore I2C is a master-slave protocol. The master will instantiate communication by calling for a specific address followed by a register it wants to read or write to, followed by some additional data in case of writing to a device. The slave device will give a response depending on the function called.
 +
 +The sensor used in the sensor is a ToF sensor called VL53L0X, which is able to measure distance pretty accurately.
 +
 +Have a look at the datasheet and the library:
   * [[https://www.st.com/resource/en/datasheet/vl53l0x.pdf | VL53L0X Datasheet ]]   * [[https://www.st.com/resource/en/datasheet/vl53l0x.pdf | VL53L0X Datasheet ]]
   * Here you can find a library for the sensor: [[https://github.com/adafruit/Adafruit_VL53L0X|Adafruit VL53L0X]]   * Here you can find a library for the sensor: [[https://github.com/adafruit/Adafruit_VL53L0X|Adafruit VL53L0X]]
  
-{{ :latinet:unicaes:workshops:tof_bb.png?400 |}}+<imgcaption image5|ToF Breadboard>{{ :latinet:unicaes:workshops:tof_bb.png?400 |}}</imgcaption> 
 + 
 +Task: Try to get the sensor to work with your microcontroller.
  
-==== 3.3. UART ====+==== 3.3. Good to know ====
  
 +Out there are more than just the protocols that we covered today. Here are some more that are worth researching if you are interested:
 +  * SPI
 +  * UART
 +  * Digital Interrupts
  
 ===== Recording ===== ===== Recording =====
  
-53 
latinet/unicaes/workshops/sensors-23.1693345251.txt.gz · Last modified: 2023/08/29 23:40 by jan.sonntag