├── telegram2 (1).py ├── DHT11.py ├── LICENSE └── README.md /telegram2 (1).py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | from machine import Pin 3 | import onewire, ds18x20 4 | 5 | import network 6 | 7 | ssid = 'POCO F5' 8 | password = '62741290' 9 | 10 | 11 | 12 | 13 | station = network.WLAN(network.STA_IF) 14 | 15 | station.active(True) 16 | station.connect(ssid, password) 17 | 18 | while station.isconnected() == False: 19 | pass 20 | 21 | print('Connection successful') 22 | print(station.ifconfig()) 23 | 24 | -------------------------------------------------------------------------------- /DHT11.py: -------------------------------------------------------------------------------- 1 | import urequests as requests 2 | from machine import Pin 3 | from time import sleep 4 | import dht 5 | 6 | sensor = dht.DHT11(Pin(13)) 7 | 8 | while True: 9 | try: 10 | sleep(5) 11 | sensor.measure() 12 | temp= sensor.temperature() 13 | hum = sensor.humidity() 14 | 15 | print('Temperature: %3.1f C' %temp) 16 | print('Humidity: %3.1f %%' %hum) 17 | requests.get(url=f'https://hellvin.com.tr/eslamibots/nsm.php?temp={temp}') 18 | requests.get(url=f'https://hellvin.com.tr/eslamibots/nsm.php?temp={hum}') 19 | 20 | 21 | except OSError as e: 22 | print('Failed to read sensor.') -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 mahdieslaminet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # ESP Temperature Sensor with Telegram Integration 3 | This project utilizes an ESP microcontroller to read temperature data from a sensor and sends the data to a specified Telegram chat using the Telegram API. 4 | ## Features 5 | • Reads temperature data using a temperature sensor connected to the ESP device. 6 | • Utilizes ESP's Wi-Fi capabilities to connect to the internet and send data. 7 | • Integrates with the Telegram API to send temperature updates to a designated chat or user. 8 | ## Requirements 9 | • ESP microcontroller (e.g., ESP32, ESP8266) 10 | • Temperature sensor (e.g., DS18B20, DHT11, DHT22) 11 | • Arduino IDE or PlatformIO 12 | • Telegram Bot Token (for accessing Telegram API) 13 | • Wi-Fi access 14 | ## Setup 15 | ### Hardware Setup: 16 | • Connect the temperature sensor to the ESP microcontroller following the appropriate pin connections. 17 | ## Telegram Bot Setup: 18 | • Create a Telegram bot using BotFather on Telegram. 19 | • Obtain the bot token generated by BotFather. 20 | Software Configuration: 21 | • Clone or download this repository. 22 | • Open the project in Arduino IDE or PlatformIO. 23 | • Update the config.h file with your Wi-Fi credentials and Telegram bot token. 24 | Upload Code: 25 | • Compile and upload the code to your ESP device. 26 | ### Usage 27 | • Power up the ESP device. 28 | • Once connected to Wi-Fi, the ESP device will start reading temperature data from the sensor. 29 | • The temperature data will be sent to the configured Telegram chat at regular intervals. 30 | Contribution 31 | Contributions are welcome! If you find any issues or want to add improvements, feel free to create a pull request. 32 | License 33 | This project is licensed under the MIT License. 34 | Acknowledgments 35 | • Arduino - Platform for programming ESP devices. 36 | • Telegram API - API used for sending messages to Telegram. 37 | • YourTemperatureLibrary - (if you use any external libraries, mention them here with links) 38 | 39 | # Future To-Do List 40 | 1. [ ] Implement Error Handling 41 | • Enhance error handling mechanisms to handle scenarios like network disconnection, sensor malfunction, or Telegram API errors gracefully. 42 | 2. [ ] Add Sensor Calibration 43 | • Implement a calibration feature to adjust temperature readings for accuracy, if necessary. 44 | 3. [ ] Enhance Data Formatting 45 | • Improve the format of the temperature data sent to Telegram for better readability. 46 | 4. [ ] Implement Sensor Redundancy 47 | • Consider incorporating redundancy by connecting multiple sensors to ensure reliability. 48 | 5. [ ] Enable Multiple Sensor Support 49 | • Add support for different types of temperature sensors to provide flexibility for users. 50 | 6. [ ] Implement Sensor Threshold Alerts 51 | • Set up alerts or notifications to be sent if the temperature surpasses predefined thresholds. 52 | 7. [ ] Develop a Web Interface 53 | • Create a simple web interface to monitor temperature readings and configure settings remotely. 54 | 8. [ ] Enhance Power Efficiency 55 | • Optimize power consumption to extend the device's battery life or overall efficiency. 56 | 9. [ ] Implement OTA Updates 57 | • Enable Over-The-Air (OTA) updates to remotely update the firmware without physical access to the device. 58 | 10. [ ] Create Detailed Documentation 59 | • Write comprehensive documentation covering setup instructions, troubleshooting, and project architecture for users and contributors. 60 | 11. [ ] Explore Cloud Integration 61 | • Investigate integrating the project with cloud services for data logging, analysis, or long-term storage. 62 | 12. [ ] Enhance Security Measures 63 | • Implement encryption or additional security measures to protect sensitive data transmission. 64 | 13. [ ] Develop Mobile App Integration 65 | • Create a mobile application for monitoring temperature and receiving alerts. 66 | 14. [ ] Expand Telegram Bot Features 67 | • Add interactive features to the Telegram bot, such as user commands for querying historical data or configuring settings. 68 | 15. [ ] Conduct Stress Testing 69 | • Perform stress testing under various conditions to ensure the system's robustness and reliability. 70 | # video 71 | https://drive.google.com/file/d/1uQ8g8YVC8Xc1anKWar6EXHM-hSVuno0R/view?usp=sharing --------------------------------------------------------------------------------