ds1820 interfacing with avr primer

11,807

Circuit Image

The circuit demonstrates the interfacing of the DS1820 temperature sensor with a microcontroller. The first pin of the sensor is connected to ground (GND), the third pin is connected to the power supply (VCC), and the second pin is connected to the microcontroller. As the temperature is sensed, the sensor provides readings to the controller. The objective is to read the temperature from the DS1820 sensor using an AVR Primer Board. The AVR Primer Board utilizes the PORTA pin to receive temperature data from the DS1820 sensor. The output readings are displayed on a PC via UART communication. To compile the associated C code, the CodeVision AVR software is required. This software includes its own Integrated Development Environment (IDE) and a built-in AVR GCC compiler. Proper installation of the software and the creation of a project with the correct settings are necessary for successful code compilation. The C file must be included in the project for compilation. CodeVision AVR allows for the development and debugging of the project without needing hardware setup. The code must be compiled to generate a HEX file. In debugging mode, it is possible to check the port output without the microcontroller board. The AVR Primer Board requires a +12V power supply, with a serial cable connecting the controller to the PC. The HyperTerminal application should be opened, the appropriate port selected, and default settings configured. The screen will display the current temperature readings. To test the sensor, a hot soldering iron tip can be brought near the DS1820 pins without direct contact, maintaining a distance of 1 to 2 mm. The screen should reflect the increasing temperature. Direct contact with the DS1820 pins using the soldering iron tip will result in a rapid increase in temperature readings. It is advised to maintain this contact until the temperature reaches 80 degrees Celsius, after which the iron should be removed. If data does not appear in HyperTerminal, the functionality of the serial cable should be verified. Additionally, the code can be reviewed in debugging mode within CodeVision AVR.

The DS1820 temperature sensor is a digital sensor that communicates with microcontrollers using a one-wire interface, allowing for simple connections and reduced wiring complexity. The first pin serves as the ground connection, ensuring a common reference point for the circuit. The second pin is the data line, which transmits temperature readings to the microcontroller, while the third pin connects to the power supply, typically operating at 3.0 to 5.5V.

In the AVR Primer Board setup, the PORTA pin is configured as an input to read the digital signal from the DS1820 sensor. The UART communication protocol is utilized to send the temperature data from the microcontroller to the PC. This setup allows for real-time monitoring of temperature changes, making it suitable for various applications, including environmental monitoring and temperature logging.

The CodeVision AVR software is essential for programming the microcontroller and includes features for compiling, debugging, and simulating the application. The IDE simplifies the development process, enabling the programmer to focus on writing code rather than managing hardware configurations. The HEX file generated during compilation is uploaded to the microcontroller, facilitating the execution of the temperature reading program.

When testing the sensor, the response to external heat sources, such as a soldering iron, verifies the sensor's functionality. The ability to see real-time updates in HyperTerminal confirms that the data communication between the microcontroller and the PC is functioning correctly. If issues arise, troubleshooting steps include checking the serial connection and reviewing the code for any errors. This comprehensive approach ensures that the temperature sensing application operates effectively and reliably.The circuit shows how to interface the ds1820 to microcontroller. As you can see the first pin is connected to GND, the third pin is connected to VCC & the second pin is connected to the Microcontroller. So when the temperature is sensing, it give the sensor reading to controller. We now want to read the temperature in AVR Primer Board from temperature sensor ds1820. AVR Primer board uses the PORTA pin for reading temperature from temperature sensor ds1820. The reading output is displayed into PC through UART. To compile the above C code you need the CodeVision AVR software. The software has it`s own IDE and built-in AVR gcc- Compiler. They must be properly installed and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project. In CodeVision AVR software, you can develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without microcontroller Board. Give +12V power supply to AVR Primer Board; the serial cable is connected between the controller and PC.

Open the Hyper Terminal screen, select which port you are using and set the default settings. Now the screen should show the current temperature readings. Bring a Hot soldering iron tip near the ds1820`s pins, don`t touch it keep it 1 or 2mm away. The screen should update with the rising temperature. Now finally touch the pins of ds1820 with the tip of iron, the temperature should rise quickly. Keep it there until temperature rise to 80 degrees, and then remove the iron. If any data is not coming in Hyper Terminal, then you just check the serial cable is working or not. Otherwise you just check the code with debugging mode in CodeVisionAVR. 🔗 External reference