Elektroda.com
Elektroda.com
X

Search our partners

Find the latest content on electronic components. Datasheets.com
Elektroda.com

Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB.

TechEkspert 9342 18
This content has been translated » The original version can be found here
  • Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB.
    As part of the ongoing competition contest at elektroda.pl there is a chance to get an Arduino Uno module, the module is equipped with an ATMega328P microcontroller clocked with a 16MHz quartz resonator, 5V power supply. There is a USB-B socket on the board that allows for power supply and communication (sending the program from the Arduino environment, or communication with the running program). The DC socket allows for power supply with voltage higher than 5V (AMS1117 stabilizer). The board is equipped with a USB UART converter, which facilitates integration with the Arduino environment. Connectors on the board allow you to connect expansion modules (shield). On the board, there are LEDs informing about the presence of power, activity on the RX / TX lines of the UART interface and the LED connected to the D13 pin. The microcontroller and its I / O ports work with a voltage of 5V, additionally there is a 3.3V supply voltage, however, care should be taken to convert logic levels for systems powered by voltages other than 5V. There is a reset button on the Arduino Uno board, the ISP connector allows you to put the program using the programmer, using ISP you can change the fusebit settings of the microcontroller (e.g. change the clock source to the internal RC generator) and even give up the bootloader or Arduino environment and send the compiled code written in e.g. Atmel Studio 7.0. The USB UART CH340 converter was used and if there is no driver in the system, they are available on the manufacturer's website:
    information about CH340
    documentation
    Windows drivers
    Linux drivers
    If the driver is installed correctly, a new serial COM port will appear in the system after connecting the module.

    We are downloading the current version of the Arduino environment, (currently 1.8.4 ),
    then create a new program (sketch) and select the Arduino / Genuino Uno board:
    Tools-> Board-> Arduino / Genuino Uno
    Next:
    Tools-> Port-> and select the COM port on which is the board connected to the USB.

    Arduino Uno schematic - source .

    For the first attempts to flash the LED, you can use sample programs made of material o Arduino nano. you will find there examples of how to flash the LED, how to smoothly change the LED brightness and how to flash the RGB LED to the beat of the music.

    Humidity and temperature sensor AM2302 (DHT22)
    The AM2302 sensor can work with voltages of 3.3-5.5V, it has 4 pins (one unused). Three outputs are used as power supply (1), data transmission (2), and ground (4), more you can find in the catalog note: AM2302 .
    The pin used for data transmission should be connected to the power supply through a 5.1kom resistor, DHT22 often appears as a module mounted on a board with three pins, usually on the board there is a resistor pulling the pin "data" to "+", so in the case of a module to connect to Arduino it is enough only three wires (power, data, ground).
    Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB.
    The length of the connection cables can be up to 20 meters. Relative humidity measurement in the range of 0-99.9% is performed with a resolution of 0.1% and an accuracy of + -2% at a temperature of 25 degrees C (the error increases at low and high humidity). Temperature measurement in the range of -40 to 80 degrees with a resolution of 0.1 degrees C and an accuracy of + -0.5 degrees.

    In the example we will use the Arduino digital output "2" to connect the DHT22 data line.

    To make our work easier, we will use the library to handle the sensor:
    Sketch-> Manage Libraries-> Library Manager
    We search for the phrase "dht" and select "SimpleDHT by Winlin"
    More information about the library here: https://github.com/winlinvip/SimpleDHT

    Below is an example of a code that downloads data from a sensor, after its launch in the monitor of the serial port, we will see information about temperature and humidity:
    Code: c
    Log in, to see the code


    Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB. Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB.

    A humidity sensor during the heating season can help you decide to start the air humidifier. A sensor outside your home can help you forecast the weather, a large increase in humidity with a drop in pressure can indicate a stressful storm.

    Temperature and pressure sensor BMP180
    The sensor allows temperature and pressure measurement, I2C interface used, 1.8-3.6V supply voltage, more in the application note: BMP180 . The sensor mounted on the GY-68 board has additional electronic components to facilitate the connection of the sensor with Arduino Uno. We connect the GND lead to the ground, VIN to the 3.3V output of the Arduino board, the I2C bus lines to SDA and SCL, respectively.

    Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB.

    We include a library to support the BMP180 sensor:
    Sketch-> Manage Libraries-> Library Manager
    Search for the phrase "BMP085" and select "Adafruit BMP085 Unified by Adafruit"
    More information about the library here: https://github.com/adafruit/Adafruit_BMP085_Unified

    Sample code to display sensor data in the serial port monitor:
    Code: c
    Log in, to see the code


    Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB.

    Observation of pressure changes can help in forecasting the weather, a systematic drop in pressure can be a sign of impending deteriorationweather and precipitation, systematic pressure increase can predict sunny weather and no precipitation. Rapid changes in pressure (from 4hPa within 3 hours) may indicate incoming winds with the force depending on the suddenness of pressure changes. There is also something like "normal" pressure for a given location (depends on altitude above sea level), based on this value, you can make a simple forecasting method, if the pressure read from the sensor oscillates + -10hPa around the "normal" pressure, you can expect cloudiness / moderate pressure weather, if the read pressure is higher by more than 10hPa than "normal" then we forecast sunny weather, while lower by 10hPa than "normal" forecasts rain / snow. Normal pressure is 1013.25hPa at 0n.pm.For your city, you can calculate the "normal" pressure using barometric formula here online: http://www.altitude.org/air_pressure.php you can calculate "normal" pressure at a certain altitude under normal conditions.

    RGB LED color phone use FFT
    Let's perform FFT analysis of the signal from the microphone supplied to the ADC A0 input of Arduino. The results of the FFT transformation will allow you to drive the RGB LED to the rhythm of the music using PWM (R-pin5, G-pin9, B-pin6). A detailed description of the FFT can be found here: FFT on ESP32 and Arduino .
    On the Arduino uno we will sample the output signal with a frequency of 8kHz which will allow the analysis of frequencies up to 4kHz, the length of the sample buffer for FFT will be 32 which will result in 16 points of the FFT result. The "arduinoFFT" library should be added to the Arduino environment. In the video below you can see the reaction to example music: Link
    [movie: c1dfeb3d29] https://filmy.elektroda.pl/52_1508085054.mp4 [/ movie: c1dfeb3d29]

    Below is a test code with which you can experiment, for example, making the degree of PWM filling dependent on selected different frequencies:
    Code: c
    Log in, to see the code


    R4-C2 form a low pass filter to adapt the input signal bandwidth to the 8kHz sampling frequency.
    Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB.

    What ideas do you have for using the Arduino Uno?

    Cool! Ranking DIY
    Can you write similar article? Send message to me and you will get SD card 64GB.
    About Author
    TechEkspert
    Editor
    Offline 
    TechEkspert wrote 3266 posts with rating 2550, helped 11 times. Been with us since 2014 year.
  • #2
    piotr_go
    DIY electronics designer
    It would be appropriate to include a diagram of the arduino itself.
  • #3
    siewcu
    Level 34  
    Ideas like everything else, America will not be discovered here ;) Depending on the needs, but still rather for hobby games or some prototype devices. I would like to make a controller for a pressure coffee machine on this, with a bit of luck it could be made quite regulated - although not all topics can be skipped.
  • #4
    TechEkspert
    Editor
    @piotr_go typical diagram for Arduino UNO, only CH340 was used as a USB UART converter,
    I am not a fan of this converter, but its use has a positive effect on the price, I prefer, for example, CP2102 which can be found e.g. in NodeMCU Amica with ESP8266 .

    @siewcu for prototyping, quick tests and experiments, these modules are very suitable, some different modules from gadgets and various contests, you can expect various interesting materials in DIY and articles later.
  • #5
    Mikroprocesorowiec
    Level 12  
    TechEkspert wrote:
    @piotr_go typical diagram for Arduino UNO, only CH340 was used as a USB UART converter,
    I am not a fan of this converter but its use has a positive effect on the price, I prefer the CP2102

    I prefer FTDI. I have never had a problem with them (from the system side), which is not so obvious in the case of other converters (especially the popular PLxxxx). And I can get to FTDI through D2XX libraries. I don't need to know the number of the virtual COM, moreover, such a COM may not appear at all. On and I have access (not in all FTDI) to the EEPROM of this chip. There are versions of FTDI with IIC / SPI. And VNC2. 2xUSB (also 2xHOST). You can write your own programs on VNC like on ESP, so in many cases you don't need a microcontroller.
  • #6
    Tomq
    Level 38  
    CH340G is very cheap and, interestingly, it works "kick". I used to be afraid of such cheap modules, but if they are popular, it means that they work :) FTDI-based converters have many unused functions
  • #7
    piotr_go
    DIY electronics designer
    TechEkspert wrote:
    @piotr_go a typical diagram for Arduino UNO, only CH340 was used as a USB UART converter,

    Diagram for people not using the arduino environment, so that the pinout is at hand.
    Besides, I was wondering why the LM358? (I already found it)
  • #8
    Mikroprocesorowiec
    Level 12  
    Tomq wrote:
    CH340G is very cheap and, interestingly, it works "kick". I used to be afraid of such cheap modules, but if they are popular, it means that they work :) FTDI-based converters have many unused functions

    In the family of converters belonging to the CH340, there are circuits with SPI, IIC. It is true that you cannot choose the configuration of the system from the microcontroller side as in FTDI, but it is a pity that the SPI converter was not used. Thus, the valuable USART would be free to use in any way.
  • #10
    Mikroprocesorowiec
    Level 12  
    TechEkspert wrote:
    @Mikroprocesorowiec I got discouraged by FTDI when they launched the action of breaking devices based on FTDI counterfeit products,
    https://www.theregister.co.uk/2016/01/31/ftdi_accused_of_bricking_counterfeits_again/

    I have not heard about it and this is interesting information. SaleAE software does the same, but there is a way. As for FTDI, fortunately USB-USART is counterfeit, and I use USB-IIC / SPI and VNC2.
  • #11
    piotr_go
    DIY electronics designer
    TechEkspert wrote:
    @piotr_go Could you link some clear and open arduino uno diagram?


    Arduino Uno test, opinion, first launch. DHT22, BMP180, FFT LED RGB.
    Source
  • #12
    TechEkspert
    Editor
    Thank you, I added a link to the schematic in the first post.
  • #13
    siewcu
    Level 34  
    I had several FT232 devices, all of them from the PRC - and there are allegedly only fakes. Drivers only from FTDI, I never had any problems, no device failed.
  • #14
    Mikroprocesorowiec
    Level 12  
    siewcu wrote:
    I had several FT232 devices, all of them from the PRC - and there are allegedly only fakes. Drivers only from FTDI, I never had any problems, no device failed.

    But what FT232? It can be BL (if you don't connect external eeprom, it can't be "broken"), FT232RL has eeprom inside, so that's another story. I do not think that the program itself in FTDI was modified (did the manufacturer provide such an option, if so, it will not necessarily work on a fake), rather, the modified eeprom content (MTP area).
    The question is what exactly are the counterfeit chips? Are you the latest too? If I already use USB-UART it is usually FT230.
  • #15
    siewcu
    Level 34  
    RL. For the most part, it was in EEPROM that I was looking for, out of curiosity ;)
  • #16
    Mikroprocesorowiec
    Level 12  
    siewcu wrote:
    RL. For the most part, it was in EEPROM that I was looking for, out of curiosity ;)

    Do you know the memory map?
    There you can change VID, PID, CBUS functions, etc. The configuration area protects the CRC and in case of bad it restores the standard, but it is close to 1kB for any use. There you can store information like license code, working time etc. Part of this area can be seen in FT_PROG.
  • #17
    siewcu
    Level 34  
    I only used mprog, nothing else interested me. Some crap out of curiosity about what I needed, just that.
  • #18
    mariusz004
    Level 8  
    Can this sensor, the AM2302 sensor - be put out of the window. The circuit board will deteriorate quickly. What's the way?
  • #19
    TechEkspert
    Editor
    It is more of an internal sensor, but if it were in the right cage / housing it would have a chance to work.