200 views|0 replies

46

Posts

0

Resources
The OP
 

Follow me Season 2, Issue 2, Summary Post [Copy link]

 This post was last edited by dvacos on 2024-10-16 18:00
I would like to thank DigiKey and EEWorld for co-organizing the second issue of the second season of the Follow me event, which allowed me to experience the development process of using Arduino UNO R4 WiFi to drive the temperature sensor, upload the temperature to HA, and display the data through the HA panel.

The video is as follows:

1. Overview
Mission brief:
The ultimate goal of this task is to control the Arduino UNO R4 WiFi to drive the temperature sensor, upload the temperature to HA, and display the data through the HA panel. Tasks 1-3 are to gradually become familiar with the learning process of the Arduino development platform and experience some Arduino peripherals in the process.
hardware:
1. Arduino UNO R4 WiFi
2. AHT30 sensor (it has flying wires, and it doesn’t look good if I remove it, so I just keep it)
3. Resistors used in DAC experiments
Hardware Introduction:
Arduino UNO R4 WiFi is an Arduino development board with integrated Wi-Fi and Bluetooth functions. Based on the R7FA4M1 chip and ESP32-S3 chip, it not only inherits the features of Arduino UNO R3, but also adds networking functions. It has a 12x8 LED dot matrix screen, Qwiic connector, etc. The full chip model of Arduino UNO R4 WiFi is R7FA4M1AB3CFM, and the full number of the ESP32 module is ESP32-S3-MINI-1.
AHT30 is a high-precision temperature and humidity sensor with low power consumption, excellent long-term stability and fast response capability. It supports IC interface and has wide voltage support ranging from 2.2 to 5.5 VDC. It is equipped with a new optimized ASIC dedicated chip, an improved MEMS semiconductor capacitive humidity sensor element and a standard on-chip temperature sensor element, which can maintain stable performance even in harsh environments.
2. Mission Details
Task 1
Goal: "Build the environment and start the first step Blink / Serial port print Hello EEWorld!"
Task 1 is mainly to verify that the development environment has been installed. The code is relatively simple. The hardware is a Type-C cable connected to the Arduino to complete code downloading and serial port data reception.
hardware:
Code:
Task 2
Goal: "Drive 12x8 dot matrix LED; use DAC to generate sine wave; use OPAMP to amplify DAC signal; use ADC to collect and print data to serial port and other interfaces to upload to host computer to display curve"
Task 2 is to be familiar with the Arduino LED matrix and analog peripherals, namely ADC, DAC, and operational amplifier. The operational amplifier needs to calculate the amplifier power by itself, and it cannot exceed 4.7V, otherwise it will damage the device, and the DAC output voltage must be set to half of the input voltage (USB input 5v/2=2.5v).
Hardware operation effect:
Code:
Arduino official explanation of op amps
hardware:
Code flow:
Operation results:
Comparison of DAC output voltage before and after reduction
Since the host computer cannot scale the Y axis (or I don't know how to do it), I can only barely see it.
Task 3
Goal: "Connect to the open source smart home platform HA (HomeAssistant) via Wi-Fi using the MQTT protocol"
The main purpose of Task 3 is to control the WiFi module on Arduino to send MQTT data. The HA platform runs on the PC and its function is to receive, parse and display MQTT data.
Key points:
1. Install PubSubClient library
2. Refer to the 8266 routine to write the code, because only this routine has an example of connecting to WIFI
3. Add your own WIFI name and password. Please note that it must be the 2.4G frequency band. The connection will fail if it is 5G.
4. Add the IP, port number, username, password, and published topic of mqtt_server
Operation effect:
Task 4
Goal: "Drive the SHT40 temperature and humidity sensor, upload the temperature and humidity to HA, and display the data through the HA panel"
Task 4 is to add the temperature value measured by the temperature sensor to Task 3, report it to the HA platform through MATT, and replace the previous simulation data.
Since I bought an AHT40 sensor and didn't have Qwiic, I had the following troubles.
Qwiic IIC Pinout
in conclusion:
Arduino UNO R4 WiFi has multiple IIC interfaces, and the Qwiic code cannot configure the non-Qwiic IIC interface, as shown in the upper right red box.
So I flew two wires from the black frame in the picture below.
The above solves the hardware problem.
software:
1. After testing, we know that AHT30 is compatible with AHT20 code, so install this library
2. After the wiring is correct, the temperature can be obtained normally
3. Combine the temperature measurement code with Task 3 and report the temperature normally.
Temperature Measurement GIF
Code diagram:
Conclusion
Thanks again to DigiKey and EEWorld. I learned about MQTT and HA, which I had never touched before. After going through the whole process, I found that there are too many different libraries for the same function or sensor in Arduino. The code and logic of each library are different, which makes various codes inapplicable and the information found in various libraries do not match. It wastes a lot of time and is more tiring than writing drivers manually (different kinds of tiring, it is very annoying for Arduino to filter information because it depends on the library, so the code often cannot be used for no reason, and the only error reported is the syntax error).
But the overall experience is still faster than chip SDK-level C language development, so there are gains and losses. For Arduino enthusiasts, it is still very easy to use and can quickly implement creative ideas.

Code:


code_1016.zip

6.03 KB, downloads: 2

This post is from DigiKey Technology Zone
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list