Skip to content

Commit 9ae3a3f

Browse files
Add files via upload
0 parents  commit 9ae3a3f

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
3+
# Arduino Sensor Serial Reader
4+
5+
A fun and simple project that allows you to use an Arduino to read sensor data from selected pins and send the results over the serial connection.
6+
7+
## Requirements
8+
9+
To get started, you’ll need the following hardware:
10+
11+
- **Arduino Nano**
12+
- **LDR** (Light Dependent Resistor, 2-pin model)
13+
- **Resistor** (10kΩ, preferred)
14+
- **Thermistor** (LM35 model for temperature)
15+
16+
## Setup
17+
18+
### Circuit Assembly
19+
20+
Here’s how to set up the circuitry:
21+
22+
- LM35 (Temperature Sensor)
23+
- **VCC**: Connect to **5V** on the Arduino Nano.
24+
- **GND**: Connect to **GND** on the Arduino Nano.
25+
- **Output (Analog Signal)**: Connect to **A0** on the Arduino Nano.
26+
- LDR (Light Dependent Resistor)
27+
- One leg of the LDR: Connect to **A1** on the Arduino Nano.
28+
- The other leg of the LDR: Connect to **5V** on the Arduino Nano through a **10kΩ pull-down resistor** to **GND**. This configuration ensures the LDR provides a readable voltage level at **A1**.
29+
30+
![Circuit Diagram](https://cdn.hack.pet/slackcdn/66a98bc1bb42abdd407a4204a5e91a3e.png)
31+
32+
### Receiver Side
33+
34+
The Arduino code sends data over the serial connection every second (note: not the most precise, but functional). The communication uses a **BAUD RATE** of **115200**.
35+
36+
> [!Important]
37+
> Ensure you're familiar with uploading code to the Arduino Nano using the Arduino IDE. If you face issues during upload, please note:
38+
>
39+
> - When using a **CH341** chip for serial communication, you must upload the code with the **Old Bootloader**.
40+
> - The driver version must be **3.7.2022.1**. You can download the correct version from [this link](https://cdn.sparkfun.com/assets/learn_tutorials/8/4/4/CH341SER.EXE).
41+
42+
## Usage
43+
44+
Once uploaded, the Arduino Nano will send a string containing two float values over the serial connection. The first value represents the temperature from the LM35, and the second is the reading from the LDR. The data is in a **JSON-like** format, structured as follows:
45+
`[int, float]` where the `int` is temperature (In Celsius) and `float` is LDR
46+
47+
You can easily parse this string into an array for further use in your application.
48+
49+
------
50+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const int lm35Pin = A0; // LM35 temperature sensor on A0
2+
const int ldrPin = A1; // LDR sensor on A1
3+
4+
void setup() {
5+
Serial.begin(115200); // Start serial communication
6+
}
7+
8+
void loop() {
9+
// Read temperature from LM35 (in Celsius)
10+
int tempRaw = analogRead(lm35Pin);
11+
float temperature = (tempRaw * 5.0 / 1024.0) * 100.0;
12+
13+
// Read light intensity from LDR
14+
int ldrValue = analogRead(ldrPin);
15+
16+
// Send data as a JSON-like string
17+
Serial.print("[");
18+
Serial.print(temperature, 2);
19+
Serial.print(", ");
20+
Serial.print(ldrValue);
21+
Serial.println("]");
22+
23+
delay(1000); // Send data every second
24+
}

0 commit comments

Comments
 (0)