9. Input Devices¶
Hero Shot of the Week¶
Summary¶
First I needed to know which input devices I wanted to probe. I wanted them to be used for my final project so it somehow simplified my choices. Secondly I did some documentation to see how it works and what I need to know. Than there was the experimenting part with the input device.
Sometimes some headbanging the wall because I did not understand what was happening or that it was way more complicated than I had expected and so depression came.
Work Process¶
This week's music:
Calendar¶
Date | To be done | What was done |
---|---|---|
Thursday | - 10h local | - local all day |
Friday | - FabLab normal work | - FabLab work |
Saturday | - research & coding | |
Sunday | ||
Monday | - PCB production & 3D Printing | |
Tuesday | - FabLab normal work | - mic tests |
Wednesday | - 12h Local - 13h Regional - 15h Global |
- filling in empty space |
Introduction¶
Erwin did an introduction.
Analog signal:
- continuous signal
- values are sampled over time
- signal can be amplified
Digital signal:
- On / Off
ADC
- Analog to Digital Converter
- bit value is important
- more bits = more resolution = more processing time
- resistor network and comparators
- Internal Voltage Reference measurement
- Arduino ADC - How it works
GPIO
- General Purpose Input / Output
- 2 states : Low - High
- pull-up resistors might be needed to define an undefined state
Interface / Protocol
- communication between devices
- one-way VS two-way
- address, command, value
- ex:
- 1 wire / TWI
- I2C
- SPI
- PWM
- Serial
SI Units
CO2 and VOC Sensors - SGP30¶
First step was too look up some datasheet:
Than I followed this guide from AdaFruit on how to use this sensor.
I first needed to install the Adafruit SGP30 library.
Than I looked up (again) the pin layout as the example file wanted me to connect to SDA and SCL.
The sensor works but now I need to integrate it into my code. I also want to see if I can use it on other pins.
So I started to dissect the code.
I first looked up the wire library. This is for I2C communication.
The second thing that looked weird to me was uint16_t. Reading the following BadProg seems like it is just to define the bit value of the string that we want to use. In this case it is a string of 16bit.
Difference between Void and uint
I might rewrite me function, or maybe just a return x might work. But for now print is enough.
SGP30
I copy-pasted the example code given to my code. But there is two things that I will need to check later on.
- I will need a return value that I can send over to another microcontroller. For now I only print and not return any values...
- Can I have multiple sensors on the I2C channel (SDA and SCL pins) ? We were told that we are going to see that later on...
Other useful links
Sound Sensor¶
MAX4466 Microphone¶
While searching for the datasheet I have found a really nice article on how to use this microphone. The idea of the microphone is that I can measure the dB level of the rooms in the FabLab.
<- this part was added some days later
So I tried using the code given in the article. It works but in a weird way.
So when I snap my fingers the sound dips...
And it does not hear my background music playing...
Even when I put it next to my laptop sound bar...
But I can clearly hear my own music...
(check this weeks music at the top)
This was on 3.3V. Lets see what happens with 5V.
Same thing. Value dips when I snap.
So I changed all 1024 to 4096. This made thing look in a better way:
Snap test:
Background noise:
And it seems to change with my music too.
Now to only see how I can convert all this to noise level measurements.
worksafety 🙃
->
Datasheet here
Before trying out the code given in the previous article I wanted to found out how to calculate the dB level. I know that it is a logarithmic scale but I have no clue how I go from an analog value from a microphone to the dB level. I have found several interesting pages.
What the heck...
There is at least 3 different dB...
dB, dBA, dBC
Seems like I also will need to calibrate each mic & microprocessor...
It seems that he did not do the noise measurement part :/
He used a complete system (KY-037) and not just a mic :/
I might get somewhere with this one.
This just getting more complicated...
WAIT !!!!
I have that same mic too (almost) !!!
ICS-43434 Microphone¶
The first issue with using it is that I am at home and there are no pins soldered to it yet...
(I have a box of electronics that I can play with, with me)
YAY
I soldered the pins upside down !
I should have check the guide first...
I can unsolder and resolder.
Done.
Lets continue.
Now I need to know if the ESP32-S3 does I2S (not to be mixed with I2C) communication.
It does
but here the mic id connected directly with the B2B connector...
Looking at the pin layout it seems that we have TX and RX connectors.
Really good examples here
Well.
I got the following error in arduino IDE
Compilation error: I2S.h: No such file or directory
but the doc
says it is included in the basic install...
Further research says that it is in fact library version dependent. It is no longer present in newer versions of board manager libraries.
This code resulted in the following data:
This is in real speed. No acceleration. Only scaled down to be in the KB range.
I checked but I did not understand what is happening in the code... But it send the data over to a server. That could be useful for later on.
Maybe I should go back to the previous, simpler mic...
CO2, T and Humidity Sensor - Sensirion SCD30¶
The two library that I added are
- Sensirion I2C SCD30
- sparkfun/SparkFun SCD30 Arduino Library
So I took the example given and modified it to make it compatible with my code.
SCD30
CO2, Temperature & Humidity Sensor - SCD30 | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
Other Sensirion projects:
3D Printing¶
So for each of my sensors I made a 3D "case" so that I can put them into my giant breadboard.
So for the SCD30 Sensor my soldering wasn't straight so the sensor hit the case (left bottom and right bottom). For me 3D printing is easier than soldering so instead of straightening my soldering I just made a new case with bigger error acceptance / space. In the end I made 3 iterations on the case (left top is the last iteration).
In this image you can see that I soldered the ICS microphone in the wrong direction.
I tried to make a general case & sensor PCB so I can switch them more easily. The idea is that my work is not not sensor specific and is (supposed to be) modular.
Learning Outcome¶
Sometimes it is more complicated than just plug&play.
🥲
Digital Files and Links¶
- Well-Automated Arduino Library
- Adrianino
- ICS-43434 KiCAD
- ICS-43434 FreeCAD + stl
- SDC30 KiCAD
- SDC30 FreeCAD + stl
- SGP30 KiCAD
- SGP30 FreeCAD + stl
- VMA320 KiCAD
- VMA320 FreeCAD + stl
Assignment Check¶
- group assignment:
- probe an input device's analog levels and digital signals
- Done
- probe an input device's analog levels and digital signals
- individual assignment:
- measure something: add a sensor to a microcontroller board that you have designed and read it
- Done
- measure something: add a sensor to a microcontroller board that you have designed and read it