tag:blogger.com,1999:blog-44176934498128709692024-03-14T20:08:11.409+06:00Mechatronics LAB- Internet Of ThingsHere is the blog that provide you all information about IoT In this blog you find about NodeMcu, ESP8266, arduino, PLC,Raspberry pi, Automation Component, AVR Microcontroller. Everything about automation and Technology . Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.comBlogger189125tag:blogger.com,1999:blog-4417693449812870969.post-86975474085943932782023-08-31T08:06:00.006+06:002023-08-31T08:25:15.567+06:00Understanding Motor Controls: THIRD EDITION" by Stephen L. Herma:<h1 style="text-align: left;">Understanding Motor Controls: THIRD EDITION" by Stephen L. Herma:</h1><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHL3s7z3LbRENcxTEyU12iKd8LvzQ5kFbPsrcNEeqRd_yUj8Jd6kQX3qkJCGEw7W0mw1I6K1fN6s6kU0zZ2FOwwMcxR_bpQNGJHvA8_0quNtnNJSrE0iMN20TyUNGM3b36b8I8OpXco1FLepdAfoDTHL0LJ3iga10pV1ArHF4XGr2fHgBqRANc1U1C-Z90/s2250/1.jpg" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="2250" data-original-width="1410" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHL3s7z3LbRENcxTEyU12iKd8LvzQ5kFbPsrcNEeqRd_yUj8Jd6kQX3qkJCGEw7W0mw1I6K1fN6s6kU0zZ2FOwwMcxR_bpQNGJHvA8_0quNtnNJSrE0iMN20TyUNGM3b36b8I8OpXco1FLepdAfoDTHL0LJ3iga10pV1ArHF4XGr2fHgBqRANc1U1C-Z90/s320/1.jpg" width="201" /></a></div>Understanding Motor Controls provides a comprehensive guide to the fundamentals of motor control systems. Author Stephen L. Herma effectively breaks down complex topics, making the concepts accessible to any reader. <p></p><p>The book covers all aspects of motor control from basic principles to more advanced applications. It begins with an overview of control techniques and the components that make up motor control systems. Fundamental control types like on/off, PID, and servo are clearly explained. Electrical concepts such as voltage, current, and power are also reviewed to build a strong foundation. </p><p>The middle chapters dive deeper into specific control components like sensors, actuators, and drive techniques. Numerous circuit diagrams and examples illustrate how components work together in a system. Programming concepts for PLCs and drives are also presented. This provides practical knowledge useful for many industrial applications</p><p><br /></p><h3 style="text-align: left;">Download <a href="https://cutt.ly/swkQ4ZNh" rel="nofollow" target="_blank">understanding motor controls 3th edition pdf free</a></h3><p>The final chapters explore more specialized motor control topics. Vector control, synchronous motor control, and servo motor control are three areas covered in technical detail. Programming examples show how to implement different control algorithms. A chapter on motor maintenance and troubleshooting is also very useful.</p><p>Overall, Understanding Motor Controls is an excellent textbook for anyone looking to learn motor control system design. Herbert's clear writing style makes even complex topics easy to understand. Numerous examples and illustrations reinforce key concepts. The book covers all aspects of motor controls from introductory to advanced in a comprehensive yet accessible manner. It would be a valuable reference for industrial technicians, engineers, and students.</p><p><br /></p><h3 style="text-align: left;">Download <a href="https://cutt.ly/swkQ4ZNh" rel="nofollow" target="_blank">understanding motor controls pdf</a></h3>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-13782403077274422032023-05-20T11:13:00.000+06:002023-05-20T11:13:28.059+06:00সেন্সর<p> 1. সেন্সর বলতে কী বুঝা</p><p>যা পরিমাপিত কোয়ান্টিটির উপস্থিতি অনুভব সিগন্যাল প্রদান করে, তাকে Sensor (সেশর) বলে।</p><span id="docs-internal-guid-adc54c22-7fff-7d51-ffa9-b8b9d29516aa"><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;">2. সিগন্যাল কন্ডিশনারের কাজ কী? </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"> এটি সেন্সর হতে গৃহীত সিগন্যালকে ডিসপ্লে কিংবা নিয়ন্ত্রণের উপযোগী করে।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">3. কন্ট্রোল সিস্টেম বলতে কী বুঝায়?</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">যে পদ্ধতিতে কোনো ভৌত বা প্রসেস ভ্যারিয়েবলকে স্বয়ংক্রিয়ভাবে অথবা অন্য কোনো সিস্টেমের দ্বারা নিয়ন্ত্রণ</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-ba6f86c1-7fff-8ea0-157c-388e97f5e544"></span></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">করা হয়, তাকে কন্ট্রোল সিস্টেম বলে । </span></p><div><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div><div><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;">4। ওপেন লুপ কন্ট্রোল সিস্টেম বলতে কী বুঝা? </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"> যে কন্ট্রোল সিস্টেমে ইনপুট কোয়ান্টিটির উপর আউটপুটের কোনো প্রভাব থাকে না, তাকে ওপেন সুপ কট্রেস সিস্টেম বলে। </span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;">5। ক্লোজড সুপ কন্ট্রোল সিস্টেম বলতে কী বুঝায়?</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"> যে কন্ট্রোল সিস্টেমে ইনপুট কোয়ান্টিটির উপর আউটপুটের কোনো প্রভাব থাকে না যেমন- ইলেকট্রনিক টোস্টার, ET) যে কন্ট্রোল সিস্টেমে আউটপুট কোয়ান্টিটি ইনপুট কোয়ান্টিটির উপর প্রভাব বিস্তার করে, কন্ট্রোল সিস্টেম বলে। যেমন- লিকুইড লেভেল কন্ট্রোল, অটোমেটিক টেম্পারেচার কন্ট্রোল।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;"> 6. সিকুয়েন্সিয়াল কন্ট্রোল বলতে কী বুঝায়? </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;"> পর্যায়ক্রমিক ধাপে ও সময়ে কোনো ঘটনাকে নিয়ন্ত্রণ করার পদ্ধতিকে সিকুয়েন্সিয়াল কন্ট্রোল বলে।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b id="docs-internal-guid-6fa53e52-7fff-c3f1-a9f8-ca45a691e77c" style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">7. সেন্সর ও ট্রান্সডিউসারের মাঝে মূল পার্থক্য লেখ।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;"> সেন্সর আউটপুটে পরিমাপিত কোয়ান্টিটির সাথে সম্পর্কযুক্ত সিগন্যাল প্রদান করে আর ট্রান্সডিউসার আকৃতিকে অন্য আকৃতিতে পরিবর্তনের মাধ্যমে সিস্টেমের এক স্টো থেকে অন্য স্টেজে স্থানান্তরিত করে।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;"> 8. এর সিগন্যাল কীভাবে পাওয়া যায়?</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Error এর সিগন্যাল = রেফারেন্স ভ্যালু সিগন্যাল - মেজারড ভ্যালু সিগন্যাল।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">9.পরিমাপ পদ্ধতিকে (Measurement system) </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">পরিমাপ পদ্ধতিকে (Measurement system) একটি কালো বক্স হিসেবে চিন্তা করা যায়, যা পরিমাপ কাজে ব্যবহৃত হয়। এর একটি ইনপুট (পরিমাপিত কোয়ান্টিটি) এবং একটি আউটপুট (পরিমাপিত কোয়ান্টিটি) মান থাকে। উদাহরণস্বরূপ উচ্চতা পরিমাপ পদ্ধতি (Temperature measurement system) অর্থাৎ একটি থার্মোমিটারের ইনপুট (Temperature) এবং আউটপুট (ছেলে সাগঙ্কিত মান) থাকে।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;"> 10. সিস্টেম বলতে কী বুঝায়?</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">যে ব্যবস্থার মাধ্যমে ইনপুট প্রদান করে আকাঙ্ক্ষিত আউটপুট পাওয়া যায় এবং উক্ত আউটপুট পেতে যে প্রক্রিয়া (Process) অবলম্বন করতে হয়, তাকেই সিস্টেম বলে।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">Input —-----Process —------Output</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;"> 11. ওপেন গ্রুপ পদ্ধতির মৌলিক উপাদানগুলো কী কী? ওপেন গ্রুপ পদ্ধতির মৌলিক উপাদানগুলো হলো</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">(i) Command Input (iii) Reference input</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">(ii) Reference selector (iv) Dynamic unit</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">12. (Closed) লুপ কন্ট্রোল সিস্টেমের মৌলিক উপাদানগুলো কী কী?</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">(1) কম্পানি মিন্ট (Comparision element) (ii) কন্ট্রোল ইলিমেন্ট (Control element) (iii) কারেকশন ইলিমেন্ট (Correction element) (iv) (Process element) (v) Desired output..</span></p></span></div></span>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-16599991865560512962023-05-19T16:33:00.000+06:002023-05-19T16:33:14.877+06:00Mechatronics system<p>1.<span style="font-family: Arial; font-size: 11pt; white-space: pre-wrap;"> সিস্টেম বলতে কী বুঝায়? </span></p><span id="docs-internal-guid-b20f63d9-7fff-cd02-7715-adc819a845c3"><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;">যে ব্যবস্থার মাধ্যমে ইনপুট প্রয়োগ করে আকাঙ্ক্ষিত আউটপুট পাওয়া যায় এবং উক্ত আউটপুট পেতে প্রসেস</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;">অবলম্বন করতে হয়, তাকেই সিস্টেম (System) বলে। </span></p><div><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div><div><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;">2. সিস্টেমের উপাদান (Element) কয়টি ও কী কী?</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;">সিস্টেমের উপাদান তিনটি যথা</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;">(1) ইনপুট (Input)</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;">(ii) (Process)</span></p><br /><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;">(iii) আউটপুট (Output)</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">3. পরিমাপ পদ্ধতিতে কী কী উপাদান থাকে?</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><b id="docs-internal-guid-8dc166ae-7fff-1e92-67b6-1a381220de05" style="font-weight: normal;"><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">(1) Sensor (ii) Signal conditioner</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">(ii) Display. </span></p></span></div></span>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-79179016210455593642023-05-19T12:04:00.003+06:002023-05-19T12:04:25.157+06:00মেকাট্রনিক্স-এর উপাদান (Mechatronics and It's Elements<p> 1. <span style="font-family: Arial; font-size: 11pt; white-space: pre-wrap;">মেকট্রনিক্স শব্দটি প্রথম কে নামকরণ করেন? </span></p><span id="docs-internal-guid-a961edb3-7fff-197a-5a8b-6d9b9fd6e06e"><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"> মেকট্রনিক্স শব্দটি প্রথম নামকরণ করেন <b>Tetsura Mory ১৯৬৯ সালে।</b> তিনি জাপানি Yasakawa Electric Comporation' নামক একটি কোম্পানিতে <b>সিনিয়র ইঞ্জিনিয়ার ছিলেন।</b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"> 2. Mechatronics টার্মটির উৎপত্তি কোথা থেকে? </p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"> Mechanical এবং Electronics শব্দ দুটি থেকে Mecha এবং Tronics অংশ নিয়ে Mechatronics-এর উৎপত্তি</p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><br /></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">3. W. Bolton-এর মতে মেকাট্রনিক্স-এর সংজ্ঞা দাও।</p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">w. Bolton-এর মতে, "মেকাট্রনিক্স হলো ইলেকট্রনিক্স, কন্ট্রোল ইঞ্জিনিয়ারিং এবং মেকানিক্যাল বিষয়।" (Integration of electronics, control engineering and mechanical engineering)</p><div><br /></div><div><div>4 শেটি ও রিচার্ড এ কঙ্ক-এর মতে মেকাট্রনিক্স কী কী বিষয় নিয়ে গঠিত?</div><div> Shetty এবং A. Kolk-এর মতে, “মেকাট্রনিক্স পদ্ধতি হলো বহু বিষয় সংবলিত (Multi-Desciplinary), যা মৌলিক বিষয় যথা- ইলেকট্রিক্যাল, মেকানিক্যাল, কম্পিউটার সায়েন্স এবং ইনফরমেশন টেকনোলজির সংমিশ্রণে গঠিত।</div></div><div><br /></div><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">5. মেকাট্রনিক্স-এর গাঠনিক উপাদানগুলো কী কী? মেকাট্রনিক্স-এর গাঠনিক উপাদানগুলো হলো</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">(1) ইনফরমেশন সিস্টেম (iii) মেকানিক্যাল সিস্টেম</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">(11) কম্পিউটার সিস্টেম (iv) ইলেকট্রিক্যাল সিস্টেম।</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;"> 6. মেকট্রনিঙ্গে অটোমেটিক কন্ট্রোল বলতে কী বুঝানো হয়েছে? । </span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; white-space: pre;">এখানে অটোমেটিক কন্ট্রোল বলতে কোনো অপারেটর ছাড়া কোনো মেশিনকে অন্য কোনো মেশিন এখানে বুঝানো হয়েছে </span></p><div><span id="docs-internal-guid-8e8d8bef-7fff-08ca-fcc9-b0d6c8304985"><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;">7. মেকাট্রনিক্সের মৌলিক উপাদানগুলো কী কী?</span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;">মেকট্রনিক্স-এর মৌলিক বিষয়গুলো হলো (1) ইলেকট্রিক্যাল (Electrical) </span><span style="font-family: Arial; font-size: 11pt; white-space: pre-wrap;">(ii) মেকানিক্যাল (Mechanical) (iv) ইলেকট্রনিক্স (Electronics)</span></p><div><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-85c5a305-7fff-a968-0f21-2d44e746885b"><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;"><br /></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;">8. </span><span style="font-size: 11pt;">ভায়াগ্রামের মাধ্যমে মেকাট্রনিক্সের Key Element গুলো দেখাও।</span></p></span></span></div></span></div><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b></b></span></p><div class="separator" style="clear: both; text-align: center;"><br /></div></span><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b></b></span></p><div class="separator" style="clear: both; text-align: center;"><b><a href="https://blogger.googleusercontent.com/img/a/AVvXsEi11YRVOb8sW4JV2xxW5WGIyBo4vkYaCV4yqLDk1iJ3KoPx3m-J3GgpV6-AteDCLPnqkDf-CNn-h4u-flyyWZnWg3PMw022sNoGHYUVG4aPvWHI1KVDn-WK7so_TVi3eoYLEfx31kd3XXV3lMwUBZyP1h4B0e7YWSWxwoV8tdomGrgcfB1ABpw8gE5XDA" style="margin-left: 1em; margin-right: 1em;"><img alt="মেকাট্রনিক্সের Key Element" data-original-height="238" data-original-width="381" height="200" src="https://blogger.googleusercontent.com/img/a/AVvXsEi11YRVOb8sW4JV2xxW5WGIyBo4vkYaCV4yqLDk1iJ3KoPx3m-J3GgpV6-AteDCLPnqkDf-CNn-h4u-flyyWZnWg3PMw022sNoGHYUVG4aPvWHI1KVDn-WK7so_TVi3eoYLEfx31kd3XXV3lMwUBZyP1h4B0e7YWSWxwoV8tdomGrgcfB1ABpw8gE5XDA=w320-h200" title="মেকাট্রনিক্সের Key Element" width="320" /></a></b></div><b><br /><br /></b><p></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><p dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;"><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><b><br /></b></span></p><div><span style="font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-60120485887845992382022-12-11T19:04:00.002+06:002022-12-11T19:04:16.844+06:00fuse<p>A fuse protects an electrical circuit or device from excessive current when a metal element inside it melts to create an open circuit. With the exception of resettable fuses (discussed separately in Resettable Fuses), a fuse must be discarded and replaced after it has fulfilled its function.</p><p><br /></p><p>When high current melts a fuse, it is said to blow or trip the fuse. (In the case of a resettable fuse, only the word trip is used.)</p><p><br /></p><p>A fuse can work with either AC or DC voltage, and can be designed for almost any current. In residential and commercial buildings, circuit breakers have become common, but a large cartridge fuse may still be used to protect the whole system from short-circuits or from overcurrent caused by lightning strikes on exposed power lines.</p><p><br /></p><p>In electronic devices, the power supply is almost always fused.</p><p><br /></p><p>Schematic symbols for a fuse are shown in Figure 4-1. Those at the right and second from right are most frequently used. The one in the center is approved by ANSI, IEC, and IEEE but is seldom seen. To the left of that is the fuse symbol understood by electrical contractors in architectural plans. The symbol at far left used to be common but has fallen into disuse.</p><p><br /></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgM4VIt2N-huSLf6JiOTkJ86ZVt21z3iLBnez0VMokNGbSpAqJrWbwP-gRpAzr2aNKiqoZqKA6CrM0ObJ5zKIYbkhNZ5ndrWQ6e21cfOplbMlyJ9WNe2hjFybNStO08X00Irtaqq7s6NCGIBl42uPGKcFvlnK2TSzjX2JxRgjPY9Pe2NFwW5LVtcvKdWw" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-1. Alternate schematic symbols for a fuse. See text for explanation." data-original-height="522" data-original-width="866" height="193" src="https://blogger.googleusercontent.com/img/a/AVvXsEgM4VIt2N-huSLf6JiOTkJ86ZVt21z3iLBnez0VMokNGbSpAqJrWbwP-gRpAzr2aNKiqoZqKA6CrM0ObJ5zKIYbkhNZ5ndrWQ6e21cfOplbMlyJ9WNe2hjFybNStO08X00Irtaqq7s6NCGIBl42uPGKcFvlnK2TSzjX2JxRgjPY9Pe2NFwW5LVtcvKdWw=w320-h193" title="Figure 4-1. Alternate schematic symbols for a fuse. See text for explanation." width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p></p><h3 style="clear: both; text-align: left;">How It Works</h3><div class="separator" style="clear: both;"><div class="separator" style="clear: both;">The element in a fuse is usually a wire or thin metal strip mounted between two terminals. In a cartridge fuse, it is enclosed in a glass or ceramic cylinder with a contact at each end, or in a small metallic can. (Old-style, large, high-amperage fuses may be packaged in a paper or cardboard tube.) The traditional glass cartridge allows visual inspection to confirm that the fuse has blown.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">A fuse responds only to current, not to voltage. When choosing a fuse that will be reliable in conditions of steady current consumption, a safe rule is to figure the maximum amperage when all components are functioning and add 50%. However, if current surges or spikes are likely, their duration will be relevant. If I is the current surge in amps and t is its duration in seconds, the surge sensitivity of a fuse—which is often referred to verbally or in printed format as I2t—is given by the formula:</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">I2t = I2 * t</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Some semiconductors also have an I2t rating, and should be protected with a similarly rated fuse.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Any fuse will present some resistance to the current flowing through it. Otherwise, the current would not generate the heat that blows the fuse. Manufacturer datasheets list the voltage drop that the internal resistance of a fuse is likely to introduce into a circuit.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><h3 style="clear: both; text-align: left;">Values</h3><div class="separator" style="clear: both;">The current rating or rated current of a fuse is usually printed or stamped on its casing, and is the maximum flow that it should withstand on a continuous basis, at the ambient temperature specified by the manufacturer (usually 25 degrees Centigrade). The ambient temperature refers to the immediate environment of the fuse, not the larger area in which it may be located. Note that in an enclosure containing other components, the temperature is usually significantly higher than outside the enclosure.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Ideally a fuse should function reliably and indefinitely at its rated maximum amperage, but should blow just as reliably if the current rises by approximately 20% beyond the maximum. In reality, manufacturers recommend that continuous loading of a fuse should not exceed 75% of its rating at 25 degrees Centigrade.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">The voltage rating or rated voltage of a fuse is the maximum voltage at which its element can be counted on to melt in a safe and predictable manner when it is overloaded by excess current. This is sometimes known as the breaking capacity. Above that rating, the remaining pieces of the fuse element may form an arc that sustains some electrical conduction.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">A fuse can always be used at a lower voltage than its rating. If it has a breaking capacity of 250V, it will still provide the same protection if it is used at 5V.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Four differently rated glass cartridge fuses are shown in Figure 4-2. The one at the top is a slow-blowing type, rated at 15A. Its element is designed to absorb heat before melting. Below it is a 0.5A fuse with a correspondingly thinner element. The two smaller fuses are rated at 5A each. The center two fuses have a maximum voltage rating of 250V, while the one at the top is rated at 32V and the one at the bottom is rated at 350V. Clearly, the size of a fuse should never be used as a guide to its ratings.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhqbbLDlf-9M4pTL3PUOLlh9vGo1Fv7bZFlYdcgm9XFP7A2dIZHQ8A6x1VTzhcJ2YHfZ-2jfpuyPbni4fRXTauaJg0gwM9yYYISHabt0f0Ibu_KGY4JBuiYWcG3Fx5b6BpH12fIUMZlDGPZEVAO9YIwxivqKUE6lFN3KgFUKuMvIEmcH-DhNDPBKviFHg" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-2. Four glass cartridge fuses. See text for details." data-original-height="839" data-original-width="1000" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEhqbbLDlf-9M4pTL3PUOLlh9vGo1Fv7bZFlYdcgm9XFP7A2dIZHQ8A6x1VTzhcJ2YHfZ-2jfpuyPbni4fRXTauaJg0gwM9yYYISHabt0f0Ibu_KGY4JBuiYWcG3Fx5b6BpH12fIUMZlDGPZEVAO9YIwxivqKUE6lFN3KgFUKuMvIEmcH-DhNDPBKviFHg" title="Figure 4-2. Four glass cartridge fuses. See text for details." width="286" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both;">Variants</div><div class="separator" style="clear: both;">Early power fuses in residential buildings consisted of bare nichrome wire wrapped around a porcelain holder. In the 1890s, Edison developed plug fuses in which the fuse was contained in a porcelain module with a screw thread, compatible with the base of an incandescent bulb. This design persisted in some U.S. urban areas for more than 70 years, is still found in old buildings, and is still being manufactured.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Small Cartridge Fuses</div><div class="separator" style="clear: both;">Small cartridge fuses for appliances and electronics equipment—such as those shown in Figure 4-2--are available in sizes tabulated in Figure 4-3. With the exception of the 4.5mm diameter fuse (a European addition), these sizes were originally measured in inches; today, they are often described only with the equivalent metric measurement. Any cartridge fuse is usually available with the option of a lead attached to it at each end, so that it can be used as a through-hole component.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEi-VMUGD9d_4X2xTKqud4z_Dv6T0_AD-pMTukCW-dQdp3s750tzW5vfKQua-zwsR9QNaVbenBBaTwOUI6rUJPipYL1eZfgC0CYE58uEuvaGSZ1t8jI5QrN4mxUDqZwYUV5vyxy7ahsz0ziMkInzLkJjzrPzKTIjD6EEluBLuePgixeCbof8v5npYlHilQ" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-3. The approximate physical sizes of commonly used small glass or ceramic cartridge fuses are shown here with the codes that are often used to identify them." data-original-height="700" data-original-width="867" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEi-VMUGD9d_4X2xTKqud4z_Dv6T0_AD-pMTukCW-dQdp3s750tzW5vfKQua-zwsR9QNaVbenBBaTwOUI6rUJPipYL1eZfgC0CYE58uEuvaGSZ1t8jI5QrN4mxUDqZwYUV5vyxy7ahsz0ziMkInzLkJjzrPzKTIjD6EEluBLuePgixeCbof8v5npYlHilQ" title="Figure 4-3. The approximate physical sizes of commonly used small glass or ceramic cartridge fuses are shown here with the codes that are often used to identify them." width="297" /></a></div><br /><br /></div></div><br /><br /></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both;">Fuses may be fast acting, medium acting, or slow-blowing, the last of which may alternatively be referred to as delay fuses. Extra-fast–acting fuses are available from some manufacturers. The term Slo-Blo is often used but is actually a trademark of Littelfuse. None of the terms describing the speed of action of a fuse has been standardized with a specific time or time range.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Some cartridge fuses are available in a ceramic format as an alternative to the more common glass cylinder. If accidental application of extremely high current is possible (for example, in a multimeter that can be set to measure amps, and may be accidentally connected across a powerful battery), a ceramic cartridge is preferable because it contains a filler that will help to stop an arc from forming. Also, if a fuse is physically destroyed by application of very high current, ceramic fragments may be preferable to glass fragments.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><h3 style="clear: both; text-align: left;">Automotive Fuses</h3><div class="separator" style="clear: both;">Automotive fuses are identifiable by their use of blades designed for insertion in flat sockets where the fuse is unlikely to loosen as a result of vibration or temperature changes. The fuses come in various sizes, and are uniformly color-coded for easy identification.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">A selection of automotive fuses is shown in Figure 4-4. The type at the top is typically described as a "maxi-fuse" while the type at bottom-left is a "mini-fuse." Here again, size is irrelevant to function, as all three of those pictured are rated 30A at 32V.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjIhBTvuvEoZQNrB6xFjyyawvSwV9acjDsxLV6eRymMFqz7KwsuiaPW1-byDYJUNGibkA9H4Zh-FwAyPKIIegkG78Jk7_eA1q3ZzH0r4PQz8U5lBdlF3-_Ayh4hWlv_To9Q4A3mXg72aWJ9LoI6VVRZQFyspviIZkj0-TfziPMZl8pnycOi1s-1_vBiww" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-4. Three automotive fuses. All have the same rating: 30A at 32V." data-original-height="1000" data-original-width="883" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEjIhBTvuvEoZQNrB6xFjyyawvSwV9acjDsxLV6eRymMFqz7KwsuiaPW1-byDYJUNGibkA9H4Zh-FwAyPKIIegkG78Jk7_eA1q3ZzH0r4PQz8U5lBdlF3-_Ayh4hWlv_To9Q4A3mXg72aWJ9LoI6VVRZQFyspviIZkj0-TfziPMZl8pnycOi1s-1_vBiww" title="Figure 4-4. Three automotive fuses. All have the same rating: 30A at 32V." width="212" /></a></div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both;">In Figure 4-5, the largest of the fuses from Figure 4-4 has been cut open to reveal its element.</div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgzXDX3VN2nMrJ3HuN_mzQEiKz-z-5DEeoSPGfZszLedAS3szR9Yz-xSdIgjldeBa_xHrQU1bHwFeTAsPczRkEaD4c1gZancY3Dzv1WneBJSd2n66WLPb9EvGhCkAFkxOcucRF8O6pbd8Niwre0lCZiHE992bEoOABw0tfA-0umAsGuW2E364cGTbv5kw" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-5. The largest fuse from the previous figure, cut open to reveal its element." data-original-height="866" data-original-width="1000" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEgzXDX3VN2nMrJ3HuN_mzQEiKz-z-5DEeoSPGfZszLedAS3szR9Yz-xSdIgjldeBa_xHrQU1bHwFeTAsPczRkEaD4c1gZancY3Dzv1WneBJSd2n66WLPb9EvGhCkAFkxOcucRF8O6pbd8Niwre0lCZiHE992bEoOABw0tfA-0umAsGuW2E364cGTbv5kw" title="Figure 4-5. The largest fuse from the previous figure, cut open to reveal its element." width="277" /></a></div><br /><br /></div></div><br />Usually automotive fuses are mounted together in a block, but if aftermarket accessory equipment is added, it may be protected by an inline fuse in a holder that terminates in two wires. This is shown with two sample fuses in Figure 4-6. Similar inline fuse holders are manufactured for other types of fuses.</div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhGrOJwg7IPBiF26_FAdvVCwbPnzjPMCvVoU8cUJYxyAw76S2zgMhbX1ATB_NUmTYPzcFvF8YA5sf0WR-P-LGaAMBCOxeyDz3bjbwAE1PfOdBTy_hIru_9x_CEk-_tKqKiAb-hz1_XhglOG-VY2Lx6IEMQdnq5QTTzBrS5eXm76Isecqo2L-VfWcFRDDg" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-6. Two blade-type fuses, commonly used for automotive applications, shown with an inline fuse holder. The plastic cap, at right, is closed over the holder when a fuse has been installed." data-original-height="1000" data-original-width="921" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEhGrOJwg7IPBiF26_FAdvVCwbPnzjPMCvVoU8cUJYxyAw76S2zgMhbX1ATB_NUmTYPzcFvF8YA5sf0WR-P-LGaAMBCOxeyDz3bjbwAE1PfOdBTy_hIru_9x_CEk-_tKqKiAb-hz1_XhglOG-VY2Lx6IEMQdnq5QTTzBrS5eXm76Isecqo2L-VfWcFRDDg" title="Figure 4-6. Two blade-type fuses, commonly used for automotive applications, shown with an inline fuse holder. The plastic cap, at right, is closed over the holder when a fuse has been installed." width="221" /></a></div><div class="separator" style="clear: both;">Strip Fuses</div><div class="separator" style="clear: both;">High-amperage fuses for vehicles may be sold in "strip fuse" format, also known as a fusible link, designed to be clamped between two screw-down terminals. Since some jumpers may look very similar, it is important to keep them separate. A strip fuse is shown in Figure 4-7.<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhg_65BlVpgEB3VNL09ywZNStR8P0YC7mbl674PlOsgSx9db50NZZ-y9BR8fKv15pBSQz7g3LMhlxjHxaEz9bm98oNJu9pKDlwPhuCEbuTwY3rV23nsScIsTZtWENiQ9Xi6uQwSTeSmELTOKT68OasL6GMMsIHL9ME0TzSK5MTGwlaY_HJifiv8C5HE3w" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-7. This strip fuse is intended for use in diesel vehicles. The example shown is rated 100A at 36V." data-original-height="687" data-original-width="1000" height="220" src="https://blogger.googleusercontent.com/img/a/AVvXsEhg_65BlVpgEB3VNL09ywZNStR8P0YC7mbl674PlOsgSx9db50NZZ-y9BR8fKv15pBSQz7g3LMhlxjHxaEz9bm98oNJu9pKDlwPhuCEbuTwY3rV23nsScIsTZtWENiQ9Xi6uQwSTeSmELTOKT68OasL6GMMsIHL9ME0TzSK5MTGwlaY_HJifiv8C5HE3w=w320-h220" title="Figure 4-7. This strip fuse is intended for use in diesel vehicles. The example shown is rated 100A at 36V." width="320" /></a></div><br /></div><br /></div></div></div></div></div><p>Through-Hole Fuses</p><p>Small fuses with radial leads, which seem appropriate for through-hole insertion in printed circuit boards, are actually often used in conjunction with appropriate sockets, so that they can be easily replaced. They are described in catalogues as "subminiature fuses" and are typically found in laptop computers and their power supplies, also televisions, battery chargers, and air conditioners. Three examples are shown in Figure 4-8. All have slow-blowing characteristics.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjULbrqe5VMOf_MVG3EmelBO5Ycr-S-H5Ib68wUjIR07vvHX2hRv338iRM3YtKekYlBwqnFUD4HkBqBOhwPbL2-Tsp34FFhpjaYb9SEwkJznhGd1a24ZFDxd0IafQUfm8m4LqwcSXtGgU2bM_RMM-jrXybvy4xhCkSqss42kLKoWxHIHVhSo5VPqGXZjA" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="685" data-original-width="1000" height="219" src="https://blogger.googleusercontent.com/img/a/AVvXsEjULbrqe5VMOf_MVG3EmelBO5Ycr-S-H5Ib68wUjIR07vvHX2hRv338iRM3YtKekYlBwqnFUD4HkBqBOhwPbL2-Tsp34FFhpjaYb9SEwkJznhGd1a24ZFDxd0IafQUfm8m4LqwcSXtGgU2bM_RMM-jrXybvy4xhCkSqss42kLKoWxHIHVhSo5VPqGXZjA" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;"><h3 style="clear: both; text-align: left;">Resettable Fuses</h3><div class="separator" style="clear: both;">Properly known as a polymeric positive temperature coefficient fuse (often abbreviated PTC or PPTC), a resettable fuse is a solid-state, encapsulated component that greatly increases its resistance in response to a current overload, but gradually returns to its original condition when the flow of current is discontinued. It can be thought of as a thermistor that has a nonlinear response. Three through-hole examples are shown in Figure 4-9. While different sizes of cartridge fuse may share the same ratings, differently rated resettable fuses may be identical in size. The one on the left is rated 40A at 30V, while the one on the right is rated 2.5A at 30V. (Note that the codes printed on the fuses are not the same as their manufacturer part numbers.) The fuse at the top is rated 1A at 135V.</div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgvXW5ZCMM0F0BnMyv2xoTsiR_ba2zlVVouHLJGdAFdvOR_ih11oeJugC3Hy6a86Abn3khSz7-j8As5xFJ9485wFMiWISgD57Y7iL0Npk6XNNH84sY1ngNjg5ldCIMvdQOCt_ZOqT36fn25hekna4ZRlqy6Lk-BpkTVzwwZMMwPe0oLFY8dIY7cVXwxqQ" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-9. Some through-hole resettable fuses. See text for details." data-original-height="1000" data-original-width="934" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEgvXW5ZCMM0F0BnMyv2xoTsiR_ba2zlVVouHLJGdAFdvOR_ih11oeJugC3Hy6a86Abn3khSz7-j8As5xFJ9485wFMiWISgD57Y7iL0Npk6XNNH84sY1ngNjg5ldCIMvdQOCt_ZOqT36fn25hekna4ZRlqy6Lk-BpkTVzwwZMMwPe0oLFY8dIY7cVXwxqQ" title="Figure 4-9. Some through-hole resettable fuses. See text for details." width="224" /></a></div><br /><div class="separator" style="clear: both;">When more than the maximum current passes through the fuse, its internal resistance increases suddenly from a few ohms to hundreds of thousands of ohms. This is known as tripping the fuse. This inevitably entails a small delay, but is comparable to the time taken for a slow-blowing fuse to respond.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">A resettable fuse contains a polymer whose crystalline structure is loaded with graphite particles that conduct electricity. As current flowing through the fuse induces heat, the polymer transitions to an amorphous state, separating the graphite particles and interrupting the conductive pathways. A small current still passes through the component, sufficient to maintain its amorphous state until power is disconnected. After the resettable fuse cools, it gradually recrystallizes, although its resistance does not fall back completely to its original value for more than an hour.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">The maximum safe level of current for a resettable fuse is known as the hold current, while the current that triggers its response is termed the trip current. Resettable fuses are available with trip-current ratings from 20mA to 100A. While conventional appliance and electronics fuses may be rated as high as 600V, resettable fuses are seldom rated above 100V.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Typical cartridge fuses are affected only to a minor extent by temperature, but the current rating of a resettable fuse may diminish to 75% of its normal value at 50 degrees Centigrade and may drop to 50% of its normal value at 80 degrees Centigrade. In other words, a fuse that is rated for 4A at 25 degrees may tolerate a maximum of only 3A when it operates at twice that temperature. See Figure 4-10.</div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgKZ9KIpzx4NRPQoz2pF9Ed0qFV7L8VcRvmUl36F2cdHejR-ZT8a27QB-y19j2UtQYsyurEiGnKK-CJznTKnJKp1LsYhkAeuYp6Qs0SK-HKpsVXSwabEmGRNp3dOXXoyI8A1bfzxDN7J1gzjNtmGyLiPO2ivA3JpcWD7lXqEjpJk1LX--RH7dcc8zK-Ug" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="841" data-original-width="867" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEgKZ9KIpzx4NRPQoz2pF9Ed0qFV7L8VcRvmUl36F2cdHejR-ZT8a27QB-y19j2UtQYsyurEiGnKK-CJznTKnJKp1LsYhkAeuYp6Qs0SK-HKpsVXSwabEmGRNp3dOXXoyI8A1bfzxDN7J1gzjNtmGyLiPO2ivA3JpcWD7lXqEjpJk1LX--RH7dcc8zK-Ug" width="247" /></a></div><br /><br /></div></div><div class="separator" style="clear: both;"><br /></div></div><div>Conventional slow-blowing fuses are temperature-sensitive, but to a lesser degree than resettable fuses.</div><div><br /></div><div>Resettable fuses are used in computer power supplies, USB power sources, and loudspeaker enclosures, where they protect the speaker coils from being overdriven. They are appropriate in situations where a fuse may be tripped relatively often, or where technically unsophisticated users may feel unable to replace a fuse or reset a circuit breaker.</div><div><br /></div><div>Brand names for resettable fuses include PolySwitch, OptiReset, Everfuse, Polyfuse, and Multifuse. They are available in surface-mount (SMT) packages or as through-hole components, but not in cartridge format.</div><div><br /></div><div>Surface Mount Fuses</div><div>Because surface-mount fuses are difficult or impossible to replace after they have been soldered onto the board, they are often resettable.</div><div><br /></div><div>A surface-mount resettable fuse approximately 0.3" square is shown in Figure 4-11. It is rated for 230V and has an internal resistance of 50 ohms. Its hold current is 0.09A and its trip current is 0.19A.</div><div><br /></div><div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiJpxULJV8YuiRQ9o1ERl4HfNOfBlBJrKh_2nDr6ITbuOKAAI3kuTCPmjhlPw9U6ceAHLuarp8XASqwXQV7v93fhZv0veq0oQx6pc6VJxxioCKPKOVTpzKkCwZsVq5XXdl2dPzvk5ybYZ9aOS3tIwaZlLdIiVU_WAkI6dS7ZvBKk2iRxeM5SYfAtY_f8w" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="814" data-original-width="1000" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEiJpxULJV8YuiRQ9o1ERl4HfNOfBlBJrKh_2nDr6ITbuOKAAI3kuTCPmjhlPw9U6ceAHLuarp8XASqwXQV7v93fhZv0veq0oQx6pc6VJxxioCKPKOVTpzKkCwZsVq5XXdl2dPzvk5ybYZ9aOS3tIwaZlLdIiVU_WAkI6dS7ZvBKk2iRxeM5SYfAtY_f8w" width="295" /></a></div><br /><br /></div><br /><p></p><h3 style="text-align: left;">How to Use it</h3><p>Any equipment that may be plugged into a wall outlet should be fused, not only to protect its components but also to protect users who may open the box and start investigating with a screwdriver.</p><p><br /></p><p>Equipment that contains powerful motors, pumps, or other inductive loads should be protected with slow-blowing fuses, as the initial surge of current when the equipment is switched on is likely to rise well above the rating of the fuse. A slow-blowing fuse will tolerate a surge for a couple of seconds. Other fuses will not.</p><p><br /></p><p>Conversely, fast-acting fuses should be used with electronic equipment, especially integrated circuits that are quickly and easily damaged.</p><p><br /></p><p>Any device using substantial battery power should be fused because of the unpredictable and generally bad behavior of batteries when they are short-circuited. Parallel connections between multiple large batteries should be fused to avoid the possibility that a highly charged battery may attempt to recharge its neighbor(s). Large "J size" fuses rated from 125A to 450A have become common in the solar power community, where banks of lead-acid batteries are often used. These fuses have a thick brass tab at each end, drilled so that they can be bolted into place. Alternatively, they will push-fit into an appropriate fuseholder.</p><p><br /></p><p>For cartridge fuses up to 1/4" in diameter that don’t have leads attached, appropriately sized fuseholders are available in several formats:</p><p><br /></p><p>Panel mounted fuse enclosure is probably the most common, consisting of a plastic tube with a spring-contact at the bottom, and a plastic cap with a second contact inside. The cap either screws onto the tube of the fuse, or is pushed down and turned to hold it in place. A nut is provided to secure the fuseholder after it has been inserted into a hole drilled in the panel. The fuse is dropped into the tube, and the cap is applied. This type of holder is available in full-length or shorter, "low profile" formats. A low-profile holder is shown in Figure 4-12. It is shown assembled at right, with its component parts disassembled alongside.</p><p><br /></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgGqsq9Ck8cEGleiSpqo7a3dSLJMr8OFmZkoxkPQ-BgsCzeVcvtjZMP6P8xlTqoKAV_4lpj_xwQyZl10_CqAh2R11t325P7vUAKaQVLZqDzdatS0r1FR7c7tkq4QSnMmcnCNAHaxM51yvHtwmRe3ohGRYxnSJpp2RqArzbADIh3mBQHAHcI9exSdIEdpw" style="margin-left: 1em; margin-right: 1em;"><img alt="Figure 4-12. A low-profile panel-mounted fuse holder shown disassembled (left) and assembled (right)." data-original-height="925" data-original-width="1000" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEgGqsq9Ck8cEGleiSpqo7a3dSLJMr8OFmZkoxkPQ-BgsCzeVcvtjZMP6P8xlTqoKAV_4lpj_xwQyZl10_CqAh2R11t325P7vUAKaQVLZqDzdatS0r1FR7c7tkq4QSnMmcnCNAHaxM51yvHtwmRe3ohGRYxnSJpp2RqArzbADIh3mBQHAHcI9exSdIEdpw" title="Figure 4-12. A low-profile panel-mounted fuse holder shown disassembled (left) and assembled (right)." width="259" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p></p><div class="separator" style="clear: both;">Circuit board mounted fuse enclosure is basically the same as the panel-mounted version, but with through-hole solder pins attached.</div><div class="separator" style="clear: both;"><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Fuse block is a small plastic block with two clips on its upper surface for insertion of a cartridge fuse.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Fuse clips can be bought individually, with solder pins for through-hole mounting.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Inline fuse holder is designed to be inserted in a length of wire. Usually made of plastic, it will either terminate it, wires or will have metal contacts to crimp or solder at each end. See Figure 4-6.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Through-hole fuse holders are available for subminiature fuses.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><h2 style="clear: both; text-align: left;">What Can Go Wrong</h2><div class="separator" style="clear: both;">Repeated Failure</div><div class="separator" style="clear: both;">When a fuse in a circuit blows frequently, this is known as nuisance opening. Often it can result from failure to take into account all the aspects of the circuit, such as a large filtering capacitor in a power supply that draws a major surge of current when the power supply is switched on. The formally correct procedure to address this problem is to measure the power surge, properly known as peak inrush current, with an oscilloscope, calculate the I2 * t of the wave form, and select a fuse with a rating at least 5 times that value.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">A fuse should never be replaced with an equivalent length of wire or any other conductor.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Soldering Damage</div><div class="separator" style="clear: both;">When a through-hole or surface-mount fuse is soldered into place, heat from the soldering process can cause the soft metal element inside the fuse to melt partially and reflow. This is likely to change the rating of the fuse. Generally, fuses should be treated with the same caution as semiconductors when they are fixed in place with solder.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Placement</div><div class="separator" style="clear: both;">A fuse should be placed close to the power source or power input point in a circuit, so that it protects as much of the circuit as possible.</div></div></div><p><br /><br /></p>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-12954536156920508912022-12-05T11:44:00.017+06:002022-12-05T11:44:00.144+06:00arduino divide two integers<p>You want to find the remainder after you divide two integer values.</p><p><span style="font-family: Fira Code;">int myValue0 = 20 % 10; // get the modulus(remainder) of 20 divided by 10</span></p><p><span style="font-family: Fira Code;">int myValue1 = 21 % 10; // get the modulus(remainder) of 21 divided by 10</span></p><p><br /></p><p>myValue0 equals 0 (20 divided by 10 has a remainder of 0). myValue1 equals 1 (21 divided by 10 has a remainder of 1).</p><p><br /></p><p>The modulus operator is surprisingly useful, particularly when you want to see if a value is a multiple of a number. For example, the code in this recipe’s Solution can be enhanced to detect when a value is a multiple of 10:</p><p>for (int myValue = 0; myValue <= 100; myValue += 5)</p><p>{</p><p> if (myValue % 10 == 0)</p><p> {</p><p> Serial.println("The value is a multiple of 10");</p><p> }</p><p>}</p><p><br /></p><p>The preceding code takes the modulus of the myValue variable and compares the result to zero </p><p>Here is a similar example, but by using 2 with the modulus operator, the result can be used to check if a value is odd or even:</p><p><span style="font-family: Source Code Pro;">for (int myValue = 0; myValue <= 10; myValue++)</span></p><p><span style="font-family: Source Code Pro;">{</span></p><p><span style="font-family: Source Code Pro;"> if (myValue % 2 == 0)</span></p><p><span style="font-family: Source Code Pro;"> {</span></p><p><span style="font-family: Source Code Pro;"> Serial.println("The value is even");</span></p><p><span style="font-family: Source Code Pro;"> }</span></p><p><span style="font-family: Source Code Pro;"> else</span></p><p><span style="font-family: Source Code Pro;"> {</span></p><p><span style="font-family: Source Code Pro;"> Serial.println("The value is odd");</span></p><p><span style="font-family: Source Code Pro;"> }</span></p><p><span style="font-family: Source Code Pro;">}</span></p><br /><br />This example calculates the hour on a 24-hour clock for any given number of hours offset:<div><br /></div><div><div><span style="font-family: Source Code Pro;">void printOffsetHour( int hourNow, int offsetHours)</span></div><div><span style="font-family: Source Code Pro;">{</span></div><div><span style="font-family: Source Code Pro;"> Serial.println((hourNow + offsetHours) % 24);</span></div><div><span style="font-family: Source Code Pro;">}</span></div><br />You can also use the modulus operator to help simulate floating-point operations. For example, consider the problem described in where dividing 36.3 by 3 yields 12.0999994277 rather than the expected 12.1. You can multiply the two values by 10, then perform the division as an integer operation to get the integer part:<br /><pre data-code-language="arduino" data-type="programlisting" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; vertical-align: baseline; word-break: keep-all;"><code class="p" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; font-family: "Fira Code"; font-size: 16px; hyphens: none; line-height: 1.5em; margin: 0.75em 0px 1.25em; outline: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; vertical-align: baseline; white-space: pre-wrap; word-break: break-word;">int int_part = 363/30; // result: 12</code><code class="p" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; font-size: 16px; hyphens: none; line-height: 1.5em; margin: 0.75em 0px 1.25em; outline: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; vertical-align: baseline; white-space: pre-wrap; word-break: break-word;">
</code></pre><pre data-code-language="arduino" data-type="programlisting" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; vertical-align: baseline; word-break: keep-all;"><code class="p" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; font-size: 16px; hyphens: none; line-height: 1.5em; margin: 0.75em 0px 1.25em; outline: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; vertical-align: baseline; white-space: pre-wrap; word-break: break-word;"><span style="font-family: arial;">Next, you can calculate the remainder, multiply it by 100, then divide by the divisor to get the fractional part:</span></code></pre><pre data-code-language="arduino" data-type="programlisting" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; vertical-align: baseline; word-break: keep-all;"><code class="p" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; font-size: 16px; hyphens: none; line-height: 1.5em; margin: 0.75em 0px 1.25em; outline: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; vertical-align: baseline; white-space: pre-wrap; word-break: break-word;"><span style="font-family: Fira Code;">int remainder = 363 % 30; // result: 3
int fractional_part = remainder * 100 / 30;</span></code></pre><div><span><code class="p" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; font-size: 16px; hyphens: none; line-height: 1.5em; margin: 0.75em 0px 1.25em; outline: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; vertical-align: baseline; white-space: pre-wrap; word-break: break-word;"><br /></code></span></div><section data-pdf-bookmark="Solution" data-type="sect2" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; box-sizing: border-box; color: #333333; font-family: serif, DejaVuSerif; font-size: 20px; overflow-wrap: break-word; word-break: break-word;"><div class="sect2" id="solution-id29" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; text-indent: 0pt; vertical-align: baseline; word-break: break-word;"></div></section></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-44044151424102550562022-12-04T11:25:00.001+06:002022-12-04T11:25:00.145+06:00Arduino incrementing variables<p> You want to Arduino incrementing variables . In this guide I will show you Arduino incrementing variables step by step complete process. </p><h3 style="text-align: left;">Arduino incrementing variables Code</h3><div style="line-height: 19px;"><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"><span style="color: #727c81;">// Incrementing and Decrementing Values</span></div><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"><span style="color: blue;">void</span> <span style="color: #5e6d03;">setup</span>() {</div><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> <span style="color: #e97366; font-weight: bold;">Serial</span>.<span style="color: #e97366;">begin</span>(<span style="color: #098658;">9600</span>);</div><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> </div><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> <span style="color: blue;">int</span> myValue = <span style="color: #098658;">0</span>;</div><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> myValue = myValue + <span style="color: #098658;">1</span>; <span style="color: #727c81;">// this adds one to the variable myValue</span></div><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> myValue += <span style="color: #098658;">1</span>; <span style="color: #727c81;">// this does the same as the above</span></div><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> myValue = myValue - <span style="color: #098658;">1</span>; <span style="color: #727c81;">// this subtracts one from the variable myValue</span></div><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> myValue -= <span style="color: #098658;">1</span>; <span style="color: #727c81;">// this does the same as the above</span></div><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> myValue = myValue + <span style="color: #098658;">5</span>; <span style="color: #727c81;">// this adds five to the variable myValue</span></div><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> myValue += <span style="color: #098658;">6</span>; <span style="color: #727c81;">// this does the same as the above</span></div><br /><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> <span style="color: #e97366; font-weight: bold;">Serial</span>.<span style="color: #e97366;">println</span>(myValue);</div><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;">}</div><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"><span style="color: blue;">void</span> <span style="color: #5e6d03;">loop</span>() {</div><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;"> <span style="color: #727c81;">// put your main code here, to run repeatedly:</span></div><br /><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; white-space: pre;">}</div><div><div class="separator" style="background-color: #fffffe; clear: both; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; text-align: center; white-space: pre;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /><div class="separator" style="background-color: #fffffe; clear: both; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; text-align: center; white-space: pre;"><br /></div><div class="separator" style="background-color: #fffffe; clear: both; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; text-align: left; white-space: pre;"><br /></div><div class="separator" style="clear: both;"><div class="separator" style="background-color: #fffffe; clear: both; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; text-align: center; white-space: pre;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIBpM8ACLftbKUET_8rC-maZWMoj-5Ehz_E0U9-hBKT4PtGNUOnalSxqo8QYNM7YMExD13aceZxO49gAkuSS1GCCjyNXfeCBo88ddV0VdJ8cC83e4snNUcITzco0Vu5wllQg20LlxONqAO1I8UOLTTM2xYoB01yJUkFOiMB5LH-VaQZtrFVh_jpeX_9w/s852/3.2%20Incrementing%20and%20Decrementing%20Values.png" style="margin-left: 1em; margin-right: 1em;"><img alt="Arduino incrementing variables" border="0" data-original-height="470" data-original-width="852" height="177" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIBpM8ACLftbKUET_8rC-maZWMoj-5Ehz_E0U9-hBKT4PtGNUOnalSxqo8QYNM7YMExD13aceZxO49gAkuSS1GCCjyNXfeCBo88ddV0VdJ8cC83e4snNUcITzco0Vu5wllQg20LlxONqAO1I8UOLTTM2xYoB01yJUkFOiMB5LH-VaQZtrFVh_jpeX_9w/w320-h177/3.2%20Incrementing%20and%20Decrementing%20Values.png" title="Arduino incrementing variables" width="320" /></a></div><div class="separator" style="background-color: #fffffe; clear: both; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; text-align: left; white-space: pre;"><br /></div><br /><br /><div style="text-align: left;">Increasing and decreasing the values of variables is one of the most common programming tasks, and Arduino has operators to make this easy. Increasing a value by one is called incrementing, and decreasing it by one is called decrementing. The longhand way to do this is as follows:</div><div style="text-align: left;"><br /></div><div style="text-align: left;"><div>myValue = myValue + 1; // this adds one to the variable myValue</div><div><br /></div><div>But you can also combine the increment and decrement operators with the assign operator, like this:</div><div><div><br /></div><div>myValue += 1; // this does the same as the above</div></div><div><br /></div><div>If you are incrementing or decrementing a value by 1, you can use the abbreviated increment and decrement operators ++ or --:</div><div><br /></div><div><div>myValue++; // this does the same as the above</div></div><div><br /></div><div>When the increment or decrement operators appear after a variable, they are known as the post-increment or post-decrement operators because they perform their operation after the variable is evaluated. If they appear before the identifier (pre-increment or pre-decrement), they modify the value before the variable is evaluated:</div><div><br /></div><div><br /></div><div><blockquote style="background-color: white; border-left: 5px solid rgb(238, 238, 238); box-sizing: border-box; font-family: "typonine sans regular"; font-size: 17.5px; letter-spacing: 0.3px; margin: 1em 40px; padding: 10px 20px;"><span style="box-sizing: border-box; font-family: "typonine sans medium"; margin: 0px; padding: 0px;"><em style="box-sizing: border-box; margin: 0px; padding: 0px;">Acknowledgment</em></span></blockquote><blockquote style="background-color: white; border-left: 5px solid rgb(238, 238, 238); box-sizing: border-box; font-family: "typonine sans regular"; font-size: 17.5px; letter-spacing: 0.3px; margin: 1em 40px; padding: 10px 20px;"><span style="box-sizing: border-box; font-family: "typonine sans medium"; margin: 0px; padding: 0px;"><em style="box-sizing: border-box; margin: 0px; padding: 0px;">I took help from</em></span><span style="box-sizing: border-box; margin: 0px; padding: 0px;"> </span><span style="box-sizing: border-box; font-family: "typonine sans medium"; margin: 0px; padding: 0px;"><em style="box-sizing: border-box; margin: 0px; padding: 0px;"><a href="https://amzn.to/3SR4szB" rel="nofollow" style="background-color: transparent; box-sizing: border-box; color: #00979c; margin: 0px; padding: 0px; text-decoration-line: none;">Arduino Cookbook Book</a></em></span><a href="https://amzn.to/3SR4szB" rel="nofollow" style="background-color: transparent; box-sizing: border-box; color: #00979c; margin: 0px; padding: 0px; text-decoration-line: none;"> </a> Arduino incrementing variables <span style="box-sizing: border-box; font-family: "typonine sans medium"; margin: 0px; padding: 0px;"><em style="box-sizing: border-box; margin: 0px; padding: 0px;">tutorial. This cookbook is perfect for anyone who wants to experiment with the popular Arduino microcontroller and programming environment. You’ll find more than 200 tips and techniques for building a variety of objects and prototypes such as IoT solutions, environmental monitors, location and position-aware systems, and products that can respond to touch, sound, heat, and light.</em></span></blockquote></div><div><br /></div><div><br /></div><div><br /></div></div></div></div></div></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-23664854628361000342022-12-03T11:14:00.052+06:002022-12-03T11:24:07.140+06:00Arduino basic math<p><br /></p>You want to work on Arduino basic math on values in your sketch. You want to control the order in which the operations are performed and you may need to handle different variable types. In this guide I will show you how to do Arduino basic math step by step complete process. <br /><br /><br /><br />Use the following code:<div><br /></div><div><div>int myValue;</div><div>myValue = 1 + 2; // addition</div><div>myValue = 3 - 2; // subtraction</div><div>myValue = 3 * 2; // multiplication</div><div>myValue = 3 / 2; // division (the result is 1)</div><br /><section data-pdf-bookmark="Discussion" data-type="sect2" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; box-sizing: border-box; overflow-wrap: break-word; word-break: break-word;"><div class="sect2" id="discussion-id27" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word;"><h2 style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; break-after: avoid; hyphens: none; line-height: 1.1; margin: 30px 0px 8px; outline: 0px; overflow-wrap: break-word; padding: 0px; text-indent: 0pt; vertical-align: baseline; word-break: break-word;"><div class="separator" style="clear: both;"><br /></div></h2>Addition, subtraction, and multiplication for integers work much as you expect.<br /><br />Integer division truncates the fractional remainder in the division example shown in this recipe’s Solution; myValue will equal 1 after the division<br /><div class="sect2" id="discussion-id27" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word;"><br /></div><div class="sect2" id="discussion-id27" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word;">int value = 1 + 2 * 3 + 4;</div><div><br /></div><br />Compound statements, such as the preceding statement, may appear ambiguous, but the precedence (order) of every operator is well-defined. Multiplication and division have higher precedence than addition and subtraction, so the result will be 11. It’s advisable to use parentheses in your code to make the desired calculation precedence clear. int value = 1 + (2 * 3) + 4; produces the same result but is easier to read.<br /><br />Use parentheses if you need to alter the precedence, as in this example:<br /><pre data-code-language="arduino" data-type="programlisting" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; vertical-align: baseline; word-break: keep-all;"> int value = ((1 + 2) * 3) + 4;<br /><br /><br /><span style="color: #404040; font-family: Ubuntu Mono, monospace;"><span style="white-space: pre-wrap;">The result will be 13. The expression in the inner parentheses is calculated first, so 1 gets added to 2, this then gets multiplied by 3, and finally is added to 4, yielding 13.</span></span></pre><p style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; hyphens: auto; line-height: 1.5em; margin: 0.75em 0px 1.25em; outline: 0px; overflow-wrap: break-word; padding: 0px; text-align: left; vertical-align: baseline; word-break: break-word;"><br />You’ll need to make sure your result will not exceed the maximum size of the destination variable because the Arduino IDE will not warn you about that, unless you enable warnings in File→Preferences. However, even if you use the correct type, you can still overflow the size of the destination variable. Consider this code:</p><pre data-code-language="arduino" data-type="programlisting" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; text-indent: 0pt; vertical-align: baseline; word-break: keep-all;"><span style="color: #404040; font-family: Ubuntu Mono, monospace;"><span style="font-size: 16px; white-space: pre-wrap;">// 60 seconds in a minute, 60 minutes in an hour, 24 hours in a day
long seconds_per_day = 60 * 60 * 24;</span></span></pre>In theory, that should be fine because the result is 86,400, which can fit in a long data type. But the value that’s really stored in seconds_per_day is 20,864. 86,400 is enough to overflow an integer twice (86,400 – 32,768 * 2 = 20,864). The overflow happens because the Arduino IDE’s C compiler sees an arithmetic expression composed of integers, and doesn’t know any better. You must tell the compiler that it should treat the whole expression like a long by appending L to the first value that is evaluated in the expression:<br /><pre data-code-language="arduino" data-type="programlisting" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; vertical-align: baseline; word-break: keep-all;">long seconds_per_day = 60L * 60 * 24;</pre><pre data-code-language="arduino" data-type="programlisting" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; vertical-align: baseline; word-break: keep-all;"><br /><span style="color: #404040; font-family: Ubuntu Mono, monospace;"><span style="white-space: pre-wrap;">If, for some reason, you are using parentheses, remember that innermost parentheses are evaluated first, so this will overflow:</span></span></pre>long seconds_per_day_plus_one = 1L + 60 * (60 * 24);</div><div class="sect2" id="discussion-id27" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word;"><br /></div><div class="sect2" id="discussion-id27" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word;">However, this will run correctly:</div><div class="sect2" id="discussion-id27" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word;"><br /></div><div class="sect2" id="discussion-id27" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-break: break-word;">long seconds_per_day_plus_one = 1 + 60 * (60L * 24);<h3 style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #404040; font-family: "Ubuntu Mono", monospace; font-size: 16px; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; text-align: left; text-indent: 0pt; vertical-align: baseline; white-space: pre-wrap; word-break: keep-all;"><code class="p" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: black; font-family: inherit; font-size: inherit; hyphens: none; line-height: 1.5em; margin: 0.75em 0px 1.25em; outline: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; vertical-align: baseline; word-break: break-word;">Complet code Arduino basic math</code></h3><pre data-code-language="arduino" data-type="programlisting" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #404040; font-family: "Ubuntu Mono", monospace; font-size: 16px; hyphens: none; line-height: 1.5em; margin-bottom: 25px; margin-left: 20px; margin-top: 25px; outline: 0px; overflow-wrap: break-word; overflow: unset; padding: 0px; text-indent: 0pt; vertical-align: baseline; white-space: pre-wrap; word-break: keep-all;"><code class="p" style="-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: black; font-family: inherit; font-size: inherit; hyphens: none; line-height: 1.5em; margin: 0.75em 0px 1.25em; outline: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; vertical-align: baseline; word-break: break-word;"><div style="background-color: #fffffe; font-family: "Droid Sans Mono", "monospace", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><br /><div><span style="color: #727c81;">// Adding, Subtracting, Multiplying, and Dividing</span></div><br /><div><span style="color: blue;">void</span> <span style="color: #5e6d03;">setup</span>() {</div><div> <span style="color: #e97366; font-weight: bold;">Serial</span>.<span style="color: #e97366;">begin</span>(<span style="color: #098658;">9600</span>);</div><div> <span style="color: #727c81;">// put your setup code here, to run once:</span></div><div> <span style="color: blue;">int</span> myValue;</div><div> myValue = <span style="color: #098658;">1</span> + <span style="color: #098658;">2</span>; <span style="color: #727c81;">// addition</span></div><div> myValue = <span style="color: #098658;">3</span> - <span style="color: #098658;">2</span>; <span style="color: #727c81;">// subtraction</span></div><div> myValue = <span style="color: #098658;">3</span> * <span style="color: #098658;">2</span>; <span style="color: #727c81;">// multiplication</span></div><div> myValue = <span style="color: #098658;">3</span> / <span style="color: #098658;">2</span>; <span style="color: #727c81;">// division (the result is 1)</span></div><div> myValue * <span style="color: #098658;">2</span>;</div><div> {</div><div> <span style="color: blue;">int</span> value = <span style="color: #098658;">1</span> + <span style="color: #098658;">2</span> * <span style="color: #098658;">3</span> + <span style="color: #098658;">4</span>;</div><div> value * <span style="color: #098658;">2</span>;</div><div> }</div><div> {</div><div> <span style="color: blue;">int</span> value = ((<span style="color: #098658;">1</span> + <span style="color: #098658;">2</span>) * <span style="color: #098658;">3</span>) + <span style="color: #098658;">4</span>;</div><div> value * <span style="color: #098658;">2</span>;</div><div> }</div><br /><div> {</div><div> <span style="color: #727c81;">// 60 seconds in a minute, 60 minutes in an hour, 24 hours in a day</span></div><div> <span style="color: blue;">long</span> seconds_per_day = <span style="color: #098658;">60</span> * <span style="color: #098658;">60</span> * <span style="color: #098658;">24</span>;</div><div> <span style="color: #e97366; font-weight: bold;">Serial</span>.<span style="color: #e97366;">println</span>(seconds_per_day);</div><div> }</div><div> {</div><div> <span style="color: blue;">long</span> seconds_per_day = <span style="color: #098658;">60L</span> * <span style="color: #098658;">60</span> * <span style="color: #098658;">24</span>;</div><div> <span style="color: #e97366; font-weight: bold;">Serial</span>.<span style="color: #e97366;">println</span>(seconds_per_day);</div><div> }</div><div> {</div><div> <span style="color: blue;">long</span> seconds_per_day_plus_one = <span style="color: #098658;">1L</span> + <span style="color: #098658;">60</span> * (<span style="color: #098658;">60</span> * <span style="color: #098658;">24</span>);</div><div> <span style="color: #e97366; font-weight: bold;">Serial</span>.<span style="color: #e97366;">println</span>(seconds_per_day_plus_one);</div><div> }</div><div> {</div><div> <span style="color: blue;">long</span> seconds_per_day_plus_one = <span style="color: #098658;">1</span> + <span style="color: #098658;">60</span> * (<span style="color: #098658;">60L</span> * <span style="color: #098658;">24</span>);</div><div> <span style="color: #e97366; font-weight: bold;">Serial</span>.<span style="color: #e97366;">println</span>(seconds_per_day_plus_one);</div><div> }</div><div>}</div><br /><div><span style="color: blue;">void</span> <span style="color: #5e6d03;">loop</span>() {</div><div> <span style="color: #727c81;">// put your main code here, to run repeatedly:</span></div><br /><div>}</div><div><br /></div><div><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgT5h3nvoJarSrLEJFMRSQgPES70-DC9yGzXR28C1sH1pAqs5fmUjA_Fc-4WRAHBUAehy_5t5nhHuYsZhukJbyuE8CUN2a5pLExeco97eYwVe9UohEfhpJrtNa-JUdKT1u2ChwcZJw40xK7x4LZ2UFecT65Ja6vSUpB1iF10PFZCfJnqsFO62O9y9LcrA" style="font-family: "Times New Roman"; font-size: 24px; font-weight: 700; margin-left: 1em; margin-right: 1em; white-space: normal;"><img alt="" data-original-height="474" data-original-width="627" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEgT5h3nvoJarSrLEJFMRSQgPES70-DC9yGzXR28C1sH1pAqs5fmUjA_Fc-4WRAHBUAehy_5t5nhHuYsZhukJbyuE8CUN2a5pLExeco97eYwVe9UohEfhpJrtNa-JUdKT1u2ChwcZJw40xK7x4LZ2UFecT65Ja6vSUpB1iF10PFZCfJnqsFO62O9y9LcrA" width="317" /></a></div><div><br /></div><div><blockquote style="background-color: white; border-left: 5px solid rgb(238, 238, 238); box-sizing: border-box; font-family: "typonine sans regular"; font-size: 17.5px; letter-spacing: 0.3px; margin: 1em 40px; padding: 10px 20px; white-space: normal;"><span style="box-sizing: border-box; font-family: "typonine sans medium"; margin: 0px; padding: 0px;"><em style="box-sizing: border-box; margin: 0px; padding: 0px;">Acknowledgment</em></span></blockquote><blockquote style="background-color: white; border-left: 5px solid rgb(238, 238, 238); box-sizing: border-box; font-family: "typonine sans regular"; font-size: 17.5px; letter-spacing: 0.3px; margin: 1em 40px; padding: 10px 20px; white-space: normal;"><span style="box-sizing: border-box; font-family: "typonine sans medium"; margin: 0px; padding: 0px;"><em style="box-sizing: border-box; margin: 0px; padding: 0px;">I took help from</em></span><span style="box-sizing: border-box; margin: 0px; padding: 0px;"> </span><span style="box-sizing: border-box; font-family: "typonine sans medium"; margin: 0px; padding: 0px;"><em style="box-sizing: border-box; margin: 0px; padding: 0px;"><a href="https://amzn.to/3SR4szB" rel="nofollow" style="background-color: transparent; box-sizing: border-box; color: #00979c; margin: 0px; padding: 0px; text-decoration-line: none;">Arduino Cookbook Book</a></em></span><a href="https://amzn.to/3SR4szB" rel="nofollow" style="background-color: transparent; box-sizing: border-box; color: #00979c; margin: 0px; padding: 0px; text-decoration-line: none;"> </a> <span style="box-sizing: border-box; margin: 0px; padding: 0px;"> Arduino basic math </span><span style="box-sizing: border-box; font-family: "typonine sans medium"; margin: 0px; padding: 0px;"><em style="box-sizing: border-box; margin: 0px; padding: 0px;">tutorial. This cookbook is perfect for anyone who wants to experiment with the popular Arduino microcontroller and programming environment. You’ll find more than 200 tips and techniques for building a variety of objects and prototypes such as IoT solutions, environmental monitors, location and position-aware systems, and products that can respond to touch, sound, heat, and light.</em></span></blockquote></div><div><br /></div></div></code></pre></div></section></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-14992282607805558422022-06-03T10:36:00.001+06:002022-06-03T10:36:00.155+06:00How to Sending Tweets Using ThingSpeak with Raspberry Pi<h1 style="text-align: left;"><span><font face="">How to Sending Tweets Using ThingSpeak with Raspberry Pi</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">You <span class="words" data-synonyms="want;need" title="">need</span> to <span class="words" data-synonyms="automatically;naturally;consequently" title="">automatically</span> send tweets from your Raspberry Pi. Today I show you, How to Sending Tweets Using ThingSpeak with Raspberry Pi. for example, to <span class="words" data-synonyms="irritate;bother;chafe;aggravate" title="">irritate</span> <span class="words" data-synonyms="people;individuals" title="">people</span> by telling them the temperature of your CPU.</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-1eeWli9LD5A/XvLYOq7aP9I/AAAAAAAAF1A/pfjOjvgmcuMoZtZTf6CvBbwW9lqtSBLRwCK4BGAsYHg/s596/twiterpost.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="95" data-original-width="596" src="https://1.bp.blogspot.com/-1eeWli9LD5A/XvLYOq7aP9I/AAAAAAAAF1A/pfjOjvgmcuMoZtZTf6CvBbwW9lqtSBLRwCK4BGAsYHg/s320/twiterpost.JPG" width="320" /></a></div><span style="font-family: arial, helvetica, sans-serif;"><br /></span><p></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Components Required :</span></h2><hr /><div><h4><span style="font-family: arial, helvetica, sans-serif;">Here <span class="words" data-synonyms="is a;may be a;could be a" title="">is a</span> list of the <span class="words" data-synonyms="equipment;gear;hardware" title="">hardware</span> we <span class="words" data-synonyms="recommend;suggest;prescribe" title="">suggest</span> for this <span class="words" data-synonyms="tutorial;instructional exercise" title="">tutorial</span> on ThingSpeak Tweets Raspberry Pi</span></h4><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img alt="Raspberry pi" border="0" class="alignnone" height="120" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" width="160" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2. <a href="https://amzn.to/2NeiiwH" rel="noopener noreferrer" target="_blank">Micro SD Card</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Sandisk-Ultra-Micro-UHS-I-Adapter/dp/B073K14CVB/ref=as_li_ss_il?s=pc&ie=UTF8&qid=1530856971&sr=1-3&keywords=16gb+micro+sd+card+class+10&linkCode=li2&tag=sarful-20&linkId=7bd557de6615c6e30c98ebad7a976622&language=en_US" rel="noopener noreferrer" target="_blank"><img alt="Micro SD Card" border="0" class="alignnone" height="116" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B073K14CVB&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" width="160" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B073K14CVB" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3.<a href="https://amzn.to/2Bn579S" rel="noopener noreferrer" target="_blank">Ethernet cable</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Ethernet-Outdoor-Connector-Weatherproof-Resistant/dp/B07QLXC6QR/ref=as_li_ss_il?dchild=1&keywords=ethernet+cable&qid=1592668420&s=electronics&sr=1-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRDUwSThJNE80TVNFJmVuY3J5cHRlZElkPUEwMjE5ODQ5M0FLV1hJT09ZODMzVyZlbmNyeXB0ZWRBZElkPUEwMjQ4NzQ1MU9CV1NZOUkzS09SUCZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=&linkCode=li2&tag=sarful-20&linkId=342c6ec93ab949bd64c1fc92dadd716c&language=en_US" rel="noopener noreferrer" target="_blank"><img alt="Ethernet cable" border="0" class="alignnone" height="160" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07QLXC6QR&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" width="160" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07QLXC6QR" width="1" /></span></p><div><span style="font-family: arial, helvetica, sans-serif;">4.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img alt="Power Supply" border="0" class="alignnone" height="135" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" width="160" /></a></span></div><div><p><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></p><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><hr /></div><h2><span style="font-family: arial, helvetica, sans-serif;"><strong>≡ Create ThingSpek Account :</strong></span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">ThingSpeak is <span class="words" data-synonyms="similar;comparative;comparable" title="">similar</span> to <a href="https://www.mechatronicslab.net/raspberry-pi-email-send-with-ifttt/" rel="noopener noreferrer" target="_blank">Raspberry Pi Email send with IFTTT</a> but is <span class="words" data-synonyms="aimed;pointed" title="">pointed</span> <span class="words" data-synonyms="squarely;unequivocally;decisively" title="">squarely</span> at IoT <span class="words" data-synonyms="projects;ventures" title="">projects</span>. It allows you <span class="words" data-synonyms="to create;to make;to form" title="">to create</span> channels that can store and retrieve data using web requests, <span class="words" data-synonyms="and also;additionally;conjointly" title="">and also</span> <span class="words" data-synonyms="has a;features a;includes a;contains a;encompasses a;incorporates a" title="">contains a</span> number of <span class="words" data-synonyms="actions;activities" title="">activities</span>, <span class="words" data-synonyms="including;counting" title="">including</span> ThingTweet, which provides web <span class="words" data-synonyms="services;administrations" title="">services</span> wrapper around Twitter. <span class="words" data-synonyms="This is;This is often;Typically;Usually;This can be" title="">This is often</span> <span class="words" data-synonyms="easier;less demanding;simpler" title="">less demanding</span> to <span class="words" data-synonyms="use;utilize" title="">utilize</span> than the Twitter API, <span class="words" data-synonyms="which requires;which needs" title="">which needs</span> you to <span class="words" data-synonyms="register;enlist;enroll" title="">register</span> your application with Twitter. Start by <span class="words" data-synonyms="visiting;going to;going by" title="">going by</span> https://thingspeak.com and <span class="words" data-synonyms="signing;marking" title="">signing</span> up.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"> <span class="words" data-synonyms="Then;At that point" title="">At that point</span> select the ThingTweet <span class="words" data-synonyms="action;activity" title="">action</span>. <span class="words" data-synonyms="You will;You'll;You may" title="">You'll </span>be <span class="words" data-synonyms="prompted;provoked;incited" title="">provoked</span> to log in to Twitter.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="The ThingTweet action" class="alignnone size-medium wp-image-736" height="260" src="https://www.mechatronicslab.net/my_uploads/2020/06/t1-wpp1592969310118-e1592969352493-300x260.jpg" width="300" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">Now you have to time link your twitter account <span class="words" data-synonyms="service;benefit" title="">screenshot below</span>.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="The ThingTweet action" class="alignnone size-medium wp-image-737" height="68" src="https://www.mechatronicslab.net/my_uploads/2020/06/t2-wpp1592970272183-300x68.jpg" width="300" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="The ThingTweet action" class="alignnone size-medium wp-image-738" height="148" src="https://www.mechatronicslab.net/my_uploads/2020/06/t3-wpp1592970447569-e1592970477348-300x148.jpg" width="300" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">You can see Your API key On this page, <span class="words" data-synonyms="copy;duplicate" title="">copy</span> down the API key and past on your python Program </span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="The ThingTweet action" class="alignnone size-medium wp-image-739" height="111" src="https://www.mechatronicslab.net/my_uploads/2020/06/t4-wpp1592970641135-e1592970692571-300x111.jpg" width="300" /></span></p></div><div><hr /></div><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Preparing your Raspberry Pi for this project:</span></h2><hr /><div> </div><div><span style="font-family: arial, helvetica, sans-serif;">In this <span class="words" data-synonyms="section;area;segment" title="">section</span>, <span class="words" data-synonyms="we will;we'll;we are going to" title="">we’ll </span>be showing you how to Raspberry Pi for this project. if you First-time run project you have to need to update your raspberry pi <span class="words" data-synonyms="You can;You'll;You'll be able to">You’ll </span>do this by running the following commands.</span></div><div><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">sudo apt update
sudo apt upgrade</span></pre><h4><span style="font-family: arial, helvetica, sans-serif;">Now you have to need library install for this project <span class="words" data-synonyms="You can;You'll;You'll be able to">You’ll </span>do this by running the following commands. </span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">pip install urllib3
Or
sudo apt-get install urllib2</span></pre></div><div><hr /><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Code ThingSpeak Tweets Raspberry Pi:</span></h2><hr /><h4><span style="font-family: arial, helvetica, sans-serif;">The Python program to ThingSpeak Tweets Raspberry Pi</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">import time, os, urllib, urllib2
MAX_TEMP = 37.0
MIN_T_BETWEEN_WARNINGS = 60 # Minutes
BASE_URL = 'https://api.thingspeak.com/apps/thingtweet/1/statuses/update/'
KEY = '68LZC4LBMMMO6YDY'
def send_notification(temp):
status = 'Hello Raspberry Pi getting hot. CPU temp=' + temp
data = urllib.urlencode({'api_key' : KEY, 'status': status})
response = urllib2.urlopen(url=BASE_URL, data=data)
print(response.read())
def cpu_temp():
dev = os.popen('/opt/vc/bin/vcgencmd measure_temp')
cpu_temp = dev.read()[5:-3]
return cpu_temp
while True:
temp = cpu_temp()
print("CPU Temp (C): " + str(temp))
if temp > MAX_TEMP:
print("CPU TOO HOT!")
send_notification(temp)
print("No more notifications for: " + str(MIN_T_BETWEEN_WARNINGS) +
" mins")
time.sleep(MIN_T_BETWEEN_WARNINGS * 60)
time.sleep(1)</span></pre><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="Before;Some time recently" title="">Before</span> running the program, <span class="words" data-synonyms="you will;you'll;you may" title="">you’ll </span><span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">have to get</span> an <span class="words" data-synonyms="access;get to" title="">get to</span> the key for the Maker Action channel by selecting Channels, <span class="words" data-synonyms="and then;and after that" title="">and after that</span> <span class="words" data-synonyms="searching;looking" title="">searching</span> for Maker. Paste the key into thingtweetl.py on the line that <span class="words" data-synonyms="starts;begins">begins</span> KEY= and then run the program <span class="words" data-synonyms="using;utilizing" title="">using the screenshot below</span>:</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="The ThingTweet action" class="alignnone size-medium wp-image-740" height="180" src="https://www.mechatronicslab.net/my_uploads/2020/06/t-terminal-wpp1592971587565-e1592971614821-300x180.jpg" width="300" /></span></p><h4><span style="font-family: arial, helvetica, sans-serif;">Notice how the values have been substituted into the Tweeter <span class="words" data-synonyms="using;utilizing" title="">screenshot below </span></span></h4><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="The ThingTweet action" class="alignnone wp-image-741 size-medium" height="48" src="https://www.mechatronicslab.net/my_uploads/2020/06/twiterpost-wpp1592971725373-300x48.jpg" title="The ThingTweet action" width="300" /></span></p></div><h2><span style="font-family: arial, helvetica, sans-serif;">If you want to know more about raspberry pi then click on the link below</span></h2><h4 class="page-title is-large uppercase"><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></span></h4><div> </div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-28402492675237369012022-05-27T20:19:00.001+06:002022-05-27T20:19:00.141+06:00Raspberry Pi Email send with IFTTT<h1 style="text-align: left;"><span><font face="arial, helvetica, sans-serif">Raspberry Pi Email send with IFTTT</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">You went to do Raspberry Pi Email send with the IFTTT project. Today I show you How to send an email with IFTTT Using Raspberry Pi step by step in the complete process. and in this Project, we show an example that sends an email when the CPU temperature of your Raspberry Pi exceeds a threshold.</span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Components Required Raspberry Pi Email send IFTTT :</span></h2><hr /><div><p><span style="font-family: arial, helvetica, sans-serif;">Here <span class="words" data-synonyms="is a;may be a;could be a" title="">is a</span> list of the <span class="words" data-synonyms="equipment;gear;hardware" title="">hardware</span> we <span class="words" data-synonyms="recommend;suggest;prescribe" title="">suggest</span> for this <span class="words" data-synonyms="tutorial;instructional exercise" title="">tutorial</span> on <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> IFTTT on the Raspberry Pi.</span></p><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2. <a href="https://amzn.to/2NeiiwH" rel="noopener noreferrer" target="_blank">Micro SD Card</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Sandisk-Ultra-Micro-UHS-I-Adapter/dp/B073K14CVB/ref=as_li_ss_il?s=pc&ie=UTF8&qid=1530856971&sr=1-3&keywords=16gb+micro+sd+card+class+10&linkCode=li2&tag=sarful-20&linkId=7bd557de6615c6e30c98ebad7a976622&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B073K14CVB&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B073K14CVB" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3.<a href="https://amzn.to/2Bn579S" rel="noopener noreferrer" target="_blank">Ethernet cable</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Ethernet-Outdoor-Connector-Weatherproof-Resistant/dp/B07QLXC6QR/ref=as_li_ss_il?dchild=1&keywords=ethernet+cable&qid=1592668420&s=electronics&sr=1-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRDUwSThJNE80TVNFJmVuY3J5cHRlZElkPUEwMjE5ODQ5M0FLV1hJT09ZODMzVyZlbmNyeXB0ZWRBZElkPUEwMjQ4NzQ1MU9CV1NZOUkzS09SUCZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=&linkCode=li2&tag=sarful-20&linkId=342c6ec93ab949bd64c1fc92dadd716c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07QLXC6QR&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07QLXC6QR" width="1" /></span></p><div><span style="font-family: arial, helvetica, sans-serif;">4.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></div><div><p><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></p><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><hr /></div><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Creates an account with IFTTT for Raspberry Pi Email sent:</span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">In this <span class="words" data-synonyms="section;area;segment" title="">section</span>, <span class="words" data-synonyms="we will;we'll;we are going to" title="">we'll </span>be showing you how to creates an account with IFTTT: for this project.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="You need;You would like;You wish" title="Click to edit and show the other synonyms">1. You need</span> <span class="words" data-synonyms="to create;to make;to form" title="">to create</span> an account with IFTTT <span class="words" data-synonyms="before;some time recently" title="">before</span> <span class="words" data-synonyms="you can;you'll;you'll be able to" title="">you'll be able</span> to <span class="words" data-synonyms="start;begin" title="">begin</span> <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> it, so visit <a href="https://ifttt.com/" rel="noopener noreferrer" target="_blank">www.ifttt.com</a> and sign up.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone wp-image-716 size-medium" height="75" src="https://www.mechatronicslab.net/my_uploads/2020/06/1-1-wpp1592888640145-e1592909668780-300x75.jpg" width="300" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2. Now you have to need Click to create in red highlight Option</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone wp-image-717 size-medium" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/2-1-wpp1592889118357-e1592909642153-259x300.jpg" width="259" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3. On this page, we <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">got to</span> <span class="words" data-synonyms="start;begin" title="">start</span> by selecting the trigger for our IFTTT <span class="words" data-synonyms="action;activity" title="">activity</span>. so now clicking the “+This” <span class="words" data-synonyms="text;content" title="">content</span>, as <span class="words" data-synonyms="shown;appeared">appeared</span> <span class="words" data-synonyms="in the;within the" title="">within the</span> screenshot <span class="words" data-synonyms="below;underneath" title="">below</span></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone wp-image-718 size-medium" height="137" src="https://www.mechatronicslab.net/my_uploads/2020/06/3-1-wpp1592903585903-e1592909615448-300x137.jpg" width="300" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">4. We are <span class="words" data-synonyms="going to;getting to;progressing to;attending to;reaching to;planning to;aiming to" title="">planning to</span> <span class="words" data-synonyms="show;appear" title="">show</span> you how <span class="words" data-synonyms="to make;to form;to create" title="">to make</span> <span class="words" data-synonyms="use;utilize" title="">utilize</span> the webhook <span class="words" data-synonyms="service;benefit" title="">service. so That Start by searching “webhook” within the search box and. we got to click the “Webhooks” button like the screenshot below</span></span></p><p><span class="words" data-synonyms="service;benefit" style="font-family: arial, helvetica, sans-serif;" title=""><img alt="" class="alignnone wp-image-719 size-medium" height="265" src="https://www.mechatronicslab.net/my_uploads/2020/06/4-1-wpp1592904054680-e1592909591474-300x265.jpg" width="300" />. </span></p><h4><span style="font-family: arial, helvetica, sans-serif;">5. Now time to Click Receive a web request <span class="words" data-synonyms="service;benefit" title="">screenshot below</span></span></h4><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone wp-image-720 size-medium" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/5-wpp1592904265950-e1592909567251-210x300.jpg" width="210" /></span></p><h4><span style="font-family: arial, helvetica, sans-serif;">6. We <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">need to</span> <span class="words" data-synonyms="give;allow;provide;deliver;donate;grant" title="">allow</span> an <span class="words" data-synonyms="event;occasion" title="">event</span> <span class="words" data-synonyms="name;title" title="">title</span> for this trigger. This <span class="words" data-synonyms="name;title">title</span> must not contain any spaces or <span class="words" data-synonyms="symbols;images" title="">images of</span> <span class="words" data-synonyms="besides;other than" title="">other than</span> the <span class="words" data-synonyms="underscore;emphasize" title="">underscore</span> (_) character. For our <span class="words" data-synonyms="example;case;illustration" title="">case</span> <span class="words" data-synonyms="event;occasion" title="">event</span>, we are <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> “Raspberry_Pi_CPU_temperature” as the <span class="words" data-synonyms="event;occasion" title="">event</span> <span class="words" data-synonyms="name;title" title="">title screenshot below</span>.</span></h4><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone wp-image-721 size-medium" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/6-wpp1592904733611-e1592909547503-289x300.jpg" width="289" /></span></p></div><p><span style="font-family: arial, helvetica, sans-serif;">7. Let’s <span class="words" data-synonyms="now;presently" title="">now</span> select the “That” <span class="words" data-synonyms="action;activity" title="">activity</span> for the IFTTT trigger <span class="words" data-synonyms="name;title" title="">screenshot below</span>.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone wp-image-722 size-medium" height="77" src="https://www.mechatronicslab.net/my_uploads/2020/06/7-wpp1592905042984-e1592909526511-300x77.jpg" width="300" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">8. The <span class="words" data-synonyms="next;following;another" title="">following</span> step is <span class="words" data-synonyms="to select;to choose" title="">to choose</span> the <span class="words" data-synonyms="service;benefit" title="">service</span> we <span class="words" data-synonyms="want;need" title="">need</span> to <span class="words" data-synonyms="use;utilize" title="">utilize</span> for our actions. For this <span class="words" data-synonyms="tutorial;instructional exercise" title="">tutorial</span>, <span class="words" data-synonyms="we will;we'll;we are going to" title="">we are going</span> be making <span class="words" data-synonyms="use;utilize" title="">utilize</span> of the “Email” <span class="words" data-synonyms="service;benefit" title="">service</span>. </span></p><div><span style="font-family: arial, helvetica, sans-serif;">This <span class="words" data-synonyms="service;benefit" title="">service</span> sends an Email to the IFTTT app when our <span class="words" data-synonyms="event;occasion" title="">event</span> is triggered. There are <span class="words" data-synonyms="various;different" title="">different</span> other services, but Email is one of the <span class="words" data-synonyms="easiest;most effortless;most straightforward;least demanding" title="">easiest</span> to setup</span></div><div><span style="font-family: arial, helvetica, sans-serif;">. We <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">got to</span> <span class="words" data-synonyms="search;look" title="">look</span> up “Email” <span class="words" data-synonyms="in the;within the" title="">within the</span> <span class="words" data-synonyms="search;look" title="">look</span> box. When the “Email” <span class="words" data-synonyms="service;benefit" title="">service</span> pops up, <span class="words" data-synonyms="click;tap;press" title="">click</span> its <span class="words" data-synonyms="name;title" title="">screenshot below</span>.</span></div><div><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone wp-image-723 size-medium" height="174" src="https://www.mechatronicslab.net/my_uploads/2020/06/8-wpp1592905572535-e1592909499862-300x174.jpg" width="300" /></span></div><div><span style="font-family: arial, helvetica, sans-serif;">9. <span class="words" data-synonyms="Now;Presently" title="">Now</span> we <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">have to be</span> select an <span class="words" data-synonyms="action;activity" title="">action</span> <span class="words" data-synonyms="provided;given" title="">provided</span> by this service. In this case, we <span class="words" data-synonyms="want;need" title="">need</span> to send a <span class="words" data-synonyms="simple;basic;straightforward" title="">basic</span> Email to the IFTTT app <span class="words" data-synonyms="name;title" title="">screenshot below</span>, </span></div><div><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone wp-image-724 size-medium" height="265" src="https://www.mechatronicslab.net/my_uploads/2020/06/9-wpp1592905747172-e1592909470474-300x265.jpg" width="300" /></span></div><div><span style="font-family: arial, helvetica, sans-serif;">10. now click Create an action No need any change now <span class="words" data-synonyms="name;title" title="">screenshot below</span></span></div><div><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone size-medium wp-image-725" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/10-wpp1592908161140-e1592908198266-172x300.jpg" width="172" /></span></div><div><span style="font-family: arial, helvetica, sans-serif;">11. Now, click the “Finish” button <span class="words" data-synonyms="name;title" title="">screenshot below</span></span></div><div><span style="font-family: arial, helvetica, sans-serif;"><img alt="" class="alignnone size-medium wp-image-726" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/11-216x300.jpg" width="216" /></span></div><div><span style="font-family: arial, helvetica, sans-serif;">12. Now-Again Back on the webhooks page, <span class="words" data-synonyms="click;tap;press" title="">click</span> the “Documentation” Option <span class="words" data-synonyms="in the;within the" title="">within the</span> <span class="words" data-synonyms="top;beat;best" title="">best</span> right-hand corner of the screen. Clicking this will take us to the screen were <span class="words" data-synonyms="we can;we will;we are able to;ready to;able to" title="">ready to</span> <span class="words" data-synonyms="find;discover" title="">find</span> the API keys we <span class="words" data-synonyms="need;require" title="">require screenshot below</span>.</span></div><div><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone size-medium wp-image-727" height="154" src="https://www.mechatronicslab.net/my_uploads/2020/06/12-wpp1592908561807-e1592908603903-300x154.jpg" width="300" /></span></div><div><span style="font-family: arial, helvetica, sans-serif;">13.you You can see Your API key On this page, <span class="words" data-synonyms="copy;duplicate" title="">copy</span> down the API key Below <span class="words" data-synonyms="you can;you'll;you'll be able to" title="">you'll be able</span> to see the URL where <span class="words" data-synonyms="we will;we'll;we are going to" title="">we'll </span>send our webhook calls to. This URL is <span class="words" data-synonyms="located;found" title="">located</span> underneath the “To trigger an Event” title.</span></div><div><span style="font-family: arial, helvetica, sans-serif;"><img alt="create an account with IFTTT" class="alignnone size-medium wp-image-728" height="134" src="https://www.mechatronicslab.net/my_uploads/2020/06/13-wpp1592908871347-e1592908948372-300x134.jpg" width="300" /></span></div><div> </div><div><span style="font-family: arial, helvetica, sans-serif;">That’s it—the <span class="words" data-synonyms="recipe;formula" title="">recipe</span> is <span class="words" data-synonyms="now;presently" title="">now</span> live, and once the Raspberry Pi <span class="words" data-synonyms="is ready;is prepared" title="">is prepared</span> to send web requests to it, <span class="words" data-synonyms="it will;it'll" title="">it'll </span><span class="words" data-synonyms="start;begin" title="">start</span> emailing.</span></div><div><hr /></div><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Preparing your Raspberry Pi for this project:</span></h2><hr /><div> </div><div><span style="font-family: arial, helvetica, sans-serif;">In this <span class="words" data-synonyms="section;area;segment" title="">section</span>, <span class="words" data-synonyms="we will;we'll;we are going to" title="">we'll </span>be showing you how to Raspberry Pi for this project. </span><span style="font-family: arial, helvetica, sans-serif;">if you First-time run project you have to need to update your raspberry pi <span class="words" data-synonyms="You can;You'll;You'll be able to">You'll </span>do this by running the following commands.</span></div><div><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">sudo apt update
sudo apt upgrade</span></pre><p><span style="font-family: arial, helvetica, sans-serif;">Now you have to need library install for this project <span class="words" data-synonyms="You can;You'll;You'll be able to">You'll </span>do this by running the following commands. </span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">pip install urllib3</span>
<span style="font-family: arial, helvetica, sans-serif;">Or</span>
<span style="font-family: arial, helvetica, sans-serif;">sudo apt-get install urllib2</span></pre><hr /><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Code Raspberry Pi Email send IFTTT:</span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">The Python program to send the web request</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">import time, os, urllib, urllib2
MAX_TEMP = 37.0
MIN_T_BETWEEN_WARNINGS = 60 # Minutes
EVENT = 'raspberry'
BASE_URL = 'https://maker.ifttt.com/trigger/'
KEY = 'hLTwmMC3A5J9KnUXwoITVfHEJ2d5eVpvcNsqi85OhDA'
def send_notification(temp):
data = urllib.urlencode({'value1' : str(temp)})
url = BASE_URL + EVENT + '/with/key/' + KEY
response = urllib2.urlopen(url=url, data=data)
print(response.read())
def cpu_temp():
dev = os.popen('/opt/vc/bin/vcgencmd measure_temp')
cpu_temp = dev.read()[5:-3]
return float(cpu_temp)
while True:
temp = cpu_temp()
print("CPU Temp (C): " + str(temp))
if temp > MAX_TEMP:
print("CPU TOO HOT!")
send_notification(temp)
print("No more notifications for: " + str(MIN_T_BETWEEN_WARNINGS) +
" mins")
time.sleep(MIN_T_BETWEEN_WARNINGS * 60)
time.sleep(1)
</span></pre><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="Before;Some time recently" title="">Before</span> running the program, <span class="words" data-synonyms="you will;you'll;you may" title="">you'll </span><span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">have to get</span> an <span class="words" data-synonyms="access;get to" title="">get to</span> the key for the Maker Action channel by selecting Channels, <span class="words" data-synonyms="and then;and after that" title="">and after that</span> <span class="words" data-synonyms="searching;looking" title="">searching</span> for Maker. Paste the key into email.py on the line that <span class="words" data-synonyms="starts;begins">begins</span> KEY= and then run the program <span class="words" data-synonyms="using;utilizing" title="">using the screenshot below</span>:</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="terminal" class="alignnone size-medium wp-image-729" height="196" src="https://www.mechatronicslab.net/my_uploads/2020/06/terminal-300x196.jpg" width="300" /></span></p></div><p><span style="font-family: arial, helvetica, sans-serif;"> Notice how the values have been substituted into the email <span class="words" data-synonyms="using;utilizing" title="">screenshot below </span></span></p><p><img alt="create an account with IFTTT" class="alignnone size-medium wp-image-732" height="78" src="https://www.mechatronicslab.net/my_uploads/2020/06/email-1-300x78.jpg" width="300" /></p><h2>If you want to know more about raspberry pi then click on the link below</h2><h4 class="page-title is-large uppercase"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></h4>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-16926867389186132282022-05-20T22:27:00.001+06:002022-05-20T22:27:00.184+06:00How to Measuring Distance Using Ultrasonic Sensors with Raspberry Pi<h1 style="text-align: left;"><span><font face="arial, helvetica, sans-serif">How to Measuring Distance Using Ultrasonic Sensors with Raspberry Pi</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">In This <span class="words" data-synonyms="Project;Extend;Venture" title="">Project</span>, <span class="words" data-synonyms="you will;you'll;you may" title="">you'll </span>learn the <span class="words" data-synonyms="basics;nuts and bolts;essentials" title="">basics of </span>How to Measuring Distance Using Ultrasonic Sensors with Raspberry Pi. <span class="words" data-synonyms="You will;You'll;You may" title="">You'll</span> <span class="words" data-synonyms="understand;get it" title="">get it</span> on how to <span class="words" data-synonyms="use;utilize" title="">utilize</span> the <span class="words" data-synonyms="distance;separate;remove" title="">distance</span> calculation formulas on the Raspberry Pi.</span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;"><strong>≡ What is the ultrasonic sensor :</strong></span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">Ultrasonic sensors <span class="words" data-synonyms="generate;create;produce" title="">produce</span> ultrasound waves that are <span class="words" data-synonyms="targeted;focused on" title="">targeted</span> towards an obstacle after which they <span class="words" data-synonyms="wait;hold up" title="">wait</span> for the <span class="words" data-synonyms="echo;resound;reverberate" title="">echo</span> to be <span class="words" data-synonyms="heard;listened" title="">heard</span>. this sensor works at an ultrasonic <span class="words" data-synonyms="frequency;recurrence" title="">frequency</span>, which is higher than the <span class="words" data-synonyms="audible;capable of being heard" title="">capable of being heard</span> <span class="words" data-synonyms="frequency;recurrence" title="">frequency</span> range of <span class="words" data-synonyms="humans;people" title="">humans. The human's normal hypothetical capable of being heard frequency range is 20 Hz to 20 kHz. The ultrasonic sensor transmits the sound waves higher than 20 kHz frequency. so that why you hear any<br />sound when you use an ultrasonic sensor.</span></span></p><h4><span style="font-family: arial, helvetica, sans-serif;">Ultrasonic waves are <span class="words" data-synonyms="mainly;primarily;basically" title="">primarily</span> <span class="words" data-synonyms="used;utilized" title="">utilized</span> because they are not <span class="words" data-synonyms="audible;capable of being heard" title="">capable of being heard</span> to the human ear <span class="words" data-synonyms="and also;additionally;conjointly" title="">and also</span> <span class="words" data-synonyms="because;since" title="">because</span> they <span class="words" data-synonyms="provide;give">give</span> precise distance <span class="words" data-synonyms="measurement;estimation" title="">measurements</span> over <span class="words" data-synonyms="short;brief" title="">short</span> <span class="words" data-synonyms="distances;separations" title="">distances</span>. <span class="words" data-synonyms="You can;You'll;You'll be able to" title="">You'll </span><span class="words" data-synonyms="definitely;unquestionably;certainly" title="">certainly</span> <span class="words" data-synonyms="use;utilize" title="">utilize</span> acoustic sound for this <span class="words" data-synonyms="purpose;reason" title="">reason</span>, but it's not <span class="words" data-synonyms="nice;pleasant;decent" title="Click to edit and show the other synonyms">pleasant</span> to have a <span class="words" data-synonyms="noisy;boisterous;loud" title="">noisy</span> robot <span class="words" data-synonyms="shouting;yelling" title="">shouting</span> <span class="words" data-synonyms="every;each" title="">every</span> few seconds. </span></h4><p><span style="font-family: arial, helvetica, sans-serif;"> ultrasonic sensors <span class="words" data-synonyms="produce;create;deliver" title="">create</span> sonic bursts and calculate the <span class="words" data-synonyms="echo;resound;reverberate" title="">echo</span>. This echo is <span class="words" data-synonyms="received;gotten" title="">gotten</span> back by the same sensor, calculating the time <span class="words" data-synonyms="interval;interim" title="">interval</span> between the transition of the <span class="words" data-synonyms="signal;flag" title="">signal</span> and <span class="words" data-synonyms="reception;gathering" title="">reception</span> of the <span class="words" data-synonyms="echo;resound;reverberate" title="">echo</span> to <span class="words" data-synonyms="decide;choose" title="">choose</span> the <span class="words" data-synonyms="distance;separate;remove" title="">distance</span> to a target. The concept behind this sensor is almost the same concept used in Radar.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="n HC-SR04 ultrasonic range finder" class="alignnone size-medium wp-image-697" height="249" src="https://www.mechatronicslab.net/my_uploads/2020/06/ultras_pinout-300x249.jpg" width="300" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="This is;This is often;Typically;Usually;This can be" title="">Usually, </span>the representation of the HC-SR04 sensor, <span class="words" data-synonyms="which will;which can;which is able to" title="">which can</span> be <span class="words" data-synonyms="used;utilized" title="">utilized</span> for this <span class="words" data-synonyms="project;extend;venture" title="">project The sensor appeared here has one transmitter and one <span class="words" data-synonyms="receiver;collector;recipient" title="Click to edit and show the other synonyms">receiver</span>. For more accuracy, there can be different transmitters and receivers. In any case, this sensor can provide accuracy close ±3 cm within the run of 400 cm.</span></span></p><p><span class="words" data-synonyms="project;extend;venture" style="font-family: arial, helvetica, sans-serif;" title=""> For example, on the off chance that the measured distance is 270 cm, the real separate can be 273 cm or 267 cm. Under the cylinders, the sensor has a control circuit that takes care of everything, counting the communication with RasPi. </span></p><p><span class="words" data-synonyms="project;extend;venture" style="font-family: arial, helvetica, sans-serif;" title="">There are four pins that come out of the sensor: ground, echo, trigger, and supply. The ground and 5 V supply can be connected to Raspberry pi pins directly. When we provide input from Raspberry pi to the trigger pin of the sensor, the transmitter radiates the sound pulses. These sound pulses bounce back from the solid object or surface, and we get the pulse from the echo pin. At that point, we calculate the time of arrival of the echo, and ready to calculate the distance. </span></p><p><span style="font-family: arial, helvetica, sans-serif;">More About hc-sr04 sensor<a href="https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf" rel="noopener noreferrer" target="_blank"> datasheet </a></span></p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;"><strong>≡ How to calculation Distance on the ultrasonic sensor :</strong></span></h3><hr /><p><span style="font-family: arial, helvetica, sans-serif;">The speed of sound depends on which medium the sound wave is <span class="words" data-synonyms="travelling;voyaging" title="">traveling</span> in and the <span class="words" data-synonyms="ambient;surrounding;encompassing" title="">surrounding</span> temperature as well as elevation from <span class="words" data-synonyms="sea;ocean" title="">sea</span> level. physicists have calculated the speed of sound at the <span class="words" data-synonyms="sea;ocean" title="">sea</span> level and have found it to be 34,300 cm/s. <span class="words" data-synonyms="If;On the off chance that;In the event that;In case" title="">In case</span> you <span class="words" data-synonyms="measure;degree" title="">measure</span> the distance underwater <span class="words" data-synonyms="then;at that point" title="">at that point</span> the speed of sound is 1,48,200 cm/s. See, it changed drastically when the medium changed. </span></p><p><span style="font-family: arial, helvetica, sans-serif;">This <span class="words" data-synonyms="again;once more" title="">once more</span> depends on the water's temperature and so <span class="words" data-synonyms="many;numerous" title="">many</span> other <span class="words" data-synonyms="entities;substances" title="">entities</span>. <span class="words" data-synonyms="While;Whereas" title="">While</span> making a <span class="words" data-synonyms="project;extend;venture" title="">project</span>, make <span class="words" data-synonyms="sure;beyond any doubt" title="">beyond any doubt</span> that you use <span class="words" data-synonyms="the correct;the right;the proper" title="">the proper</span> speed of sound. Here, we are <span class="words" data-synonyms="using;utilizing">utilizing</span> <span class="words" data-synonyms="air;discuss" title="">discussion</span> as the medium.</span></p><h4><span style="font-family: arial, helvetica, sans-serif;">We know that, Speed = <math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mrow><mi>D</mi><mi>i</mi><mi>s</mi><mi>tan</mi><mi>c</mi><mi>e</mi></mrow><mrow><mi>T</mi><mi>i</mi><mi>m</mi><mi>e</mi></mrow></mfrac></math></span></h4><p> </p><p> </p><p> </p><p> </p><p><span style="font-family: arial, helvetica, sans-serif;">When we <span class="words" data-synonyms="measure;degree" title="">measure</span> the time, it is measured based on the time taken in going towards the target and returning to the source of the sound waves. <span class="words" data-synonyms="However;In any case;Be that as it may" title="">In any case</span>, we <span class="words" data-synonyms="want;need" title="">need</span> to calculate the time just for the one-way <span class="words" data-synonyms="journey;travel" title="">journey</span> in <span class="words" data-synonyms="order;arrange" title="">order</span> to <span class="words" data-synonyms="measure;degree" title="">measure</span> the <span class="words" data-synonyms="distance;separate;remove" title="">distance</span>. For <span class="words" data-synonyms="example;case;illustration" title="">case</span>, we are measuring the <span class="words" data-synonyms="distance;separate;remove" title="">distance</span> from point A to B. The sensor will <span class="words" data-synonyms="generate;create;produce" title="">create</span> the sound from point A.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"> Let's <span class="words" data-synonyms="suppose;assume" title="">assume</span> that this sound <span class="words" data-synonyms="reaches;comes to" title="">comes to</span> point B in time T1. At point B, the sound is reflected and <span class="words" data-synonyms="reaches;comes to" title="">comes to</span> back to the sensor at point A in time T2. So, the actual time we <span class="words" data-synonyms="measure;degree" title="">measure</span> at the ultrasonic sensor is T = T1 + T2. <span class="words" data-synonyms="That is;That's" title="">That's </span>why we <span class="words" data-synonyms="need;require" title="">require</span> to divide the measured time by the <span class="words" data-synonyms="factor;calculate;figure">calculate</span> of 2.</span></p><p><span style="font-family: arial, helvetica, sans-serif;">So now, our equation is as follows:</span></p><h4><span style="font-family: arial, helvetica, sans-serif;">Distance = <math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mrow><mi>S</mi><mi>p</mi><mi>e</mi><mi>e</mi><mi>d</mi><mo> </mo><mi>T</mi><mi>i</mi><mi>m</mi><mi>e</mi></mrow><mrow><mi>T</mi><mi>i</mi><mi>m</mi><mi>e</mi><mo>/</mo><mn>2</mn></mrow></mfrac></math></span></h4><p> </p><p> </p><p> </p><p> </p><p><span style="font-family: arial, helvetica, sans-serif;">We know that the speed of sound is 34,300 cm/s:</span></p><p><span style="font-family: arial, helvetica, sans-serif;">34300 = </span></p><p><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mrow><mn>2</mn><mo>*</mo><mi>D</mi><mi>i</mi><mi>s</mi><mi>tan</mi><mi>c</mi><mi>e</mi></mrow><mrow><mi>T</mi><mi>i</mi><mi>m</mi><mi>e</mi></mrow></mfrac></math></p><p> </p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;">≡ Components Required :</span></h3><hr /><div><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2. <a href="https://amzn.to/2NeiiwH" rel="noopener noreferrer" target="_blank">Micro SD Card</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Sandisk-Ultra-Micro-UHS-I-Adapter/dp/B073K14CVB/ref=as_li_ss_il?s=pc&ie=UTF8&qid=1530856971&sr=1-3&keywords=16gb+micro+sd+card+class+10&linkCode=li2&tag=sarful-20&linkId=7bd557de6615c6e30c98ebad7a976622&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B073K14CVB&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B073K14CVB" style="border: none; margin: 0px;" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3.<a href="https://amzn.to/2Bn579S" rel="noopener noreferrer" target="_blank">Ethernet cable</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Ethernet-Outdoor-Connector-Weatherproof-Resistant/dp/B07QLXC6QR/ref=as_li_ss_il?dchild=1&keywords=ethernet+cable&qid=1592668420&s=electronics&sr=1-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRDUwSThJNE80TVNFJmVuY3J5cHRlZElkPUEwMjE5ODQ5M0FLV1hJT09ZODMzVyZlbmNyeXB0ZWRBZElkPUEwMjQ4NzQ1MU9CV1NZOUkzS09SUCZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=&linkCode=li2&tag=sarful-20&linkId=342c6ec93ab949bd64c1fc92dadd716c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07QLXC6QR&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07QLXC6QR" style="border: none; margin: 0px;" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">4.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">5. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><div><span style="font-family: arial, helvetica, sans-serif;">6.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></span></div><p><span style="font-family: arial, helvetica, sans-serif;">7. <a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07CPX487B" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01ISMVA1E" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">8. HC-SR04 ultrasonic range finder</span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/SainSmart-HC-SR04-Ranging-Detector-Distance/dp/B004U8TOE6/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=6e5e554697c629006880abc74ca74558&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B004U8TOE6&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B004U8TOE6" style="border: none; margin: 0px;" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></p><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;">≡ Circuit diagram Ultrasonic Sensors Raspberry Pi:</span></h3><hr /><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="We will;We'll;We are going to">We'll </span>perform the <span class="words" data-synonyms="following;taking after" title="">taking after</span> steps:</span></p><div><span style="font-family: arial, helvetica, sans-serif;">1. Take the breadboard.</span></div><div><span style="font-family: arial, helvetica, sans-serif;">2. Connect the sensor on the breadboard. <span class="words" data-synonyms="Keep in mind;Be sure" title="">Be beyond any doubt that</span> <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in case</span> you <span class="words" data-synonyms="connect;interface" title="">connect</span> it flipped, the <span class="words" data-synonyms="connections;associations" title="">associations</span> <span class="words" data-synonyms="suggested;proposed;recommended" title="">recommended</span> here would not work. Cross-check the connections, and make <span class="words" data-synonyms="sure;beyond any doubt" title="">sure</span> to <span class="words" data-synonyms="that you;that you simply;merely;that you just;simply" title="">simply </span>make a <span class="words" data-synonyms="correct;adjust;rectify;redress" title="">adjust</span> circuit.</span></div><div> </div><div><span style="font-family: arial, helvetica, sans-serif;">3. <span class="words" data-synonyms="Connect;Interface" title="">Interface</span> <span class="words" data-synonyms="pin;stick" title="">pin</span> 6 of Raspberry Pi to the ground rail of the breadboard.</span></div><div> </div><div><span style="font-family: arial, helvetica, sans-serif;"> 4. <span class="words" data-synonyms="Connect;Interface" title="">Interface</span> Raspberry pi <span class="words" data-synonyms="pin;stick" title="">pin</span> 2 to the sensor's 5V pin.</span></div><div> </div><div><span style="font-family: arial, helvetica, sans-serif;"> 5. The trigger <span class="words" data-synonyms="pin;stick" title="">pin</span> can be <span class="words" data-synonyms="connected;associated" title="">connected</span> <span class="words" data-synonyms="directly;specifically;straightforwardly" title="">directly</span> with the sensor. In <span class="words" data-synonyms="fact;reality;truth" title="">reality</span>, the Raspberry Pi sends a 3.3V <span class="words" data-synonyms="signal;flag" title="">signal</span> to this trigger <span class="words" data-synonyms="pin;stick" title="">pin</span>, which is <span class="words" data-synonyms="acceptable;worthy;satisfactory" title="">satisfactory</span> by the sensor.</span></div><div> </div><div><span style="font-family: arial, helvetica, sans-serif;"> 6. Take out an <span class="words" data-synonyms="connection;association" title="">association</span> from Raspberry pi <span class="words" data-synonyms="pin;stick" title="">pin</span> 18 to the breadboard, and connect it to the terminal rails of the breadboard. From the same <span class="words" data-synonyms="row;push" title="">row</span>, <span class="words" data-synonyms="you can;you'll;you'll be able to" title="">you'll be able</span> to <span class="words" data-synonyms="connect;interface" title="">interface</span> one terminal of 2KΩ resistor. The <span class="words" data-synonyms="second;moment" title="">second</span> terminal goes to the same ground strip where Raspberry Pi ground and sensor's ground are <span class="words" data-synonyms="connected;associated" title="">associated</span>, as <span class="words" data-synonyms="shown;appeared" title="">appeared</span> in the following <span class="words" data-synonyms="image;picture" title="">picture.</span></span></div><div> </div><div><span style="font-family: arial, helvetica, sans-serif;"><img alt="Measuring Distance Using Ultrasonic Sensors" class="alignnone size-medium wp-image-702" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-mcp3008-with-Ultrasonics_bb-1-218x300.png" width="218" /> <img alt="Measuring Distance Using Ultrasonic Sensors" class="alignnone size-medium wp-image-704" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-mcp3008-with-Ultrasonics_schem-1-268x300.png" width="268" /></span></div><div><span style="font-family: arial, helvetica, sans-serif;">Measuring Distance Using Ultrasonic Sensors</span></div></div><div> </div><div><span style="font-family: arial, helvetica, sans-serif;">The <span class="words" data-synonyms="connections;associations" title="">connections</span> we have done are <span class="words" data-synonyms="good;great" title="">great</span> to go. Cross-check the connection twice <span class="words" data-synonyms="before;some time recently" title="">before</span> you <span class="words" data-synonyms="power;control" title="">control</span> up the Raspberry pi . We have done the <span class="words" data-synonyms="procedure;method;strategy" title="">method</span> on the hardware. We <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">have to compose</span> the <span class="words" data-synonyms="software;computer program;program" title="">program</span> (code) to tell the RAspberry pi that we have <span class="words" data-synonyms="connected;associated" title="">connected</span> this sensor to these pins and to calculate the <span class="words" data-synonyms="distance;separate;remove">separate</span> based on the <span class="words" data-synonyms="formulas;equations" title="">equations</span> we <span class="words" data-synonyms="derived;inferred;determined" title="">determined.</span></span></div><div><hr /></div><h2><span style="font-family: arial, helvetica, sans-serif;"><strong>≡ Code Ultrasonic Sensors Raspberry Pi:</strong></span></h2><div><hr /></div><div><span style="font-family: arial, helvetica, sans-serif;">it's time to write the code that measures the distance as well as notifies</span></div><div><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">#Libraries
import RPi.GPIO as GPIO
import time
#GPIO Mode (BOARD / BCM)
GPIO.setmode(GPIO.BCM)
#set GPIO Pins
GPIO_TRIGGER = 23
GPIO_ECHO = 24
#set GPIO direction (IN / OUT)
GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
GPIO.setup(GPIO_ECHO, GPIO.IN)
print("\nBeginning Measurements...\n")
def distance():
# set Trigger to HIGH
GPIO.output(GPIO_TRIGGER, True)
# set Trigger after 0.01ms to LOW
time.sleep(0.00001)
GPIO.output(GPIO_TRIGGER, False)
StartTime = time.time()
StopTime = time.time()
# save StartTime
while GPIO.input(GPIO_ECHO) == 0:
StartTime = time.time()
# save time of arrival
while GPIO.input(GPIO_ECHO) == 1:
StopTime = time.time()
# time difference between start and arrival
TimeElapsed = StopTime - StartTime
# multiply with the sonic speed (34300 cm/s)
# and divide by 2, because there and back
distance = (TimeElapsed * 34300) / 2
return distance
if __name__ == '__main__':
try:
while True:
dist = distance()
print ("Measured Distance = %.1f cm" % dist)
time.sleep(0.5)
# Reset by pressing CTRL + C
except KeyboardInterrupt:
print("Measurement stopped by User")
GPIO.cleanup()
</span></pre><p><span style="font-family: arial, helvetica, sans-serif;">when you run code you can see like this Measured Distance = 9.1321cm</span></p><p><span style="font-family: arial, helvetica, sans-serif;">Compared to the steps to set up the <span class="words" data-synonyms="software;computer program;program" title="">program</span>, there are <span class="words" data-synonyms="some;a few" title="">a few</span> minor changes in the compiled code. <span class="words" data-synonyms="You will;You'll;You may" title="">You may</span> <span class="words" data-synonyms="find;discover" title="">find</span> that we <span class="words" data-synonyms="used;utilized" title="">utilized</span> GPIO.setwarnings(False). This command turns off the <span class="words" data-synonyms="warnings;notices" title="">warnings</span> <span class="words" data-synonyms="generated;created;produced" title="">created</span> <span class="words" data-synonyms="while;whereas" title="">whereas</span> compiling the code. When the program is <span class="words" data-synonyms="started;begun" title="">begun</span> and the GPIOs are <span class="words" data-synonyms="configured;arranged;designed" title="">arranged</span>, <span class="words" data-synonyms="give;allow;provide;deliver;donate;grant" title="">deliver</span> the Raspberry pi module some time to get <span class="words" data-synonyms="ready;prepared" title="">ready</span> <span class="words" data-synonyms="to take;to require" title="">to require</span> the readings.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"> <span class="words" data-synonyms="There is;There's" title="">There's </span>a <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">have to utilize</span> the <span class="words" data-synonyms="while;whereas" title="">while</span>() <span class="words" data-synonyms="loop;circle" title="">loop</span>. Using this forever-running <span class="words" data-synonyms="loop;circle" title="">circle</span>, <span class="words" data-synonyms="we can;we will;we are able to;ready to;able to" title="">we will</span> see the live <span class="words" data-synonyms="distance;separate;remove" title="">remove</span> <span class="words" data-synonyms="variation;variety" title="">variation</span> by <span class="words" data-synonyms="pointing;indicating" title="">indicating</span> the sensor towards <span class="words" data-synonyms="different;diverse;distinctive" title="">different</span> targets. <span class="words" data-synonyms="Before;Some time recently" title="">Sometime recently</span> we <span class="words" data-synonyms="start;begin" title="">start</span> to compile the <span class="words" data-synonyms="project;extend;venture" title="">extend</span>, check the connections <span class="words" data-synonyms="again;once more" title="">once more</span>. <span class="words" data-synonyms="Just;Fair" title="">Just</span> <span class="words" data-synonyms="ensure;guarantee" title="">ensure</span> that the ultrasonic sensor is <span class="words" data-synonyms="positioned;situated" title="">positioned</span> well and pointed towards the target. <span class="words" data-synonyms="Alternatively;Then again;On the other hand" title="">Then again</span>, <span class="words" data-synonyms="just;fair" title="">just</span> put the sensor <span class="words" data-synonyms="perpendicular;opposite" title="">perpendicular</span> to the table so that the <span class="words" data-synonyms="cylinders;barrels">barrels</span> <span class="words" data-synonyms="remain;stay" title="">stay</span> parallel to the table surface.</span></p><p><span style="font-family: arial, helvetica, sans-serif;">If you want to know more about raspberry pi then click on the link below</span></p><h4 class="page-title is-large uppercase"><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></span></h4></div><div> </div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-18238172756436255742022-05-13T12:29:00.001+06:002022-05-13T12:29:00.145+06:00How to Measuring Acceleration with an MCP3008 Module in Raspberry Pi<h1 style="text-align: left;"><span><font face="arial, helvetica, sans-serif">How to Measuring Acceleration with an MCP3008 Module in Raspberry Pi</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">You want to connect an Acceleration with MCP3008 in Raspberry Pi. Today I show you how to Measuring Acceleration with an MCP3008 Module step by step complete process. we are using Accelerometer ADXL335 for this project.</span></p><hr /><h2><strong><span style="font-family: arial, helvetica, sans-serif;">≡ What is Accelerometer</span></strong></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">By measuring the <span class="words" data-synonyms="amount;sum" title="">sum</span> of <span class="words" data-synonyms="acceleration;increasing speed;speeding up" title="">acceleration</span> due to gravity, an accelerometer can figure out the <span class="words" data-synonyms="angle;point" title="">point</span> it is tilted at with <span class="words" data-synonyms="respect;regard" title="">regard</span> to the <span class="words" data-synonyms="earth;soil" title="">earth</span>. By detecting the <span class="words" data-synonyms="amount;sum" title="">sum</span> of <span class="words" data-synonyms="dynamic;energetic" title="">energetic</span> <span class="words" data-synonyms="acceleration;increasing speed;speeding up" title="">acceleration</span>, the accelerometer can <span class="words" data-synonyms="find;discover" title="">discover</span> out how <span class="words" data-synonyms="fast;quick" title="">quick</span> and in what <span class="words" data-synonyms="direction;course;heading" title="">course</span> the <span class="words" data-synonyms="device;gadget">gadget</span> is moving.</span></p><p><strong><span style="font-family: arial, helvetica, sans-serif;">In Accelerometer ADXL335 :</span></strong></p><p><span style="font-family: arial, helvetica, sans-serif;">The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. The product measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration. The user selects the bandwidth of the accelerometer using the CX, CY, and CZ capacitors at the XOUT, YOUT, and ZOUT pins. Bandwidths can be selected to suit the application, with a range of 0.5 Hz to 1600 Hz for the X and Y axes, and a range of 0.5 Hz to 550 Hz for the Z-axis.</span></p><p><span style="font-family: arial, helvetica, sans-serif;">Source and More about see <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL335.pdf" rel="noopener noreferrer" target="_blank">Datasheet Accelerometer ADXL335</a></span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Why we need MCP3008:</span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">The Raspberry Pi computer does not have a way to <span class="words" data-synonyms="read;perused;examined;studied" title="">read</span> analog inputs. It’s a digital-only computer. Compare this to the Arduino, AVR or PIC microcontrollers that <span class="words" data-synonyms="often;regularly;frequently" title="">regularly</span> have 6 or more analog inputs! Analog inputs are <span class="words" data-synonyms="handy;convenient;helpful" title="">handy</span> <span class="words" data-synonyms="because;since" title="">because</span> <span class="words" data-synonyms="many;numerous" title="">many</span> sensors are analog <span class="words" data-synonyms="outputs;yields" title="">outputs</span>, so we <span class="words" data-synonyms="need;require" title="">require</span> a way <span class="words" data-synonyms="to make;to form;to create" title="">to form</span> the Pi analog-friendly.</span></p><p><span style="font-family: arial, helvetica, sans-serif;">We’ll do that by wiring up an MCP3008 chip to it. The MCP3008 acts like a “bridge” between <span class="words" data-synonyms="digital;computerized;advanced" title="">digital</span> and analog. It has 8 analog inputs and the Pi can <span class="words" data-synonyms="query;inquiry" title="">query</span> it <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> 4 <span class="words" data-synonyms="digital;computerized;advanced" title="">digital</span> pins. <span class="words" data-synonyms="That makes;That creates;That produces" title="">That produces</span> it a <span class="words" data-synonyms="perfect;culminate;idealize" title="">perfect</span> <span class="words" data-synonyms="addition;expansion" title="">addition</span> to the Pi for <span class="words" data-synonyms="integrating;joining;coordination" title="">joining</span> <span class="words" data-synonyms="simple;basic;straightforward" title="">basic</span> sensors like photocells, FSRs or potentiometers, thermistors, etc.!<a href="http://www.adafruit.com/datasheets/MCP3008.pdf" rel="noopener noreferrer" target="_blank"> Let’s check the datasheet of the MCP3008 chip</a>.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="MCP3008" class="alignnone wp-image-663 size-medium" height="225" sizes="(max-width: 300px) 100vw, 300px" src="https://www.mechatronicslab.net/my_uploads/2020/06/ezgif.com-gif-maker-300x225.jpg" srcset="https://www.mechatronicslab.net/my_uploads/2020/06/ezgif.com-gif-maker-300x225.jpg 300w, https://www.mechatronicslab.net/my_uploads/2020/06/ezgif.com-gif-maker.jpg 564w" width="300" /></span></p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;"> ≡ Components Required :</span></h3><hr /><div><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><div><span style="font-family: arial, helvetica, sans-serif;">5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></span></div><p><span style="font-family: arial, helvetica, sans-serif;">6. <a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07CPX487B" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01ISMVA1E" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">7.<a href="https://amzn.to/2YiYa2F" rel="noopener noreferrer" target="_blank">MCP3008</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Adafruit-MCP3008-8-Channel-Interface-Raspberry/dp/B00NAY3RB2/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=f307473ab64c76461ea354b61c60fa1c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00NAY3RB2&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B00NAY3RB2" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">8.<a href="https://amzn.to/2ATb8Lu" rel="noopener noreferrer" target="_blank"> Accelerometer ADXL335</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Adafruit-ADXL335-5V-Triple-axis-Accelerometer-Analog/dp/B00NAY2TUC/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=c4398e8b58b1dcb0b00f2f1df1c12757&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00NAY2TUC&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B00NAY2TUC" style="border: none; margin: 0px;" width="1" /></span><br /><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></p><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;">≡ Circuit diagram Acceleration MCP3008 Raspberry Pi:</span></h3><hr /><p><span style="font-family: arial, helvetica, sans-serif;">shows the arrangement for this, using a breadboard. It uses three channels of the ADC to measure the X, Y, and Z acceleration forces</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="Using a triple-axis accelerometer" class="alignnone size-medium wp-image-690" height="243" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-mcp3008-with-Accolometer_schem-300x243.png" width="300" /> <img alt="Using a triple-axis accelerometer" class="alignnone size-medium wp-image-689" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-mcp3008-with-Accolometer_bb-218x300.png" width="218" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">You will need to set up SPI on your Raspberry Pi, so if you have not already done so, follow <a href="https://www.mechatronicslab.net/setting-up-spi-on-your-raspberry-pi/" rel="noopener noreferrer" target="_blank">Setting Up SPI on your Raspberry pi</a></span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Code Acceleration MCP3008 Raspberry Pi:</span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">Open an editor (nano or IDLE) and paste in the following code.</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">import spidev, time
spi = spidev.SpiDev()
spi.open(0,0)
def analog_read(channel):
r = spi.xfer2([1, (8 + channel) << 4, 0])
adc_out = ((r[1]&3) << 8) + r[2]
return adc_out
while True:
x = analog_read(0)
y = analog_read(1)
z = analog_read(2)
print("X=%d\tY=%d\tZ=%d" % (x, y, z))
time.sleep(1)</span></pre><p><span style="font-family: arial, helvetica, sans-serif;">The program simply reads the three forces and prints them out:</span><br /><span style="font-family: arial, helvetica, sans-serif;">X=508 Y=503 Z=626</span></p><p><span style="font-family: arial, helvetica, sans-serif;">If you want to know more about raspberry pi then click on the link below</span></p><h4 class="page-title is-large uppercase"><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></span></h4></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-89437223833402156422022-05-06T10:11:00.001+06:002022-05-06T10:11:00.145+06:00Measuring Temperature with an ADC in Raspberry pi<h1 style="text-align: left;">Measuring Temperature with an ADC in Raspberry pi</h1><p>You <span class="words" data-synonyms="want;need" title="Click to edit and show the other synonyms">need</span> to <span class="words" data-synonyms="measure;degree" title="">measure</span> temperature <span class="words" data-synonyms="using a;employing a" title="">using a</span> TMP36 - Temperature Sensor and an analog-to-digital converter. Today I show you how to Measuring Temperature with an ADC in Raspberry pi Use an MCP3008 ADC chip. unless <span class="words" data-synonyms="you need;you would like;you wish" title="">you would like</span> more than one analog channel, you should consider <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> the DS18B20 <span class="words" data-synonyms="digital;computerized;advanced" title="">digital</span> temperature sensor, which is more accurate and doesn’t require a separate ADC chip.</p><hr /><h2>≡ What is TMP36 - Temperature Sensor</h2><hr /><p>These sensors <span class="words" data-synonyms="use;utilize" title="">utilize</span> a solid-state <span class="words" data-synonyms="technique;procedure;strategy;method" title="">strategy</span> to <span class="words" data-synonyms="determine;decide" title="">decide</span> the temperature. <span class="words" data-synonyms="That is;That's" title="">That's </span>to say, they <span class="words" data-synonyms="don't;do not" title="">do not</span> <span class="words" data-synonyms="use;utilize" title="">utilize</span> mercury, bimetallic strips, nor do they <span class="words" data-synonyms="use;utilize" title="">utilize</span> thermistors. <span class="words" data-synonyms="Instead;Instep" title="">Instead</span>, they <span class="words" data-synonyms="use;utilize" title="">utilize</span> the <span class="words" data-synonyms="fact;reality;truth" title="">truth</span> as temperature <span class="words" data-synonyms="increases;increments" title="">increases</span>, the voltage <span class="words" data-synonyms="across;over" title="">over</span> a diode <span class="words" data-synonyms="increases;increments" title="">increases</span> at a known rate. By <span class="words" data-synonyms="precisely;accurately;absolutely" title="">accurately</span> <span class="words" data-synonyms="amplifying;increasing;opening up;intensifying" title="">increasing</span> the voltage change, it is <span class="words" data-synonyms="easy;simple" title="">simple</span> to <span class="words" data-synonyms="generate;create;produce" title="">create</span> an analog <span class="words" data-synonyms="signal;flag" title="">signal</span> <span class="words" data-synonyms="that is;that's" title="">that's </span><span class="words" data-synonyms="directly;specifically;straightforwardly" title="">directly</span> proportional to temperature. There have been <span class="words" data-synonyms="some;a few" title="">a few</span> <span class="words" data-synonyms="improvements;changes;enhancements;advancements" title="">improvements</span> on the <span class="words" data-synonyms="technique;procedure;strategy;method" title="">strategy</span> but, <span class="words" data-synonyms="essentially;basically" title="">basically,</span> <span class="words" data-synonyms="that is;that's" title="">that's </span>how temperature is measured. The <span class="words" data-synonyms="good;great" title="">great</span> news is all that complex calculation is done <span class="words" data-synonyms="inside;interior" title="">inside</span> the chip - it <span class="words" data-synonyms="just;fair" title="">fair</span> spits out the temperature, <span class="words" data-synonyms="ready;prepared" title="">ready</span> for you to <span class="words" data-synonyms="use;utilize" title="">utilize</span>!</p><p><img alt="temperature_tmp36pinout" class="alignnone size-medium wp-image-683" height="283" src="https://www.mechatronicslab.net/my_uploads/2020/06/temperature_tmp36pinout-300x283.jpg" width="300" /></p><p><span class="words" data-synonyms="Because;Since" title="Click to edit and show the other synonyms">Since</span> these sensors have no moving parts, they are <span class="words" data-synonyms="precise;exact" title="">exact</span>, never wear out, <span class="words" data-synonyms="don't;do not" title="">do not</span> <span class="words" data-synonyms="need;require" title="">require</span> calibration, work <span class="words" data-synonyms="under;beneath" title="">under</span> <span class="words" data-synonyms="many;numerous" title="">many</span> <span class="words" data-synonyms="environmental;natural" title="">natural</span> conditions, and are consistent between sensors and readings. <span class="words" data-synonyms="Moreover;In addition;Additionally;Besides" title="">In addition,</span> they are <span class="words" data-synonyms="very;exceptionally" title="">exceptionally</span> <span class="words" data-synonyms="inexpensive;reasonable;cheap" title="">cheap</span> and <span class="words" data-synonyms="quite;very" title="">very</span> <span class="words" data-synonyms="easy;simple" title="">simple</span> to <span class="words" data-synonyms="use;utilize" title="">utilize</span>.</p><p>More about this <a href="https://learn.adafruit.com/tmp36-temperature-sensor">https://learn.adafruit.com/tmp36-temperature-sensor</a></p><hr /><h2>≡ Components Required</h2><hr /><p>For this project, we <span class="words" data-synonyms="recommend;suggest;prescribe" title="">suggest</span> <span class="words" data-synonyms="that you;that you simply;merely;that you just;simply" title="">that you simply</span> have the <span class="words" data-synonyms="following;taking after" title="">following</span> parts.</p><p>1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a><br /><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></p><p>2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a><br /><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></p><p>3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a><br /><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></p><div>5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a><br /><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></div><p>6. <a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a><br /><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07CPX487B" width="1" /></p><p><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01ISMVA1E" width="1" /></p><p>7.<a href="https://amzn.to/2YiYa2F" rel="noopener noreferrer" target="_blank">MCP3008</a><br /><a href="https://www.amazon.com/Adafruit-MCP3008-8-Channel-Interface-Raspberry/dp/B00NAY3RB2/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=f307473ab64c76461ea354b61c60fa1c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00NAY3RB2&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B00NAY3RB2" width="1" /></p><p>8.<a href="https://amzn.to/2Nic0fq" rel="noopener noreferrer" target="_blank">TMP36 - Temperature Sensor</a><br /><a href="https://www.amazon.com/SparkFun-TMP36-Temperature-Sensor/dp/B007R9UM78/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=5d318374036f3229c72b5c1706d7b444&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B007R9UM78&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B007R9UM78" style="border: none; margin: 0px;" width="1" /><br />This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</p><h3><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></h3><p><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></p><hr /><h3>≡ Circuit diagram Temperature ADC Raspberry pi:</h3><hr /><p><span class="words" data-synonyms="shows;appears" title="">Shows</span> the <span class="words" data-synonyms="arrangement;course of action" title="">arrangement</span> of components on the breadboard , You will need to set up SPI on your Raspberry Pi, so if you haven’t already<br />done so, follow <a href="https://www.mechatronicslab.net/setting-up-spi-on-your-raspberry-pi/" rel="noopener noreferrer" target="_blank">Setting Up SPI on your Raspberry pi</a></p><p><img alt="Using a TMP36 with an ADC" class="alignnone size-medium wp-image-684" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-mcp3008-with-lm36_bb-218x300.png" width="218" /> <img alt="Using a TMP36 with an ADC" class="alignnone size-medium wp-image-685" height="237" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-mcp3008-with-lm36_schem-300x237.png" width="300" /></p><div>VDD (<span class="words" data-synonyms="power;control" title="">power</span>) and DGND (<span class="words" data-synonyms="digital;computerized;advanced" title="">digital</span> ground) to <span class="words" data-synonyms="power;control" title="">power</span> the MCP3008 chip. We <span class="words" data-synonyms="also;too;moreover" title="">moreover</span> <span class="words" data-synonyms="need;require" title="">require</span> four “SPI” <span class="words" data-synonyms="data;information" title="">data</span> pins: DOUT (<span class="words" data-synonyms="Data;Information" title="">Data</span> Out from MCP3008), CLK (Clock <span class="words" data-synonyms="pin;stick" title="">stick</span>), <span class="words" data-synonyms="Din;Clamor;Commotion;Noise" title="">Din</span> (<span class="words" data-synonyms="Data;Information" title="">Information</span> In from Raspberry Pi), and /CS (Chip Select). <span class="words" data-synonyms="Finally;At last;At long last" title="">At long last</span> of course, a source of analog <span class="words" data-synonyms="data;information" title="">data</span>. We’ll be <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> <span class="words" data-synonyms="the basic;the essential;the fundamental" title="Click to edit and show the other synonyms">the fundamental</span> 10k trim pot.</div><div> </div><div>The MCP3008 <span class="words" data-synonyms="has a;features a;includes a;contains a;encompasses a;incorporates a" title="">has a</span> few more pins we <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">got to</span> <span class="words" data-synonyms="connect;interface" title="">interface</span>: AGND (analog ground, <span class="words" data-synonyms="used;utilized" title="">utilized</span> <span class="words" data-synonyms="sometimes;in some cases;now and then;some of the time" title="">now and then</span> in precision circuitry, which <span class="words" data-synonyms="this is;this is often;typically;usually;this can be" title="">typically </span>not) <span class="words" data-synonyms="connects;interfaces" title="">interfaces</span> to GND, and VREF (analog voltage reference, <span class="words" data-synonyms="used;utilized" title="">utilized</span> for changing the “scale” – we want <span class="words" data-synonyms="the full;the complete;the total" title="">the total</span> scale, so tie it to 3.3V). Below <span class="words" data-synonyms="is a;may be a;could be a" title="">could be a</span> wiring <span class="words" data-synonyms="diagram;graph;chart" title="">chart</span>. <span class="words" data-synonyms="Connect;Interface" title="">Interface</span> the 3.3V cobbler <span class="words" data-synonyms="pin;stick" title="">pin</span> to the <span class="words" data-synonyms="left;cleared out" title="">left</span> + rail and the GND <span class="words" data-synonyms="pin;stick" title="">pin</span> to <span class="words" data-synonyms="the right;the proper;the correct" title="">the correct</span> – rail. <span class="words" data-synonyms="Connect;Interface" title="">Interface</span> the <span class="words" data-synonyms="following;taking after" title="">taking after</span> pins for the MCP chip</div><div><table><tbody><tr><td>MCP3008 chip</td><td>Raspberry Pi</td></tr><tr><td>VDD</td><td>3.3V</td></tr><tr><td>VREF</td><td>3.3V</td></tr><tr><td>AGND</td><td>GND</td></tr><tr><td>CLK</td><td>SCLK</td></tr><tr><td>DOUT</td><td>MISO</td></tr><tr><td>DIN</td><td>MOSI</td></tr><tr><td> CS</td><td>GPIO Pin 22</td></tr></tbody></table><div> </div><div>Next, connect up theTMP36 - Temperature Sensor.</div><div> 1 (left) goes to 3.3v</div><div> 2 (middle) connects to MCP3008 CH0 (analog input #0)</div><div> 3 (right) connects to GND</div><div><hr /></div><h2>≡ Code Temperature ADC Raspberry pi:</h2><hr /><p>Open an editor (nano or IDLE) and paste in the following code</p></div><div><pre class="EnlighterJSRAW" data-enlighter-language="generic">import spidev, time
spi = spidev.SpiDev()
spi.open(0,0)
def analog_read(channel):
r = spi.xfer2([1, (8 + channel) << 4, 0])
adc_out = ((r[1]&3) << 8) + r[2]
return adc_out
while True:
reading = analog_read(0)
voltage = reading * 3.3 / 1024
temp_c = voltage * 100 - 50
temp_f = temp_c * 9.0 / 5.0 + 32
print("Temp C=%f\t\tTemp f=%f" % (temp_c, temp_f))
time.sleep(1)</pre><p>The program is based on that of Follow How to Interface MCP3008 with raspberry Pi . A little bit of additional math calculates the temperature in degrees Celsius and Fahrenheit:</p><p>Temp C=29.287109 Temp f=90.716797<br />Temp C=29.642578 Temp f=90.556641</p><p>The TMP36 <span class="words" data-synonyms="outputs;yields" title="">outputs</span> a voltage <span class="words" data-synonyms="that is;that's" title="">that's </span><span class="words" data-synonyms="proportional;relative;corresponding" title="">proportional</span> to the temperature. According to the <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/TMP35_36_37.pdf" rel="noopener noreferrer" target="_blank">datasheet</a> for the TMP36, the temperature in degrees C is calculated as the voltage (in volts) times 100 <span class="words" data-synonyms="minus;short" title="">minus</span> 50. The TMP36 is fine for measuring the <span class="words" data-synonyms="approximate;surmised;inexact" title="">inexact</span> temperature but is specified as having a <span class="words" data-synonyms="accuracy;precision;exactness" title="">precision</span> of <span class="words" data-synonyms="only;as it were" title="">as it were</span> 2 degrees C. This will <span class="words" data-synonyms="only;as it were" title="">as it got</span> worse <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">on the off chance that</span> you <span class="words" data-synonyms="attach;connect;join" title="">connect</span> long leads to it. To some extent, <span class="words" data-synonyms="you can;you'll;you'll be able to">you'll be able</span> to calibrate an individual <span class="words" data-synonyms="device;gadget" title="">device</span>, but for <span class="words" data-synonyms="better;superior;way better" title="">better</span> <span class="words" data-synonyms="accuracy;precision;exactness" title="">exactness</span>, <span class="words" data-synonyms="use;utilize" title="">utilize</span> a DS18B20 (<span class="words" data-synonyms="Recipe;Formula" title="">Formula</span> 13.11), which <span class="words" data-synonyms="has a;features a;includes a;contains a;encompasses a;incorporates a" title="">incorporates an</span> <span class="words" data-synonyms="stated;expressed" title="">expressed</span> <span class="words" data-synonyms="accuracy;precision;exactness" title="">precision</span> of 0.5% over a temperature <span class="words" data-synonyms="range;extend;run" title="">run</span> of -10 to +85 degrees C. Being an <span class="words" data-synonyms="digital;computerized;advanced" title="">advanced</span> <span class="words" data-synonyms="device;gadget" title="">gadget</span>, it <span class="words" data-synonyms="should;ought to" title="">ought to</span> not <span class="words" data-synonyms="suffer;endure" title="">suffer</span> any <span class="words" data-synonyms="loss;misfortune" title="">loss</span> of accuracy when <span class="words" data-synonyms="attached;connected;joined" title="">joined</span> to long leads.</p><p>If you want to know more about raspberry pi then click on the link below</p><h4 class="page-title is-large uppercase"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></h4></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-27217166440089927282022-04-29T19:49:00.001+06:002022-04-29T19:49:00.138+06:00Controlling GPIO Outputs Using a Web Interface with Raspberry Pi<h1 style="text-align: left;"><span><font face="arial, helvetica, sans-serif">Controlling GPIO Outputs Using a Web Interface with Raspberry Pi</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">You want to control GPIO outputs using a web interface to your Raspberry Pi. Today I show you how to Controlling GPIO Outputs Using a Web Interface with Raspberry Pi. Fast you have to need to know how to Use the bottle Python web server library to create an HTML web interface.</span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;"><strong>≡ Writing a Simple Web Server in Python:</strong></span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">To <span class="words" data-synonyms="understand;get it" title="">get it</span> how the program works, we, to begin with, <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">have to be seen</span> at how a web interface works. All web <span class="words" data-synonyms="interfaces;interfacing" title="">interfacing</span> <span class="words" data-synonyms="rely;depend" title="">depends</span> on a server <span class="words" data-synonyms="somewhere;some place" title="">someplace </span><span class="words" data-synonyms="responding;reacting" title="">responding</span> to <span class="words" data-synonyms="requests;demands" title="">requests</span> from a web browser. When the server <span class="words" data-synonyms="receives;gets" title="">receives</span> a <span class="words" data-synonyms="request;ask" title="">request</span>, it looks at the <span class="words" data-synonyms="information;data" title="">information</span> that comes with the <span class="words" data-synonyms="request;ask" title="">request</span> and <span class="words" data-synonyms="formulates;defines" title="">formulates</span> <span class="words" data-synonyms="some;a few" title="">a few</span> HyperText Markup <span class="words" data-synonyms="Language;Dialect" title="">Language</span> (HTML) in <span class="words" data-synonyms="response;reaction" title="">response</span>.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="Use;Utilize" title="">Utilize</span> the bottle Python library to run an <span class="words" data-synonyms="pure;unadulterated;immaculate" title="">unadulterated</span> Python web server that will respond to HTTP requests. To <span class="words" data-synonyms="install;introduce" title="">install</span> bottle, <span class="words" data-synonyms="use;utilize" title="">utilize</span> the <span class="words" data-synonyms="following;taking after" title="">following</span> command:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">sudo apt-get introduce python-bottle</span></pre><hr /><h2><strong><span style="font-family: arial, helvetica, sans-serif;">≡ Simple Web Server in Python Code:</span></strong></h2><hr /><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">from bottle import route, run, template
from datetime import datetime
@route('/')
def index(name='time'):
dt = datetime.now()
time = "{:%Y-%m-%d %H:%M:%S}".format(dt)
return template(' <head> <h1> Welcome to MechatronicsLab </h1> </head> <br> '
'<b> <h3> Raspberry Pi Thinks Today is : </h3> <br> date/time : {{t}}</b>', t=time)
run(host='localhost', port=8080)
</span></pre><p><strong><span style="font-family: arial, helvetica, sans-serif;">When you run this code you can see like this</span></strong></p>[caption id="attachment_709" align="alignnone" width="300"]<img alt="Browsing to a Python bottle web server" class="size-medium wp-image-709" height="169" src="https://www.mechatronicslab.net/my_uploads/2020/06/gpio-web-300x169.jpg" width="300" /> <span style="font-family: arial, helvetica, sans-serif;">Browsing to a Python bottle web server</span>[/caption]<p> </p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;">≡ Components Required Web Interface Raspberry Pi :</span></h3><hr /><div><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2. <a href="https://amzn.to/2NeiiwH" rel="noopener noreferrer" target="_blank">Micro SD Card</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Sandisk-Ultra-Micro-UHS-I-Adapter/dp/B073K14CVB/ref=as_li_ss_il?s=pc&ie=UTF8&qid=1530856971&sr=1-3&keywords=16gb+micro+sd+card+class+10&linkCode=li2&tag=sarful-20&linkId=7bd557de6615c6e30c98ebad7a976622&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B073K14CVB&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B073K14CVB" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3.<a href="https://amzn.to/2Bn579S" rel="noopener noreferrer" target="_blank">Ethernet cable</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Ethernet-Outdoor-Connector-Weatherproof-Resistant/dp/B07QLXC6QR/ref=as_li_ss_il?dchild=1&keywords=ethernet+cable&qid=1592668420&s=electronics&sr=1-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRDUwSThJNE80TVNFJmVuY3J5cHRlZElkPUEwMjE5ODQ5M0FLV1hJT09ZODMzVyZlbmNyeXB0ZWRBZElkPUEwMjQ4NzQ1MU9CV1NZOUkzS09SUCZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=&linkCode=li2&tag=sarful-20&linkId=342c6ec93ab949bd64c1fc92dadd716c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07QLXC6QR&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07QLXC6QR" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">4.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">5. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><div><span style="font-family: arial, helvetica, sans-serif;">6.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></span></div><p><span style="font-family: arial, helvetica, sans-serif;">7. <a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07CPX487B" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01ISMVA1E" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">8.<a href="https://amzn.to/2MV2v5s" rel="noopener noreferrer" target="_blank">Push Button Switch</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/6x6x4-5mm-Momentary-Tactile-Button-Switch/dp/B008DS1GY0/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=8443be8b71b0e38a1b7b9599f06fc87c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B008DS1GY0&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">9. <a href="https://amzn.to/30b8drV" rel="noopener noreferrer" target="_blank"> 5mm LED </a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Circuit-Assorted-Science-Experiment/dp/B07PG84V17/ref=as_li_ss_il?dchild=1&keywords=5mm+LED&qid=1591360832&sr=8-3&linkCode=li2&tag=sarful-20&linkId=1fb0a8a88cb779442b0b7b349d240761&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07PG84V17&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></p><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;">≡ Circuit diagram Web Interface Raspberry Pi:</span></h3><hr /><p><span style="font-family: arial, helvetica, sans-serif;">The breadboard layout for this is shown in</span></p></div><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="Controlling GPIO Outputs Using a Web_bb" class="alignnone size-medium wp-image-711" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/1-Controlling-GPIO-Outputs-Using-a-Web_bb-223x300.png" width="223" /> <img alt="Controlling GPIO Outputs Using a Web_bb" class="alignnone size-medium wp-image-712" height="235" src="https://www.mechatronicslab.net/my_uploads/2020/06/1-Controlling-GPIO-Outputs-Using-a-Web_schem-300x235.png" width="300" /></span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;"><strong>≡ Code Web Interface Raspberry Pi:</strong></span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">Open an editor (nano or IDLE) and paste in the following code</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">from bottle import route, run
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
led_pins = [18, 23, 24]
led_states = [0, 0, 0]
switch_pin = 25
GPIO.setup(led_pins[0], GPIO.OUT)
GPIO.setup(led_pins[1], GPIO.OUT)
GPIO.setup(led_pins[2], GPIO.OUT)
GPIO.setup(switch_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def switch_status():
state = GPIO.input(switch_pin)
if state:
return 'Up'
else:
return 'Down'
def html_for_led(led):
l = str(led)
result = " <input type='button' onClick='changed(" + l + ")' value='LED " + l + "'/>"
return result
def update_leds():
for i, value in enumerate(led_states):
GPIO.output(led_pins[i], value)
@route('/')
@route('/<led>')
def index(led):
if led >= '0' and led <= '9':
led_num = int(led)
led_states[led_num] = not led_states[led_num]
update_leds()
response = "<script>"
response += "function changed(led)"
response += "{"
response += " window.location.href='/' + led"
response += "}"
response += "</script>"
response += '<h1>MechatronicsLAB GPIO Control Raspberry Pi</h1>'
response += '<h2>Button=' + switch_status() + '</h2>'
response += '<h2>LEDs</h2>'
response += html_for_led(0)
response += html_for_led(1)
response += html_for_led(2)
return response
try:
run(host='0.0.0.0', port=8080)
finally:
print('\nCleaning up')
GPIO.cleanup()
</span></pre><p><span style="font-family: arial, helvetica, sans-serif;">If it starts correctly, you should see a message like this:</span></p><p><span style="font-family: arial, helvetica, sans-serif;">Bottle server starting up (using WSGIRefServer())...</span><br /><span style="font-family: arial, helvetica, sans-serif;">Listening on http://0.0.0.0:8080/</span><br /><span style="font-family: arial, helvetica, sans-serif;">Hit Ctrl-C to quit.</span></p><p><span style="font-family: arial, helvetica, sans-serif;">Open a browser window from any machine on your <span class="words" data-synonyms="network;organize;arrange" title="">network</span>, <span class="words" data-synonyms="even;indeed" title="">indeed</span> the Raspberry Pi itself, and <span class="words" data-synonyms="navigate;explore" title="">explore</span> to the IP address of the Raspberry Pi. The web interface <span class="words" data-synonyms="shown;appeared" title="">appeared</span> in <span class="words" data-synonyms="should;ought to" title="">ought to</span> <span class="words" data-synonyms="appear;show up" title="">show up</span>.</span></p>[caption id="attachment_710" align="alignnone" width="300"]<img alt="A web interface to GPIO" class="size-medium wp-image-710" height="200" src="https://www.mechatronicslab.net/my_uploads/2020/06/gpoi-interface-300x200.jpg" width="300" /> <span style="font-family: arial, helvetica, sans-serif;">A web interface to GPIO</span>[/caption]<p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="If;On the off chance that;In the event that;In case" title="Click to edit and show the other synonyms">On the off chance that</span> you <span class="words" data-synonyms="click;tap;press">tap</span> on one of the three <span class="words" data-synonyms="Led;Driven" title="">Led</span> buttons at the <span class="words" data-synonyms="bottom;foot" title="">bottom</span> of the screen, you <span class="words" data-synonyms="should;ought to" title="">ought to</span> <span class="words" data-synonyms="find;discover" title="">discover</span> that the <span class="words" data-synonyms="appropriate;fitting;suitable" title="">suitable</span> <span class="words" data-synonyms="Led;Driven" title="">Led</span> <span class="words" data-synonyms="toggles;flips" title="">toggles</span> on and off. Also, <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in case</span> you hold down the button as you reload <span class="words" data-synonyms="the web;the net;the internet" title="">the web</span> page, you should see that the <span class="words" data-synonyms="text;content" title="">content</span> next to Button says Down <span class="words" data-synonyms="rather than;instead of" title="">instead of</span> Up.</span></p><h2><span style="font-family: arial, helvetica, sans-serif;">If you want to know more about raspberry pi then click on the link below</span></h2><h4 class="page-title is-large uppercase"><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></span></h4>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-42154392606257123182022-04-29T10:59:00.001+06:002022-04-29T10:59:00.133+06:00How to Interface MCP3008 with raspberry Pi<h1 style="text-align: left;"><span><font face="arial, helvetica, sans-serif">How to Interface MCP3008 with raspberry Pi</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">You want to measure an analog voltage or Need to add analog inputs. Today I show you How to Interface MCP3008 with raspberry pi for measuring analog value.</span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Why we need MCP3008:</span></h2><hr /><p><span style="font-family: arial, helvetica, sans-serif;">The Raspberry Pi computer does not have a way to <span class="words" data-synonyms="read;perused;examined;studied" title="">read</span> analog inputs. It's a digital-only computer. Compare this to the Arduino, AVR or PIC microcontrollers that <span class="words" data-synonyms="often;regularly;frequently" title="">regularly</span> have 6 or more analog inputs! Analog inputs are <span class="words" data-synonyms="handy;convenient;helpful" title="">handy</span> <span class="words" data-synonyms="because;since" title="">because</span> <span class="words" data-synonyms="many;numerous" title="">many</span> sensors are analog <span class="words" data-synonyms="outputs;yields" title="">outputs</span>, so we <span class="words" data-synonyms="need;require" title="">require</span> a way <span class="words" data-synonyms="to make;to form;to create" title="">to form</span> the Pi analog-friendly.</span></p><p><span style="font-family: arial, helvetica, sans-serif;">We'll do that by wiring up an MCP3008 chip to it. The MCP3008 acts like a "bridge" between <span class="words" data-synonyms="digital;computerized;advanced" title="">digital</span> and analog. It has 8 analog inputs and the Pi can <span class="words" data-synonyms="query;inquiry" title="">query</span> it <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> 4 <span class="words" data-synonyms="digital;computerized;advanced" title="">digital</span> pins. <span class="words" data-synonyms="That makes;That creates;That produces" title="">That produces</span> it a <span class="words" data-synonyms="perfect;culminate;idealize" title="">perfect</span> <span class="words" data-synonyms="addition;expansion" title="">addition</span> to the Pi for <span class="words" data-synonyms="integrating;joining;coordination" title="">joining</span> <span class="words" data-synonyms="simple;basic;straightforward" title="">basic</span> sensors like photocells, FSRs or potentiometers, thermistors, etc.!<a href="http://www.adafruit.com/datasheets/MCP3008.pdf" rel="noopener noreferrer" target="_blank"> Let's check the datasheet of the MCP3008 chip</a>.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="MCP3008" class="alignnone wp-image-663 size-medium" height="225" src="https://www.mechatronicslab.net/my_uploads/2020/06/ezgif.com-gif-maker-300x225.jpg" width="300" /></span></p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;"> ≡ Components Required :</span></h3><hr /><div><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><div><span style="font-family: arial, helvetica, sans-serif;">5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></span></div><p><span style="font-family: arial, helvetica, sans-serif;">6. <a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07CPX487B" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01ISMVA1E" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">7.<a href="https://amzn.to/2YiYa2F" rel="noopener noreferrer" target="_blank">MCP3008</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Adafruit-MCP3008-8-Channel-Interface-Raspberry/dp/B00NAY3RB2/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=f307473ab64c76461ea354b61c60fa1c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00NAY3RB2&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B00NAY3RB2" style="border: none; margin: 0px;" width="1" /></span><br /><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></p><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;">≡ Circuit diagram MCP3008 raspberry Pi:</span></h3><hr /><div><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="shows;appears" title="">Shows</span> the <span class="words" data-synonyms="arrangement;course of action" title="">arrangement</span> of components on the breadboard</span></p></div><div> </div><div><p><span style="font-family: arial, helvetica, sans-serif;"><span style="font-family: arial, helvetica, sans-serif;"><img alt="Using an MCP3008 ADC IC with a Raspberry Pi" class="alignnone size-medium wp-image-665" height="225" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-mcp3008_schem-300x225.png" width="300" /></span></span><img alt="Using an MCP3008 ADC IC with a Raspberry Pi" class="alignnone wp-image-664 size-medium" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-mcp3008_bb-218x300.png" width="218" /></p></div></div><div><span style="font-family: arial, helvetica, sans-serif;">VDD (<span class="words" data-synonyms="power;control" title="">power</span>) and DGND (<span class="words" data-synonyms="digital;computerized;advanced" title="">digital</span> ground) to <span class="words" data-synonyms="power;control" title="">power</span> the MCP3008 chip. We <span class="words" data-synonyms="also;too;moreover" title="">moreover</span> <span class="words" data-synonyms="need;require" title="">require</span> four "SPI" <span class="words" data-synonyms="data;information" title="">data</span> pins: DOUT (<span class="words" data-synonyms="Data;Information" title="">Data</span> Out from MCP3008), CLK (Clock <span class="words" data-synonyms="pin;stick" title="">stick</span>), <span class="words" data-synonyms="Din;Clamor;Commotion;Noise" title="">Din</span> (<span class="words" data-synonyms="Data;Information" title="">Information</span> In from Raspberry Pi), and /CS (Chip Select). <span class="words" data-synonyms="Finally;At last;At long last" title="">At long last</span> of course, a source of analog <span class="words" data-synonyms="data;information" title="">data</span>. We'll be <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> <span class="words" data-synonyms="the basic;the essential;the fundamental" title="Click to edit and show the other synonyms">the fundamental</span> 10k trim pot. </span></div><div> </div><div><span style="font-family: arial, helvetica, sans-serif;">The MCP3008 <span class="words" data-synonyms="has a;features a;includes a;contains a;encompasses a;incorporates a" title="">has a</span> few more pins we <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">got to</span> <span class="words" data-synonyms="connect;interface" title="">interface</span>: AGND (analog ground, <span class="words" data-synonyms="used;utilized" title="">utilized</span> <span class="words" data-synonyms="sometimes;in some cases;now and then;some of the time" title="">now and then</span> in precision circuitry, which <span class="words" data-synonyms="this is;this is often;typically;usually;this can be" title="">typically </span>not) <span class="words" data-synonyms="connects;interfaces" title="">interfaces</span> to GND, and VREF (analog voltage reference, <span class="words" data-synonyms="used;utilized" title="">utilized</span> for changing the "scale" - we want <span class="words" data-synonyms="the full;the complete;the total" title="">the total</span> scale, so tie it to 3.3V). Below <span class="words" data-synonyms="is a;may be a;could be a" title="">could be a</span> wiring <span class="words" data-synonyms="diagram;graph;chart" title="">chart</span>. <span class="words" data-synonyms="Connect;Interface" title="">Interface</span> the 3.3V cobbler <span class="words" data-synonyms="pin;stick" title="">pin</span> to the <span class="words" data-synonyms="left;cleared out" title="">left</span> + rail and the GND <span class="words" data-synonyms="pin;stick" title="">pin</span> to <span class="words" data-synonyms="the right;the proper;the correct" title="">the correct</span> - rail. <span class="words" data-synonyms="Connect;Interface" title="">Interface</span> the <span class="words" data-synonyms="following;taking after" title="">taking after</span> pins for the MCP chip</span></div><div><table style="border-collapse: collapse; height: 171px; width: 56.9544%;"><tbody><tr style="height: 19px;"><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">MCP3008 chip</span></td><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">Raspberry Pi</span></td></tr><tr style="height: 19px;"><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">VDD</span></td><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">3.3V</span></td></tr><tr style="height: 19px;"><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">VREF</span></td><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">3.3V</span></td></tr><tr style="height: 19px;"><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">AGND</span></td><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">GND</span></td></tr><tr style="height: 19px;"><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">CLK</span></td><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">SCLK</span></td></tr><tr style="height: 19px;"><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">DOUT</span></td><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">MISO</span></td></tr><tr style="height: 19px;"><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">DIN</span></td><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">MOSI</span></td></tr><tr style="height: 19px;"><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;"> CS</span></td><td style="height: 19px; width: 50%;"><span style="font-family: arial, helvetica, sans-serif;">GPIO Pin 22</span></td></tr></tbody></table><div><span style="font-family: arial, helvetica, sans-serif;"> </span></div><div><span style="font-family: arial, helvetica, sans-serif;">Next, connect up the potentiometer.</span></div><div><span style="font-family: arial, helvetica, sans-serif;"> 1 (left) goes to 3.3v </span></div><div><span style="font-family: arial, helvetica, sans-serif;"> 2 (middle) connects to MCP3008 CH0 (analog input #0) </span></div><div><span style="font-family: arial, helvetica, sans-serif;"> 3 (right) connects to GND </span></div><div><hr /></div><h2><span style="font-family: arial, helvetica, sans-serif;">≡ Code MCP3008 raspberry pi </span></h2><hr /><div><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="Before;Some time recently" title="">Before</span> <span class="words" data-synonyms="trying;attempting" title="">trying</span> the program, make <span class="words" data-synonyms="sure;beyond any doubt" title="">beyond any doubt</span> <span class="words" data-synonyms="you have;you've got;you have got" title="">you have got</span> SPI <span class="words" data-synonyms="enabled;empowered" title="">enabled</span> and the SPIPython library <span class="words" data-synonyms="installed;introduced" title="">introduced</span> . Open an editor (nano ) and <span class="words" data-synonyms="paste;glue" title="">glue</span> <span class="words" data-synonyms="in the;within the" title="">within the</span> <span class="words" data-synonyms="following;taking after" title="">taking after</span> code</span></div><div><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">import spidev, time
spi = spidev.SpiDev()
spi.open(0, 0)
def analog_read(channel):
r = spi.xfer2([1, (8 + channel) << 4, 0])
adc_out = ((r[1]&3) << 8) + r[2]
return adc_out
while True:
reading = analog_read(0)
voltage = reading * 3.3 / 1024
print("Reading=%d\tVoltage=%f" % (reading, voltage))
time.sleep(1)</span></pre><p><span style="font-family: arial, helvetica, sans-serif;">The <span class="words" data-synonyms="interesting;curiously" title="">interesting</span> <span class="words" data-synonyms="part;portion" title="">part</span> of the program is contained <span class="words" data-synonyms="in the;within the" title="">within the</span> analog_read function. This takes a parameter that <span class="words" data-synonyms="should;ought to" title="">ought to</span> be between 0 and 7 and specifies which of the eight analog inputs down the lefthand side of the chip should be read. The bit <span class="words" data-synonyms="manipulation;control" title="">control</span> sets up an <span class="words" data-synonyms="request;ask" title="">ask</span> for the <span class="words" data-synonyms="appropriate;fitting;suitable" title="">suitable</span> channel and then sends the bits to the MCP3008, which <span class="words" data-synonyms="reads;peruses" title="">peruses</span> the resultant <span class="words" data-synonyms="data;information" title="">information</span>:</span></p><p><span style="font-family: arial, helvetica, sans-serif;">Reading=0 Voltage=0.000000</span><br /><span style="font-family: arial, helvetica, sans-serif;">Reading=126 Voltage=0.406055</span></p><p><span style="font-family: arial, helvetica, sans-serif;">The MCP3008 has 10-bit ADCs, so <span class="words" data-synonyms="when you;once you;after you" title="">after you</span> take a <span class="words" data-synonyms="reading;perusing" title="">reading</span>, it gives you a number between and 1023. The test program <span class="words" data-synonyms="converts;changes over" title="">changes over</span> this into a voltage reading by <span class="words" data-synonyms="multiplying;increasing;duplicating" title="">increasing</span> the <span class="words" data-synonyms="reading;perusing" title="">reading</span> by the voltage <span class="words" data-synonyms="range;extend;run" title="">range</span> (3.3V) and then dividing it by 1,024. You can combine any of the <span class="words" data-synonyms="following;taking after" title="">taking after</span> <span class="words" data-synonyms="recipes;formulas" title="">formulas</span> that <span class="words" data-synonyms="use;utilize">utilize</span> the MCP3008 to allow readings to be taken from up to eight sensors.</span></p></div><p><span style="font-family: arial, helvetica, sans-serif;">If you want to know more about raspberry pi then click on the link below</span></p><h4 class="page-title is-large uppercase"><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></span></h4></div><div> </div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-60060530870688720202022-04-22T12:44:00.001+06:002022-04-22T12:44:00.154+06:00How to Measuring Temperature in Thermistor with Raspberry Pi<h1 style="text-align: left;">How to Measuring Temperature in Thermistor with Raspberry Pi</h1><p>You want to measure temperature using a thermistor. Today I show you How to Measuring Temperature in Thermistor with Raspberry Pi step by step complete process</p><hr /><h3> ≡ Components Required :</h3><hr /><div><p>1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a><br /><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></p><p>2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a><br /><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></p><p>3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a><br /><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></p><div>5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a><br /><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></div><p>6. <a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a><br /><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07CPX487B" width="1" /></p><p><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01ISMVA1E" width="1" /></p><p>7. <a href="https://amzn.to/30Zm7h8" rel="noopener noreferrer" target="_blank">Thermistor</a><br /><a href="https://www.amazon.com/Ametherm-SL32-2R025-Aqua-Rite-Thermistor/dp/B06ZY4W8P4/ref=as_li_ss_il?_encoding=UTF8&psc=1&refRID=891CNP3P0RGZ307MNPNT&linkCode=li2&tag=sarful-20&linkId=3fad2c0c3e1486795932a869da4c54fc&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B06ZY4W8P4&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B06ZY4W8P4" style="border: none; margin: 0px;" width="1" /></p><p>This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</p><h3><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></h3><p><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></p><hr /><h3>≡ Circuit diagram Thermistor with Raspberry Pi:</h3><div><hr /><p>A thermistor could be a resistor whose resistance shifts with temperature. Utilize the step reaction method to measure the resistance of the thermistor and after that calculate the temperature.</p><p><span class="words" data-synonyms="When you;Once you;After you" title="Click to edit and show the other synonyms">once you</span> get your thermistor, make <span class="words" data-synonyms="sure;beyond any doubt" title="">beyond any doubt</span> simply know its values of Beta and R0 (resistance at 25C) <span class="words" data-synonyms="and that;which" title="">which </span>it <span class="words" data-synonyms="is a;may be a;could be a" title="">could be a</span> Negative Temperature Coefficient (NTC) device.</p><p><img alt="raspberry Thermister" class="alignnone size-medium wp-image-657" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-Thermister_bb-240x300.png" width="240" /> <img alt="" class="alignnone size-medium wp-image-658" height="244" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-Thermister_schem-300x244.png" width="300" /></p><p>Calculating the temperature from the resistance of the thermistor requires some <span class="words" data-synonyms="fairly;reasonably;decently" title="">reasonably</span> <span class="words" data-synonyms="hairy;shaggy;bushy" title="">bushy</span> math <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> logarithms called the Steinhart-Hart equation. This <span class="words" data-synonyms="equation;condition" title="">equation</span> <span class="words" data-synonyms="needs to;must;has to;should;ought to" title="">has to</span> know two things <span class="words" data-synonyms="about;approximately;almost;around" title="">about</span> the thermistor: its resistance at 25 degrees C (called T0 or <span class="words" data-synonyms="sometimes;in some cases;now and then;some of the time" title="">sometimes</span> T25) and a <span class="words" data-synonyms="constant;steady;consistent" title="">constant</span> for the thermistor called Beta, or sometimes <span class="words" data-synonyms="just;fair" title="">just</span> B. If <span class="words" data-synonyms="you use;you employ;you utilize" title="">you employ</span> a different thermistor, <span class="words" data-synonyms="you will;you'll;you may" title="">you'll </span><span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">got to</span> plug these values into the <span class="words" data-synonyms="variables;factors" title="">factors</span> B and R0 at the <span class="words" data-synonyms="top;beat;best" title="">top</span> of the program. Note that a capacitor typically only has an <span class="words" data-synonyms="accuracy;precision;exactness" title="">accuracy</span> of 10%, and thermistors are <span class="words" data-synonyms="similarly;essentially;so also;additionally" title="">similarly</span> <span class="words" data-synonyms="inaccurate;wrong" title="">wrong</span> in their <span class="words" data-synonyms="value;esteem" title="">value</span> of R0, so <span class="words" data-synonyms="to get;to urge;to induce" title="">to induce</span> <span class="words" data-synonyms="useful;valuable" title="">valuable</span> readings from the thermistor, <span class="words" data-synonyms="you will;you'll;you may" title="">you may</span> <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">got to</span> <span class="words" data-synonyms="tweak;change">change</span> the <span class="words" data-synonyms="variables;factors" title="">factors</span> C and R0.</p><hr /><h3>≡ Code Thermistor with Raspberry Pi :</h3><hr /><p>Open an editor (nano or IDLE) and paste in the following code</p><pre class="EnlighterJSRAW" data-enlighter-language="generic">import RPi.GPIO as GPIO
import time, math
C = 0.36 # uF
R1 = 1000 # Ohms
B = 3800.0 # The thermistor constant
R0 = 1100.0 # The resistance of the thermistor at 25C
GPIO.setmode(GPIO.BCM)
# Pin a charges the capacitor through a fixed 1k resistor
# and the thermistor in series
# Pin b discharges the capacitor through a fixed 1k resistor
a_pin = 18
b_pin = 23
# Discharge the capacitor, leaving it ready to start filling up
def discharge():
GPIO.setup(a_pin, GPIO.IN)
GPIO.setup(b_pin, GPIO.OUT)
GPIO.output(b_pin, False)
time.sleep(0.1)
# Return the time taken (uS) for C to charge
# which is 1.65V or higher
def charge_time():
GPIO.setup(b_pin, GPIO.IN)
GPIO.setup(a_pin, GPIO.OUT)
GPIO.output(a_pin, True)
t1 = time.time()
while not GPIO.input(b_pin):
pass
t2 = time.time()
return (t2 - t1) * 1000000
# Take an analog reading from charge time
def analog_read():
discharge()
t = charge_time()
discharge()
return t
# Convert the time taken to charge the capacitor into a value of resistance
# To reduce errors, do it 10 times and take the average.
def read_resistance():
n = 10
total = 0;
for i in range(1, n):
total = total + analog_read()
t = total / float(n)
T = t * 0.632 * 3.3
r = (T / C) - R1
return r
def read_temp_c():
R = read_resistance()
t0 = 273.15 # 0 deg C in K
t25 = t0 + 25.0 # 25 deg C in K
# Steinhart-Hart equation - Google it
inv_T = 1/t25 + 1/B * math.log(R/R0)
T = (1/inv_T - t0)
return T
try:
while True:
print(read_temp_c())
time.sleep(0.5)
finally:
GPIO.cleanup()</pre><p>When you run the program, you will see a series of temperature measurements in degrees C. To convert to degrees F, use the formula Tf =<br />Tc * 9 / 5 + 32.</p><p>35.5040458984<br />36.7302664759</p><p>If you want to know more about raspberry pi then click on the link below</p><h4 class="page-title is-large uppercase"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></h4></div></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-32115358904081935932022-04-15T12:04:00.001+06:002022-04-15T12:04:00.151+06:00How to Interface LDR with Raspberry Pi<h1 style="text-align: left;"><span><font face="arial, helvetica, sans-serif">How to Interface LDR with Raspberry Pi</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif; font-size: 100%;">You want to measure light intensity with a Raspberry Pi UsingLDR( photoresistor). Today I show you How to Interface LDR with Raspberry Pi and measure light intensity. </span></p><p><span style="font-family: arial, helvetica, sans-serif;">An LDR( photoresistor) <span class="words" data-synonyms="is a;may be a;could be a" title="">may be a</span> resistor whose resistance <span class="words" data-synonyms="varies;changes;shifts" title="">varies</span> depending on the amount of light coming through its <span class="words" data-synonyms="transparent;straightforward" title="">transparent</span> window. The brighter the light, the lower the resistance. <span class="words" data-synonyms="Typically;Ordinarily;Regularly" title="">Regularly</span>, the resistance <span class="words" data-synonyms="varies;changes;shifts" title="">changes</span> between about 1kΩ in <span class="words" data-synonyms="bright;shinning" title="">bright</span> light up to <span class="words" data-synonyms="perhaps;maybe" title="">maybe</span> 100kΩ in <span class="words" data-synonyms="complete;total" title="">total</span> <span class="words" data-synonyms="darkness;haziness;obscurity" title="">darkness</span></span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;"> ≡ </span>Components Required :</h2><hr /><div><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><div><span style="font-family: arial, helvetica, sans-serif;">5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></span></div><div><p><span style="font-family: arial, helvetica, sans-serif;">6. <a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07CPX487B" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01ISMVA1E" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">7. <a href="https://amzn.to/3hRFO0y" rel="noopener noreferrer" target="_blank">LDR(Photoresistor )</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/10pcs-Dependent-Resistor-Photoresistor-GL5528/dp/B00XDT8KI4/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=c72d1386b3eddbd8e971b664ca86837f&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00XDT8KI4&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B00XDT8KI4" style="border: none; margin: 0px;" width="1" /></span></p><h3><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></h3><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><hr /><h3><span style="font-family: arial, helvetica, sans-serif;">≡Circuit diagram LDR Raspberry Pi:</span></h3><hr /><p><span style="font-family: arial, helvetica, sans-serif;"> Shortcuts and do simple away with both 1kΩ resistors and one of the GPIO pins and make the simpler schematic shown in</span></p><h3><span style="font-family: arial, helvetica, sans-serif;"><img alt="A simplified light sensor" class="alignnone size-medium wp-image-653" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-pi-LDR_bb-248x300.png" width="248" /> <img alt="A simplified light sensor" class="alignnone size-medium wp-image-654" height="295" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-pi-LDR_schem-300x295.png" width="300" /></span></h3><p><span style="font-family: arial, helvetica, sans-serif;">In this Section, the same GPIO pin will be used to charge and discharge the capacitor and check to see if it is above the input HIGH threshold.</span></p><hr /><h2><span style="font-family: arial, helvetica, sans-serif;">≡Code LDR Raspberry Pi:</span></h2><hr /><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
pin = 18
def discharge():
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, False)
time.sleep(0.1)
# Return the time taken for the capacitor to go HIGH
# which is 1.65V or higher
def charge_time():
t1 = time.time()
GPIO.setup(pin, GPIO.IN)
while not GPIO.input(pin):
# charge for 1ms
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, True)
time.sleep(0.001)
# set to input to test again
GPIO.setup(pin, GPIO.IN)
time.sleep(0.001)
t2 = time.time()
return (t2 - t1) * 1000000
# Take an analog reading as the time taken to charge C
def analog_read():
discharge()
return charge_time()
while True:
print(analog_read())
time.sleep(0.5)</span></pre><p><span style="font-family: arial, helvetica, sans-serif;">In <span class="words" data-synonyms="only;as it were" title="">as it was</span> <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> one <span class="words" data-synonyms="pin;stick" title="">pin</span>, after <span class="words" data-synonyms="discharging;releasing" title="">releasing</span> the capacitor through the photoresistor, the charge_time <span class="words" data-synonyms="function;work" title="">function</span> charges the capacitor through the photoresistor for <span class="words" data-synonyms="just;fair" title="">just</span> 1 ms. It sets the <span class="words" data-synonyms="pin;stick" title="">pin</span> to be an input and tests to see if it’s over the <span class="words" data-synonyms="High;Tall" title="">Tall</span> <span class="words" data-synonyms="threshold;limit;edge" title="">threshold</span>, <span class="words" data-synonyms="and then;and after that" title="">and after that</span> <span class="words" data-synonyms="repeats;rehashes" title="">rehashes</span> until it is <span class="words" data-synonyms="High;Tall" title="">High</span>.</span></p><h2><span style="font-family: arial, helvetica, sans-serif;">If you want to know more about raspberry pi then click on the link below</span></h2><h4 class="page-title is-large uppercase"><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></span></h4></div></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-47485972718676475212022-04-08T12:35:00.001+06:002022-04-08T12:35:00.155+06:00How to Use Resistive Sensors in Raspberry pi<h1 style="text-align: left;"><span><font face="arial, helvetica, sans-serif">How to Use Resistive Sensors in Raspberry pi</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">You <span class="words" data-synonyms="want;need">need</span> <span class="words" data-synonyms="to connect;to associate;to put through (telephone)" title="">to connect</span> a variable resistor to a Raspberry Pi and <span class="words" data-synonyms="measure;degree" title="">measure</span> its resistance so <span class="words" data-synonyms="that you;that you simply;merely;that you just;simply" title="">that you simply</span> can <span class="words" data-synonyms="use;utilize" title="">utilize</span> the position of the variable resistor’s <span class="words" data-synonyms="knob;handle" title="">knob</span> in your Python program. Today I show you How to How to Use Resistive Sensors in Raspberry pi </span></p><h2><span style="font-family: arial, helvetica, sans-serif;">Components Required :</span></h2><div><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><div><span style="font-family: arial, helvetica, sans-serif;">5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></span></div><div><p><span style="font-family: arial, helvetica, sans-serif;">6. <a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07CPX487B" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01ISMVA1E" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">7. <a href="https://amzn.to/2B1i3SM" rel="noopener noreferrer" target="_blank">5K ohm Trim Pot</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/a14052600ux1117-Horizontal-Trimmer-Resistor-Potentiometer/dp/B00SWK15KE/ref=as_li_ss_il?dchild=1&keywords=Trimmer+Potentiometer&qid=1591974522&sr=8-8&linkCode=li2&tag=sarful-20&linkId=15b828176944fe566f348b8975ab17e7&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00SWK15KE&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B00SWK15KE" width="1" /></span></p><h3><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></h3><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><h3><span style="font-family: arial, helvetica, sans-serif;">Circuit diagram:</span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="shows;appears" title="">shows</span> the <span class="words" data-synonyms="arrangement;course of action" title="">arrangement</span> of components on the breadboard</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="Circuit diagram" class="alignnone size-medium wp-image-645" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/Measuring-resistance-on-a-Raspberry-Pi-248x300.png" width="248" /> <img alt="Circuit diagram" class="alignnone size-medium wp-image-644" height="246" src="https://www.mechatronicslab.net/my_uploads/2020/06/Measuring-resistance-on-a-Raspberry-Pi-ckt-300x246.png" width="300" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="You can;You'll;You'll be able to" title="Click to edit and show the other synonyms">You'll be able</span> to <span class="words" data-synonyms="measure;degree" title="">measure</span> the resistance on a Raspberry Pi using nothing more than a capacitor, <span class="words" data-synonyms="a couple;a few;one or two;a handful;some" title="">a few</span> resistors, and two GPIO pins. In this case, <span class="words" data-synonyms="you will;you'll;you may" title="">you'll </span>be able to <span class="words" data-synonyms="estimate;assess;gauge;appraise" title="">gauge</span> the position of the <span class="words" data-synonyms="knob;handle" title="">handle</span> on a <span class="words" data-synonyms="small;little" title="">small</span> variable resistor by measuring its resistance from its slider contact to one <span class="words" data-synonyms="end;conclusion" title="">end</span> of the pot.</span></p><h2><span style="font-family: arial, helvetica, sans-serif;">Code Resistive Sensors Raspberry pi:</span></h2><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">import RPi.GPIO as GPIO
import time, math
C = 0.36 # uF
R1 = 1000 # Ohms
GPIO.setmode(GPIO.BCM)
# Pin a charges the capacitor through a fixed 1k resistor
# and the pot in series
# Pin b discharges the capacitor through a fixed 1k resistor
a_pin = 18
b_pin = 23
# Discharge the capacitor, leaving it ready to start filling up
def discharge():
GPIO.setup(a_pin, GPIO.IN)
GPIO.setup(b_pin, GPIO.OUT)
GPIO.output(b_pin, False)
time.sleep(0.1)
# Return the time taken (uS) for the voltage on the capacitor
# to count as a digital input HIGH
# which is 1.65V or higher
def charge_time():
GPIO.setup(b_pin, GPIO.IN)
GPIO.setup(a_pin, GPIO.OUT)
GPIO.output(a_pin, True)
t1 = time.time()
while not GPIO.input(b_pin):
pass
t2 = time.time()
return (t2 - t1) * 1000000
# Take an analog reading as the time taken to charge after
# first discharging the capacitor
def analog_read():
discharge()
t = charge_time()
discharge()
return t
# Convert the time taken to charge the cpacitor into a value of resistance
# To reduce errors, do it 100 times and take the average
def read_resistance():
n = 10
total = 0;
for i in range(1, n):
total = total + analog_read()
t = total / float(n)
T = t * 0.632 * 3.3
r = (T / C) - R1
return r
try:
while True:
print(read_resistance())
time.sleep(0.5)
finally:
GPIO.cleanup()</span></pre><p><span style="font-family: arial, helvetica, sans-serif;">When you run the program, you should see some output like this:</span></p><p><span style="font-family: arial, helvetica, sans-serif;">10232.2157936</span><br /><span style="font-family: arial, helvetica, sans-serif;">10155.1559448</span></p><p><span style="font-family: arial, helvetica, sans-serif;">The <span class="words" data-synonyms="reading;perusing" title="">reading</span> will <span class="words" data-synonyms="vary;change;shift" title="">shift</span> as you <span class="words" data-synonyms="rotate;turn;pivot" title="">turn</span> the <span class="words" data-synonyms="knob;handle" title="">knob</span> of the trimpot. the reading of resistance would <span class="words" data-synonyms="vary;change;shift" title="">change</span> between and 10,000Ω but in practice, there will be <span class="words" data-synonyms="some;a few" title="">a few</span> <span class="words" data-synonyms="error;blunder;mistake" title="">mistakes</span>. You might like to <span class="words" data-synonyms="tweak;change" title="">change</span> the <span class="words" data-synonyms="value;esteem" title="">value</span> of the constant C at the <span class="words" data-synonyms="top;beat;best" title="">top</span> of the program <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> you <span class="words" data-synonyms="want;need" title="">need</span> more <span class="words" data-synonyms="accurate;precise;exact" title="">exact</span> readings, but remember the <span class="words" data-synonyms="value;esteem" title="">value</span> of C will <span class="words" data-synonyms="probably;likely" title="">probably</span> <span class="words" data-synonyms="have to;need to;got to;have to be compelled to;ought to" title="">have to be</span> changed <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> you put another capacitor in, <span class="words" data-synonyms="even;indeed" title="">indeed</span> <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in case</span> the capacitor was <span class="words" data-synonyms="nominally;ostensibly" title="">nominal</span> of the same <span class="words" data-synonyms="value;esteem" title="">value</span></span></p><h2><span style="font-family: arial, helvetica, sans-serif;">If you want to know more about raspberry pi then click on the link below</span></h2><h4 class="page-title is-large uppercase"><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></span></h4></div></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-89226373316934943282022-04-01T09:50:00.001+06:002022-04-01T09:50:00.180+06:00How Add GPS to the Raspberry Pi<h1 style="text-align: left;"><span><font face="arial, helvetica, sans-serif">How Add GPS to the Raspberry Pi</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">You <span class="words" data-synonyms="want;need" title="">need</span> <span class="words" data-synonyms="to connect;to associate;to put through (telephone)" title="Click to edit and show the other synonyms">to connect</span> a serial GPS module to a <span class="words" data-synonyms="mobile;portable;versatile" title="">portable</span> Raspberry Pi and access the <span class="words" data-synonyms="data;information" title="">information</span>, <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> Python. Today I show you how to How Adding GPS to the Raspberry Pi.</span></p><h2>Components Required :</h2><div><p>1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a><br /><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></p><p>2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a><br /><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></p><p>3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a><br /><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></p><div>5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a><br /><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></div><p>5.<a href="https://amzn.to/37F2zzW" rel="noopener noreferrer" target="_blank">Adafruit Ultimate GPS Breakout</a><br /><a href="https://www.amazon.com/Adafruit-Ultimate-GPS-Breakout-channel/dp/B01H1R8BK0/ref=as_li_ss_il?dchild=1&keywords=Adafruit+Ultimate+GPS+Breakout&qid=1592449817&s=electronics&sr=1-2&linkCode=li2&tag=sarful-20&linkId=c83da48bad1a18f43811cceab7528d39&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01H1R8BK0&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01H1R8BK0" style="border: none; margin: 0px;" width="1" /></p><p>The breakout is built around the MTK3339 chipset, a no-nonsense, high-quality GPS module that can track up to 22 satellites on 66 channels, has an excellent high-sensitivity receiver (-165 dBm tracking!), and a built-in antenna. It can do up to 10 location updates a second for high speed, high sensitivity logging, or tracking. Power usage is incredibly low, only 20 mA during navigation More information Visit <a href="https://www.adafruit.com/product/746">https://www.adafruit.com/product/746</a></p><h3>This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</h3><h3><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></h3><p><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></p><h3>Circuit diagram :</h3></div><div>[caption id="attachment_641" align="alignnone" width="228"]<img alt="Wiring a GPS to a Raspberry Pi" class="size-medium wp-image-641" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/raspberry-GPS_bb-228x300.png" width="228" /> Wiring a GPS to a Raspberry Pi[/caption]<p>A 3.3V serial GPS module can be <span class="words" data-synonyms="connected;associated" title="">connected</span> <span class="words" data-synonyms="directly;specifically;straightforwardly" title="">directly</span> to Raspberry Pi’s RXD connection. <span class="words" data-synonyms="shows;appears" title="">shows</span> how the module is wired. The RXD of the Raspberry Pi connects to Tx of the GPS module. The <span class="words" data-synonyms="only;as it were" title="">as it were</span> other <span class="words" data-synonyms="connections;associations" title="">connections</span> are for GND and 5V, so <span class="words" data-synonyms="we can;we will;we are able to;ready to;able to" title="">we are able</span> to <span class="words" data-synonyms="easily;effortlessly;effectively" title="">effectively</span> <span class="words" data-synonyms="just;fair" title="">just</span> <span class="words" data-synonyms="use;utilize" title="">utilize</span> three female-to-female headers.</p><p>Now you have yo need install some package</p><pre class="EnlighterJSRAW" data-enlighter-language="generic">$ sudo apt-get install gpsd
$ sudo apt-get install gpsd-clients
</pre><p>The most important of these is gpsd. This is often a tool that reads GPS information from a serial or USB connection as well as other sources and makes it available for client programs to utilize by giving a nearby web service on port 2748. To begin the gpsd service running, issue the following command:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic">sudo gpsd /dev/ttyAMA0
cgps -s
</pre><h3>Code:</h3><pre class="EnlighterJSRAW" data-enlighter-language="generic">from gps import *
session = gps()
session.stream(WATCH_ENABLE|WATCH_NEWSTYLE)
while True:
report = session.next()
if report.keys()[0] == 'epx' :
lat = float(report['lat'])
lon = float(report['lon'])
print("lat=%f\tlon=%f\ttime=%s" % (lat, lon, report['time']))
time.sleep(0.5
</pre><p>Run the program, and you should see some Look like this:<br />lat=24.3745 lon=88.6042 time=2020-06-018T08:06:24.960Z<br />lat=24.3745 lon= 88.6042 time=2020-06-018T08:06:25.960Z</p><div><h2>If you want to know more about raspberry pi then click on the link below</h2><h4 class="page-title is-large uppercase"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></h4></div><div class="blog-share text-center"> </div></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-82381928147434190902022-03-25T20:40:00.001+06:002022-03-25T20:40:00.149+06:00How to Send sensor data to cloud using NodMcu8266 | IoT Tutorial<h1 style="text-align: left;"><span style="color: black; font-family: arial, helvetica, sans-serif;"><font face="arial, helvetica, sans-serif">How to Send sensor data to the cloud using NodMcu8266 | IoT Tutorial</font></span></h1><p><span style="color: black; font-family: arial, helvetica, sans-serif;">We are <span class="words" data-synonyms="going to;getting to;progressing to;attending to;reaching to;planning to;aiming to" title="">planning to</span> use the NodMcu8266 to <span class="words" data-synonyms="automatically;naturally;consequently" title="">automatically</span> log temperature and <span class="words" data-synonyms="humidity;stickiness;mugginess" title="">humidity</span> <span class="words" data-synonyms="measurements;estimations" title="">measurements</span> <span class="words" data-synonyms="in the;within the" title="">within the</span> cloud, and <span class="words" data-synonyms="display;show" title="">show</span> these <span class="words" data-synonyms="measurements;estimations" title="">measurements</span> <span class="words" data-synonyms="inside;interior" title="">inside</span> an online dashboard for this we use the DHT11 sensor for Measure temperature and <span class="words" data-synonyms="humidity;stickiness;mugginess" title="">humidity Data in our Environment. We will complete this project by dividing it into several parts.</span></span></p><h3><span style="color: black; font-family: arial, helvetica, sans-serif;">Part-1:</span></h3><h2><span style="color: black; font-family: arial, helvetica, sans-serif;">Required Component :</span></h2><p><span style="color: black; font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/2AH0NSM" rel="noopener noreferrer" style="color: black;" target="_blank">NodeMcu8266</a></span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/KeeYees-Internet-Development-Wireless-Compatible/dp/B07PR9T5R5/ref=as_li_ss_il?dchild=1&keywords=nodemcu&qid=1592385421&s=electronics&sr=1-11&linkCode=li2&tag=sarful-20&linkId=d387bf11f7763920b4fa47ff384debe7&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07PR9T5R5&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07PR9T5R5" width="1" /></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" style="color: black;" target="_blank">Breadboard</a></span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" style="color: black;" target="_blank">Connecting wire</a></span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">4.<a href="https://amzn.to/2zG5LPp" rel="noopener noreferrer" style="color: black;" target="_blank">DHT11</a></span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Temperature-Relative-Humidity-Compatible-Arduino/dp/B00TM87YRS/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=17660a6baed933e575e726a88ff00a2a&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00TM87YRS&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B00TM87YRS" style="border: none; margin: 0px;" width="1" /></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">5.<a href="https://amzn.to/2UVWEBA" rel="noopener noreferrer" style="color: black;" target="_blank">Breadboard Power Supply Module</a></span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/JBtek-Breadboard-Supply-Arduino-Solderless/dp/B010UJFVTU/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=e65ba2650409a00cc588ed8c45f6f318&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B010UJFVTU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B010UJFVTU" style="border: none; margin: 0px;" width="1" /></span></p><h2><span style="color: black; font-family: arial, helvetica, sans-serif;">Software Required:</span></h2><p><span style="color: black; font-family: arial, helvetica, sans-serif;">The latest version of the Arduino IDE, which you can get from:</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">http://www.arduino.cc/en/Main/Software</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Follow this link to How to Complet Software Setup <a href="https://www.mechatronicslab.net/installing-the-arduino-ide-for-the-esp8266/" rel="noopener noreferrer" style="color: black;" target="_blank">Installing the Arduino IDE for the ESP8266 | IoT Tutorial</a></span></p><h3><span style="color: black; font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of the <a href="https://amzn.to/3dhe6a5" rel="noopener noreferrer" style="color: black;" target="_blank">Internet of Things with ESP8266</a></span></h3><p><span style="color: black; font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Internet-Things-ESP8266-Marco-Schwartz/dp/1786468026/ref=as_li_ss_il?dchild=1&keywords=nodemcu&qid=1592385562&s=books&sr=1-3&linkCode=li2&tag=sarful-20&linkId=4e93e7d5b6aa68f429f9db8c40aec248&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1786468026&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Part-2:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">After Complet your hardware Collection and Software installation now we have to need waring with sensor and esp8266</span></p><h2><span style="color: black; font-family: arial, helvetica, sans-serif;">Circuit Diagram sensor Data cloud NodMcu8266:</span></h2><p><span style="color: black; font-family: arial, helvetica, sans-serif;">shows how to connect a DHT 11 sensor to NodMcu8266.</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;"><img alt="DHT sensor with nosemcu8266" class="alignnone size-medium wp-image-626" height="297" src="https://www.mechatronicslab.net/my_uploads/2020/06/DHT-sensor-with-nosemcu8266-300x297.png" width="300" /></span></p><h2><span style="color: black; font-family: arial, helvetica, sans-serif;">Part-3</span></h2><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Now we went to test sensor work properly or not so we have to need a test for sensor</span></p><h3><span style="color: black; font-family: arial, helvetica, sans-serif;">Testing the sensor:</span></h3><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Now we will simply print the value of the temperature inside the Serial monitor of the Arduino IDE. If it has not been done yet</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">,<img alt="install the DHT sensor library using the Arduino IDE library manager." class="alignnone wp-image-627 size-medium" height="168" src="https://www.mechatronicslab.net/my_uploads/2020/06/DHT-Libary-Install-300x168.jpg" width="300" /></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">install the DHT sensor library using the Arduino IDE library manager.</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">This is the complete code for this part:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="cpp"><span style="color: black; font-family: arial, helvetica, sans-serif;">// Libraries
#include "DHT.h"
// Pin
#define DHTPIN D5
// Use DHT11 sensor
#define DHTTYPE DHT11
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE, 15);
void setup() {
// Start Serial
Serial.begin(115200);
// Init DHT
dht.begin();
}
void loop() {
// Reading temperature and humidity
float h = dht.readHumidity();
// Read temperature as Celsius
float t = dht.readTemperature();
// Display data
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");
// Wait a few seconds between measurements.
delay(2000);
}</span></pre><p><span style="color: black; font-family: arial, helvetica, sans-serif;">if you see like this interface then test successfully done</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;"><img alt="DHt test output" class="alignnone size-medium wp-image-628" height="182" src="https://www.mechatronicslab.net/my_uploads/2020/06/DHt-test-output-300x182.jpg" width="300" /></span></p><h2><span style="color: black; font-family: arial, helvetica, sans-serif;">Code Overview Part-3 Code:</span></h2><p><span style="color: black; font-family: arial, helvetica, sans-serif;">It starts by including the required libraries:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="color: black; font-family: arial, helvetica, sans-serif;">#include "ESP8266WiFi.h"
#include "DHT.h"</span></pre><p><span style="color: black; font-family: arial, helvetica, sans-serif;">To install those libraries, simply look for them inside the Arduino IDE library manager. Next, we need to set the pin that the DHT sensor is connected to:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="color: black; font-family: arial, helvetica, sans-serif;">#define DHTPIN D5
#define DHTTYPE DHT11</span></pre><p><span style="color: black; font-family: arial, helvetica, sans-serif;">After that, we declare an instance of the DHT sensor:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="color: black; font-family: arial, helvetica, sans-serif;">DHT dht(DHTPIN, DHTTYPE, 15);</span></pre><p><span style="color: black; font-family: arial, helvetica, sans-serif;">We also define two variables that will hold the measurements of the sensor</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="color: black; font-family: arial, helvetica, sans-serif;">float temperature;
float humidity;</span></pre><p><span style="color: black; font-family: arial, helvetica, sans-serif;">In the setup() function of the sketch, we initialize the sensor:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="color: black; font-family: arial, helvetica, sans-serif;">dht.begin();</span></pre><p><span style="color: black; font-family: arial, helvetica, sans-serif;">in the loop() function, we make the measurements from the sensor:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="color: black; font-family: arial, helvetica, sans-serif;">humidity = dht.readHumidity();
temperature = dht.readTemperature();</span></pre><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Finally Display data on your serial monitor :</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="color: black; font-family: arial, helvetica, sans-serif;">Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");</span></pre><h2><span style="color: black; font-family: arial, helvetica, sans-serif;">Part-4</span></h2><p><span style="color: black; font-family: arial, helvetica, sans-serif;">We are now going to see how to Send the temperature and humidity measurements in the cloud. We will use the Dweet.io cloud service here, which is very convenient for sending data online:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Sensor data send to Dweet.io:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Code:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="color: black; font-family: arial, helvetica, sans-serif;">// Libraries
#include <ESP8266WiFi.h>
#include "DHT.h"
// WiFi parameters
const char* ssid = "Mechatronics";
const char* password = "Pa$$word";
// Pin
#define DHTPIN D5
// Use DHT11 sensor
#define DHTTYPE DHT11
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE, 15);
// Host
const char* host = "dweet.io";
void setup() {
// Start Serial
Serial.begin(115200);
delay(10);
// Init DHT
dht.begin();
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
Serial.print("Connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
// Reading temperature and humidity
int h = dht.readHumidity();
// Read temperature as Celsius
int t = dht.readTemperature();
// This will send the request to the server
client.print(String("GET /dweet/for/sensorvalue?temperature=") + String(t) + "&humidity=" + String(h) + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(10);
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
// Repeat every 10 seconds
delay(10000);
}</span></pre><h3><span style="color: black; font-family: arial, helvetica, sans-serif;">Code overview part-4:</span></h3><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Inside this loop, we connect to the Dweet.io server with:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">WiFiClient client;</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">const int httpPort = 80;</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">if (!client.connect(host, httpPort)) {</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">Serial.println("connection failed");</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">return;</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">}</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Then, we read the data from the sensor with:</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">int h = dht.readHumidity();</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">int t = dht.readTemperature();</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">After that, we send data to the Dweet.io server with:</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">client.print(String("GET /dweet/for/sensorvalue?temperature=") +</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">String(t) + "&humidity=" + String(h) + " HTTP/1.1\r\n" +</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">"Host: " + host + "\r\n" +</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">"Connection: close\r\n\r\n");</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">We also print any data received on the serial port with:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">while(client.available()){</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">String line = client.readStringUntil('\r');</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">Serial.print(line);</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">}</span></p><h2><span style="color: black; font-family: arial, helvetica, sans-serif;">Part-5</span></h2><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Displaying data using Freeboard.io</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="Now;Presently" title="">Now</span>, we would like to <span class="words" data-synonyms="actually;really" title="">really</span> <span class="words" data-synonyms="display;show">show</span> the recorded <span class="words" data-synonyms="data;information" title="">data</span> <span class="words" data-synonyms="inside;interior" title="">interior</span> a dashboard that can be <span class="words" data-synonyms="accessed;gotten to" title="">accessed</span> from <span class="words" data-synonyms="anywhere;anyplace" title="">anyplace</span> <span class="words" data-synonyms="in the;within the" title="">within the</span> world. For that, we are <span class="words" data-synonyms="going to;getting to;progressing to;attending to;reaching to;planning to;aiming to" title="">going to</span> <span class="words" data-synonyms="use;utilize" title="">utilize</span> a service that I <span class="words" data-synonyms="love;cherish;adore" title="">love</span> to <span class="words" data-synonyms="use;utilize">utilize</span> <span class="words" data-synonyms="along with;along side;in conjunction with;beside;at the side of;together with">along side</span> Dweet.io: Freeboard.io.</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">Let's get started with using Freeboard.io:</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">1. First, create an account there by going to:</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">https://www.freeboard.io/</span><br /><span style="color: black; font-family: arial, helvetica, sans-serif;">2. Then, create a new dashboard, and inside this dashboard, create a new data source. Link this data source to your Dweet.io thing that you defined in the NodeMcu8266 code:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;"><img alt="" class="alignnone size-medium wp-image-629" height="151" src="https://www.mechatronicslab.net/my_uploads/2020/06/1-300x151.jpg" width="300" /></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">3. Now create a new Gauge widget that we will use to display the temperature. Give it a name, and link it to the temperature field of our data source:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;"><img alt="" class="alignnone size-medium wp-image-630" height="129" src="https://www.mechatronicslab.net/my_uploads/2020/06/2-300x129.jpg" width="300" /></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">This is the final result:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;"><img alt="" class="alignnone size-medium wp-image-631" height="137" src="https://www.mechatronicslab.net/my_uploads/2020/06/3-300x137.jpg" width="300" /></span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;">You can then do the same with the humidity measurements and also display them on this dashboard:</span></p><p><span style="color: black; font-family: arial, helvetica, sans-serif;"><img alt="" class="alignnone size-medium wp-image-632" height="129" src="https://www.mechatronicslab.net/my_uploads/2020/06/4-300x129.jpg" width="300" /></span></p><div><p><span style="color: black; font-family: arial, helvetica, sans-serif;">There are <span class="words" data-synonyms="many;numerous" title="">many</span> ways to <span class="words" data-synonyms="improve;move forward;progress;make strides" title="">improve</span> this <span class="words" data-synonyms="project;extend;venture" title="">extend</span>. <span class="words" data-synonyms="You can;You'll;You'll be able to" title="">You'll </span><span class="words" data-synonyms="simply;basically;essentially" title="">essentially</span> <span class="words" data-synonyms="add;include" title="">include</span> more sensors to the <span class="words" data-synonyms="project;extend;venture" title="">project</span> and <span class="words" data-synonyms="display;show" title="">display</span> these <span class="words" data-synonyms="measurements;estimations" title="">measurements</span> as well <span class="words" data-synonyms="inside;interior" title="">inside</span> the Freeboard.io dashboard. </span></p><div><span style="color: black; font-family: arial, helvetica, sans-serif;">You can <span class="words" data-synonyms="also;too;moreover" title="">also</span>, for <span class="words" data-synonyms="example;case;illustration" title="">example</span>, <span class="words" data-synonyms="completely;totally" title="">completely</span> <span class="words" data-synonyms="change;alter" title="">change</span> the <span class="words" data-synonyms="project;extend;venture" title="">extend</span>, by <span class="words" data-synonyms="connecting;interfacing" title="">interfacing</span> a motion sensor to the ESP8266 board. <span class="words" data-synonyms="You can;You'll;You'll be able to" title="">You'll be able</span> <span class="words" data-synonyms="then;at that point" title="">at that point</span> to <span class="words" data-synonyms="configure;arrange;design" title="">design</span> this sensor to automatically send you an <span class="words" data-synonyms="alert;alarm;caution" title="">alert</span> when <span class="words" data-synonyms="motion;movement" title="">movement</span> is <span class="words" data-synonyms="detected;recognized;identified" title="">detected</span>, for <span class="words" data-synonyms="example;case;illustration" title="">example</span> <span class="words" data-synonyms="via;through;by means of" title="">by means of</span> <span class="words" data-synonyms="e-mail;email;mail" title="">email</span> or <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> Twitter. The <span class="words" data-synonyms="possibilities;conceivable outcomes" title="">conceivable outcomes</span> are <span class="words" data-synonyms="endless;perpetual;unending" title="">perpetual</span>!</span></div></div><div><h2>Visit to get more tutorials on IoT project</h2><h2 class="page-title is-large uppercase"><a href="https://www.mechatronicslab.net/category/internet-of-things/" rel="noopener noreferrer" target="_blank">INTERNET OF THINGS</a></h2></div><div> </div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-76964511485766082862022-03-18T15:43:00.001+06:002022-03-18T15:43:00.147+06:00How Control an LED Using Espo8266 | IoT Tutorial<h1 style="text-align: left;"><span style="font-family: arial, helvetica, sans-serif;"><font face="arial, helvetica, sans-serif">How Control an LED Using Espo8266 | IoT Tutorial</font></span></h1><p><span style="font-family: arial, helvetica, sans-serif;">Today we are <span class="words" data-synonyms="going to;getting to;progressing to;attending to;reaching to;planning to;aiming to" title="">going to</span> see How Control an LED Using Espo8266. The GPIO pins of the ESP8266 can be <span class="words" data-synonyms="configured;arranged;designed" title="">configured</span> to realize <span class="words" data-synonyms="many;numerous" title="">many</span> <span class="words" data-synonyms="functions;capacities" title="">functions</span>: inputs, <span class="words" data-synonyms="outputs;yields" title="">outputs</span>, PWM <span class="words" data-synonyms="outputs;yields" title="">outputs</span>, and also SPI or I2C communications. This <span class="words" data-synonyms="first;to begin with" title="">to begin with</span> the <span class="words" data-synonyms="project;extend;venture" title="">project</span> will <span class="words" data-synonyms="teach;instruct;educate" title="">teach</span> you how to <span class="words" data-synonyms="use;utilize" title="">utilize</span> the GPIO pins of the chip as <span class="words" data-synonyms="outputs;yields" title="">outputs.</span></span></p><p><span style="font-family: arial, helvetica, sans-serif;">Required Component :</span></p><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/2AH0NSM" rel="noopener noreferrer" target="_blank">NodeMcu8266</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/KeeYees-Internet-Development-Wireless-Compatible/dp/B07PR9T5R5/ref=as_li_ss_il?dchild=1&keywords=nodemcu&qid=1592385421&s=electronics&sr=1-11&linkCode=li2&tag=sarful-20&linkId=d387bf11f7763920b4fa47ff384debe7&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07PR9T5R5&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07PR9T5R5" style="border: none; margin: 0px;" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">4.<a href="https://amzn.to/371fKuQ" rel="noopener noreferrer" target="_blank">Resistors</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/42-7-foot-l%C3%A1mpara-indicador-reemplazos-a18013000ux0014/dp/B07CPX487B/ref=as_li_ss_il?dchild=1&keywords=Resistors&qid=1591361170&s=electronics&sr=1-42&linkCode=li2&tag=sarful-20&linkId=7b950f7aca7d051449d2b34577ce8ec4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07CPX487B&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">5. <a href="https://amzn.to/30b8drV" rel="noopener noreferrer" target="_blank"> 5mm LED </a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Circuit-Assorted-Science-Experiment/dp/B07PG84V17/ref=as_li_ss_il?dchild=1&keywords=5mm+LED&qid=1591360832&sr=8-3&linkCode=li2&tag=sarful-20&linkId=1fb0a8a88cb779442b0b7b349d240761&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07PG84V17&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><h3><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of the Internet of Things with ESP8266</span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Internet-Things-ESP8266-Marco-Schwartz/dp/1786468026/ref=as_li_ss_il?dchild=1&keywords=nodemcu&qid=1592385562&s=books&sr=1-3&linkCode=li2&tag=sarful-20&linkId=4e93e7d5b6aa68f429f9db8c40aec248&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1786468026&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><h2><span style="font-family: arial, helvetica, sans-serif;">Circuit Diagram :</span></h2>[caption id="attachment_621" align="alignnone" width="274"]<img alt="Controlling an LED Using Nodemcu" class="size-medium wp-image-621" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/Fast-project-274x300.png" width="274" /> <span style="font-family: arial, helvetica, sans-serif;">Controlling an LED</span>[/caption]<p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="connect;interface">interface</span> the <span class="words" data-synonyms="Led;Driven" title="">LED</span> with the resistor to the ESP8266 board. To do so, <span class="words" data-synonyms="the first;the primary" title="">the primary</span> thing to do is to <span class="words" data-synonyms="place;put" title="">put</span> the resistor on the breadboard. <span class="words" data-synonyms="Then;At that point" title="">At that point</span>, <span class="words" data-synonyms="place;put" title="">put</span> the <span class="words" data-synonyms="Led;Driven" title="">LED</span> on the breadboard as well, <span class="words" data-synonyms="connecting;interfacing" title="">interfacing</span> the longest <span class="words" data-synonyms="pin;stick" title="">PIN</span> of the <span class="words" data-synonyms="Led;Driven" title="">LED</span> (the anode) to one <span class="words" data-synonyms="pin;stick" title="">PIN</span> of the resistor And <span class="words" data-synonyms="connect;interface" title="">interface</span> the other <span class="words" data-synonyms="end;conclusion" title="">end</span> of the resistor to GPIO <span class="words" data-synonyms="pin;stick" title="">PIN</span> 5 of the ESP8266, and the other <span class="words" data-synonyms="end;conclusion" title="">end</span> of the <span class="words" data-synonyms="Led;Driven" title="">LED</span> to the ground <span class="words" data-synonyms="now;presently" title="">now</span> <span class="words" data-synonyms="going to;getting to;progressing to;attending to;reaching to;planning to;aiming to" title="">going to</span> light up the <span class="words" data-synonyms="Led;Driven" title="">LED</span> by programming the ESP8266 chip</span></p><h2>Code Control LED Espo8266:</h2><pre class="EnlighterJSRAW" data-enlighter-language="generic">#include <ESP8266WiFi.h>
void setup() {
// Set GPIO 5 as output
pinMode(5, OUTPUT);
// Set GPIO 5 on a HIGH state
digitalWrite(5, HIGH);
}
void loop() {
}</pre><p>This code <span class="words" data-synonyms="simply;basically;essentially" title="">simply</span> sets the GPIO <span class="words" data-synonyms="pin;stick" title="">PIN</span> as an <span class="words" data-synonyms="output;yield" title="">Output</span>, <span class="words" data-synonyms="and then;and after that" title="">and after that</span> applies a HIGH state to it. The <span class="words" data-synonyms="High;Tall" title="">High</span> state <span class="words" data-synonyms="means;implies" title="">means</span> that the <span class="words" data-synonyms="pin;stick" title="">PIN</span> is <span class="words" data-synonyms="active;dynamic" title="">active</span>, <span class="words" data-synonyms="and that;which" title="">which </span>positive voltage (3.3V) is <span class="words" data-synonyms="applied;connected" title="">connected</span> to the <span class="words" data-synonyms="pin;stick" title="">PIN</span>. A <span class="words" data-synonyms="Low;Moo" title="">Low</span> state would mean that the output is at 0V.</p><div> <span class="words" data-synonyms="You can;You'll;You'll be able to" title="">You'll be able</span> <span class="words" data-synonyms="now;presently" title="">presently</span> to <span class="words" data-synonyms="copy;duplicate" title="">copy</span> this code and <span class="words" data-synonyms="paste;glue" title="">paste</span> it into the Arduino IDE. You <span class="words" data-synonyms="should;ought to" title="">should</span> <span class="words" data-synonyms="immediately;instantly;quickly;promptly" title="">quickly</span> see that the LED lights up. <span class="words" data-synonyms="You can;You'll;You'll be able to" title="">You'll be able</span> to close it down <span class="words" data-synonyms="again;once more" title="">once more</span> by <span class="words" data-synonyms="using;utilizing" title="">using</span> digitalWrite(5, <span class="words" data-synonyms="Low;Moo" title="">Low</span>) <span class="words" data-synonyms="in the;within the" title="">within the</span> code. <span class="words" data-synonyms="You could;You'll;You may" title="">You may</span> also, for <span class="words" data-synonyms="example;case;illustration" title="">example</span>, <span class="words" data-synonyms="modify;alter;adjust" title="">alter</span> the code so the ESP8266 switches the <span class="words" data-synonyms="Led;Driven" title="">LED</span> on and off every second.</div><h2>Visit to get more tutorials on IoT project</h2><h2 class="page-title is-large uppercase"><a href="https://www.mechatronicslab.net/category/internet-of-things/" rel="noopener noreferrer" target="_blank">INTERNET OF THINGS</a></h2><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1786468026" style="border: none; margin: 0px;" width="1" /></span></p>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-87016955580151840712022-03-11T09:46:00.000+06:002022-03-11T09:46:00.144+06:00How to Debouncing a Button Press in Raspberry pi<h1 style="text-align: left;"><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="Sometimes;In some cases;Now and then;Some of the time"><font face="arial, helvetica, sans-serif">How to Debouncing a Button Press in Raspberry pi</font></span></span></h1><p><span style="font-family: arial, helvetica, sans-serif;"><span class="words" data-synonyms="Sometimes;In some cases;Now and then;Some of the time">In some cases,</span> <span class="words" data-synonyms="when you;once you;after you">after you</span> press the button on a switch, the <span class="words" data-synonyms="expected;anticipated">anticipated</span> action happens more than once, <span class="words" data-synonyms="because;since">since</span> the switch contacts bounce. In that case, you <span class="words" data-synonyms="want;need">need</span> to write code to de-bounce the switch. Today I show you How to Debouncing a Button Press in Raspberry pi. </span></p><h2><span style="font-family: arial, helvetica, sans-serif;">Components Required :</span></h2><div><p><span style="font-family: arial, helvetica, sans-serif;">1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /></span></p><p><span style="font-family: arial, helvetica, sans-serif;">2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><div><span style="font-family: arial, helvetica, sans-serif;">5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></span></div><p><span style="font-family: arial, helvetica, sans-serif;">5.<a href="https://amzn.to/2MV2v5s" rel="noopener noreferrer" target="_blank">Push Button Switch</a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/6x6x4-5mm-Momentary-Tactile-Button-Switch/dp/B008DS1GY0/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=8443be8b71b0e38a1b7b9599f06fc87c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B008DS1GY0&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><p><span style="font-family: arial, helvetica, sans-serif;">6. <a href="https://amzn.to/30b8drV" rel="noopener noreferrer" target="_blank"> 5mm LED </a></span><br /><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/MCIGICM-Circuit-Assorted-Science-Experiment/dp/B07PG84V17/ref=as_li_ss_il?dchild=1&keywords=5mm+LED&qid=1591360832&sr=8-3&linkCode=li2&tag=sarful-20&linkId=1fb0a8a88cb779442b0b7b349d240761&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07PG84V17&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a></span></p><h3><span style="font-family: arial, helvetica, sans-serif;">This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</span></h3><h3><span style="font-family: arial, helvetica, sans-serif;"><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></span></h3><p><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" /></span></p><h3><span style="font-family: arial, helvetica, sans-serif;">Circuit diagram Debouncing Raspberry pi:</span></h3><p><span style="font-family: arial, helvetica, sans-serif;">shows how to connect a tactile push switch and LED, using a breadboard and jumper wires</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><img alt="push switch and LED to a Raspberry Pi" class="alignnone size-medium wp-image-617" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/DeBounceButton_bb-218x300.png" width="218" /></span></p><h2><span style="font-family: arial, helvetica, sans-serif;">Code-1</span></h2><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
switch_pin = 18
led_pin = 23
GPIO.setup(switch_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(led_pin, GPIO.OUT)
led_state = False
old_input_state = True # pulled-up
while True:
new_input_state = GPIO.input(switch_pin)
if new_input_state == False and old_input_state == True:
led_state = not led_state
old_input_state = new_input_state
GPIO.output(led_pin, led_state)
</span></pre><p><span style="font-family: arial, helvetica, sans-serif;">The <span class="words" data-synonyms="problem;issue" title="">issue</span> is that <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> the switch contacts bounce, it is <span class="words" data-synonyms="just;fair" title="">just</span> as <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in case</span> the switch was <span class="words" data-synonyms="pressed;squeezed" title="">pressed</span> more than once in <span class="words" data-synonyms="very;exceptionally" title="">exceptionally</span> <span class="words" data-synonyms="rapid;fast;quick" title="">fast</span> <span class="words" data-synonyms="succession;progression" title="">succession</span>. <span class="words" data-synonyms="If;On the off chance that;In the event that;In case" title="">In case</span> they bounce an odd number of times, <span class="words" data-synonyms="then;at that point" title="">at that point,</span> things will <span class="words" data-synonyms="seem;appear" title="">appear</span> to be <span class="words" data-synonyms="Ok;Alright" title="">Alright</span>. But <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in case</span> they bounce an even number of times, the two <span class="words" data-synonyms="events;occasions" title="">events</span> will <span class="words" data-synonyms="toggle;flip" title="">toggle</span> the <span class="words" data-synonyms="Led;Driven" title="">Led</span> on and then straight back off again. You <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">have to ignore</span> any changes after the switch is <span class="words" data-synonyms="pressed;squeezed" title="">pressed</span> for a short amount of time, <span class="words" data-synonyms="while;whereas" title="">whereas</span> the switch finishes bouncing. The <span class="words" data-synonyms="quick;fast;speedy" title="">fast</span> and <span class="words" data-synonyms="easy;simple" title="">simple</span> way to do <span class="words" data-synonyms="this is;this is often;typically;usually;this can be" title="">usually </span>to <span class="words" data-synonyms="introduce;present" title="">introduce</span> a <span class="words" data-synonyms="short;brief" title="">short</span> <span class="words" data-synonyms="sleep;rest" title="">sleep</span> after the button press is <span class="words" data-synonyms="detected;recognized;identified" title="">recognized</span> by adding time.sleep command of, say, 0.2 seconds. This delay is <span class="words" data-synonyms="probably;likely" title="">probably</span> much higher than <span class="words" data-synonyms="necessary;fundamental;essential;vital" title="">vital</span>, strictly speaking. <span class="words" data-synonyms="You may;You'll;You will" title="">You'll </span><span class="words" data-synonyms="find;discover" title="">discover</span> <span class="words" data-synonyms="that you;that you simply;merely;that you just;simply" title="">that you just</span> can <span class="words" data-synonyms="reduce;diminish;decrease">decrease</span> this <span class="words" data-synonyms="considerably;impressively;significantly" title="">impressively</span></span></p><h3><span style="font-family: arial, helvetica, sans-serif;">Code-2</span></h3><pre class="EnlighterJSRAW" data-enlighter-language="generic"><span style="font-family: arial, helvetica, sans-serif;">import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
switch_pin = 18
led_pin = 23
GPIO.setup(switch_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(led_pin, GPIO.OUT)
led_state = False
old_input_state = True # pulled-up
while True:
new_input_state = GPIO.input(switch_pin)
if new_input_state == False and old_input_state == True:
led_state = not led_state
time.sleep(0.2)
old_input_state = new_input_state
GPIO.output(led_pin, led_state)
</span></pre><h2><span style="font-family: arial, helvetica, sans-serif;">If you want to know more about raspberry pi then click on the link below</span></h2><h4 class="page-title is-large uppercase"><span style="font-family: arial, helvetica, sans-serif;"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></span></h4></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-61966428580298629632022-03-04T21:33:00.001+06:002022-03-04T21:33:00.158+06:00Getting Started Internet of Thing (IoT) Using NodeMcu | IoT Tutorial<h1 style="text-align: left;"><span style="color: black;">Getting Started Internet of Thing (IoT) Using NodeMcu | IoT Tutorial</span></h1><p><span style="color: black;">We are, to begin with going to see getting Started Internet of Thing(IoT) Using NodeMcu for your IoT project. There are many IoT modules accessible within the market and it is very simple to induce misplaced with all the choices available.</span></p><p><span style="color: black;"><span data-synonyms="The first;The primary" title="">The first</span> one <span data-synonyms="that you;that you simply;merely;that you just;simply" title="">that you simply</span> have <span data-synonyms="probably;likely" title="">likely</span> <span data-synonyms="heard;listened" title="">listened</span> of is the <span data-synonyms="small;little" title="">little</span> ESP8266 Serial Wireless Transceiver module:</span><br /><span style="color: black;"><a href="https://www.amazon.com/DIYmall-ESP8266-ESP-01S-Serial-Transceiver/dp/B00O34AGSU/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=6b4d468809ebd4c5ab9fa6a43b4d295e&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B00O34AGSU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B00O34AGSU" style="border: none; margin: 0px;" width="1" /></span></p><p><span style="color: black;">This module is <span class="words" data-synonyms="the most;the foremost" title="">the foremost</span> <span class="words" data-synonyms="famous;popular;celebrated" title="">popular</span> one <span class="words" data-synonyms="as it;because it">because it</span> is <span class="words" data-synonyms="really;truly" title="">truly</span> <span class="words" data-synonyms="small;little">little</span> and <span class="words" data-synonyms="only;as it were" title="">as it cost</span> $6. However, the number of <span class="words" data-synonyms="accessible;open;available" title="">open</span> GPIO pins (input/output pins) is <span class="words" data-synonyms="quite;very" title="">very</span> <span class="words" data-synonyms="limited;restricted;constrained" title="">constrained</span>. It is also difficult to plug it into a standard breadboard. If you <span class="words" data-synonyms="choose;select" title="">select</span> this module, you won't be able to do the projects using analog sensors, as the analog input <span class="words" data-synonyms="is not;isn't" title="">isn't </span><span class="words" data-synonyms="accessible;open;available" title="">available</span>.</span></p><p><span style="color: black;"><span class="words" data-synonyms="You can;You'll;You'll be able to" title="">You'll </span><span class="words" data-synonyms="find;discover" title="">discover</span> more <span class="words" data-synonyms="information;data" title="">data</span> <span class="words" data-synonyms="about;approximately;almost;around" title="">almost</span> this module at <a href="https://nurdspace.nl/images/e/e0/ESP8 266_Specifications_English.pdf" rel="noopener noreferrer" target="_blank">https://nurdspace.nl/images/e/e0/ESP8</a></span><span style="color: black; font-size: 14.4px;"> </span><span style="color: black; font-size: 14.4px;">266_Specifications_English.pdf</span></p><p><span style="color: black;">For some limitation in the ESP8266 Serial Wireless Transceiver module,, we can use NodeMcu development kit</span><br /><span style="color: black;"><a href="https://www.amazon.com/seeedstudio-NodeMCU-based-ESP8266-development/dp/B010NBDEC6/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=cefe39b5c3e24cca6c4ad51df8a33af8&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B010NBDEC6&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B010NBDEC6" style="border: none; margin: 0px;" width="1" /></span></p><p><span style="color: black;">The NodeMCU ESP8266 <span class="words" data-synonyms="development;improvement;advancement" title="">development</span> board comes with the ESP-12E module containing ESP8266 chip having Tensilica Xtensa 32-bit LX106 RISC <span class="words" data-synonyms="microprocessor;chip" title="">microprocessor</span>. This <span class="words" data-synonyms="microprocessor;chip" title="">microprocessor</span> <span class="words" data-synonyms="supports;bolsters;underpins" title="">underpins</span> RTOS and <span class="words" data-synonyms="operates;works" title="">works</span> at 80MHz to 160 MHz <span class="words" data-synonyms="adjustable;movable;flexible" title="">movable</span> clock <span class="words" data-synonyms="frequency;recurrence" title="">recurrence</span>.</span></p><p><span style="color: black;">ESP8266 has 128 KB <span class="words" data-synonyms="Ram;Smash;Slam" title="">Ram</span> and 4MB of <span class="words" data-synonyms="Flash;Streak" title="">Flash</span> memory to store <span class="words" data-synonyms="data;information" title="">information</span> and programs. Its <span class="words" data-synonyms="high;tall" title="">tall</span> <span class="words" data-synonyms="processing;handling;preparing" title="">preparing</span> <span class="words" data-synonyms="power;control" title="">power</span> with in-built Wi-Fi / Bluetooth and <span class="words" data-synonyms="Deep;Profound" title="">Profound</span> <span class="words" data-synonyms="Sleep;Rest" title="">Rest</span> <span class="words" data-synonyms="Operating;Working" title="">Working</span> <span class="words" data-synonyms="features;highlights" title="">highlights</span> make it <span class="words" data-synonyms="ideal;perfect" title="">perfect</span> internet of Thing NodeMcu projects. NodeMCU can be <span class="words" data-synonyms="powered;fueled">fueled</span> <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> a <span class="words" data-synonyms="Micro;Smaller scale;Small scale;Miniaturized scale" title="">Miniaturized scale</span> USB jack and VIN Pin (<span class="words" data-synonyms="External;Outside">Outside</span> Supply Pin). It <span class="words" data-synonyms="supports;bolsters;underpins">underpins</span> UART, SPI, and I2C interface. The NodeMCU <span class="words" data-synonyms="Development;Improvement;Advancement" title="">Development</span> Board can be <span class="words" data-synonyms="easily;effortlessly;effectively" title="">easily</span> <span class="words" data-synonyms="programmed;modified">modified</span> with Arduino IDE since it is <span class="words" data-synonyms="easy;simple" title="">easy</span> to <span class="words" data-synonyms="use;utilize" title="">use</span>.</span></p><h2><span style="color: black;">NodeMCU ESP8266 Specifications & Features</span></h2><p><span style="color: black;">Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106</span><br /><span style="color: black;">Operating Voltage: 3.3V</span><br /><span style="color: black;">Input Voltage: 7-12V</span><br /><span style="color: black;">Digital I/O Pins (DIO): 16</span><br /><span style="color: black;">Analog Input Pins (ADC): 1</span><br /><span style="color: black;">UARTs: 1</span><br /><span style="color: black;">SPIs: 1</span><br /><span style="color: black;">I2Cs: 1</span><br /><span style="color: black;">Flash Memory: 4 MB</span><br /><span style="color: black;">SRAM: 64 KB</span><br /><span style="color: black;">Clock Speed: 80 MHz</span><br /><span style="color: black;">USB-TTL based on CP2102 is included onboard, Enabling Plug n Play</span><br /><span style="color: black;">PCB Antenna</span><br /><span style="color: black;">Small Sized module to fit smartly inside your Internet of Thing NodeMcu projects</span></p><p><span style="color: black;"><img alt="NodeMCU ESP8266 Pinout" class="alignnone size-medium wp-image-595" height="200" src="https://www.mechatronicslab.net/my_uploads/2020/06/NodeMCU-ESP8266-Pinout-300x200.jpg" width="300" /></span></p><h2><span style="color: black;">Nodemcu GPIO API:</span></h2><p><span style="color: black;">This GPIO(General <span class="words" data-synonyms="Purpose;Reason">Reason</span> Input/Output) <span class="words" data-synonyms="allows;permits" title="">permits</span> us to <span class="words" data-synonyms="access;get to" title="">get to</span> pins of ESP8266, all the pins of ESP8266 <span class="words" data-synonyms="accessed;gotten to" title="">gotten to</span> <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> the command GPIO, all the <span class="words" data-synonyms="access;get to" title="">get to</span> is based on the I/O index number on the NoddMCU dev <span class="words" data-synonyms="kits;units;packs" title="">units</span>, not the <span class="words" data-synonyms="internal;inside;inner" title="">inside</span> GPIO <span class="words" data-synonyms="pin;stick" title="">pin</span>, for the <span class="words" data-synonyms="example;case;illustration" title="">case</span>, the pin ‘D7’ on the NodeMCU dev <span class="words" data-synonyms="kit;unit;pack" title="">kit</span> is mapped to the <span class="words" data-synonyms="internal;inside;inner" title="">internal</span> GPIO <span class="words" data-synonyms="pin;stick" title="">pin</span> 13, <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> you <span class="words" data-synonyms="want;need" title="">need</span> to turn ‘High’ or ‘Low’ that <span class="words" data-synonyms="particular;specific" title="">particular</span> <span class="words" data-synonyms="pin;stick" title="">pin</span> <span class="words" data-synonyms="you need;you would like;you wish" title="">you would like</span> to call the <span class="words" data-synonyms="pin;stick" title="">pin</span> number ‘7’ no the internal GPIO of the Pin. <span class="words" data-synonyms="When you;Once you;After you" title="">After you</span> are programming with <span class="words" data-synonyms="generic;non specific;bland;nonexclusive" title="">generic</span> ESP8266 this confusion will arise which <span class="words" data-synonyms="pin;stick" title="">pin</span> <span class="words" data-synonyms="needs to;must;has to;should;ought to" title="">should </span>be called <span class="words" data-synonyms="during;amid" title="">amid</span> programming, <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">on the off chance that</span> <span class="words" data-synonyms="you are;you're" title="">you' re</span><span class="words" data-synonyms="using;utilizing" title="">utilizing</span> NodeMCU dev kit, it has come prepared for working with Lua <span class="words" data-synonyms="interpreter;mediator;translator" title="">translator</span> which can <span class="words" data-synonyms="easily;effortlessly;effectively" title="">easily</span> program by looking the <span class="words" data-synonyms="pin;stick" title="">pin</span> names <span class="words" data-synonyms="associated;related" title="">related</span> on the Lua board. If <span class="words" data-synonyms="you are;you're">you're </span><span class="words" data-synonyms="using;utilizing" title="">utilizing</span> <span class="words" data-synonyms="generic;non specific;bland;nonexclusive" title="">non-specific</span> ESP8266 <span class="words" data-synonyms="device;gadget" title="">gadgets</span> or any other <span class="words" data-synonyms="vendor;merchant;seller">merchant</span> <span class="words" data-synonyms="boards;sheets" title="">sheets</span> <span class="words" data-synonyms="please;if you don't mind;it would be ideal if you;if it's not too much trouble" title="">it would be ideal if you</span> <span class="words" data-synonyms="refer;allude">allude</span> to the table <span class="words" data-synonyms="below;underneath">underneath</span> to know which IO <span class="words" data-synonyms="index;list;record;file">list</span> is <span class="words" data-synonyms="associated;related" title="">related</span> to the <span class="words" data-synonyms="internal;inside;inner">inside</span> GPIO of ESP8266.</span></p><p><span style="color: black;"><img alt="" class="alignnone size-medium wp-image-596" height="164" src="https://www.mechatronicslab.net/my_uploads/2020/06/GPIO-300x164.jpg" width="300" /></span></p><p><span style="color: black;">D0 or GPIO16 can be used only as a read and write pin, no other options like PWM/I2C are supported by this pin.</span></p><h2><span style="color: black;">gpio.mode() :</span></h2><p><span style="color: black;">This command will initialize the GPIO mode and also used for setting the input/output direction of the pin</span><br /><span style="color: black;">Syntax : gpio.mode(pin, mode)</span><br /><span style="color: black;">Pin: select any of the available gpio pins</span><br /><span style="color: black;">Mode: set the selected pin mode to input or output.</span><br /><span style="color: black;">Example: gpio.mode(7, gpio.OUTPUT)</span></p><h2><span style="color: black;">gpio.read():</span></h2><p><span style="color: black;">This command will <span class="words" data-synonyms="read;perused;examined;studied" title="">read</span> the Pin <span class="words" data-synonyms="value;esteem" title="">value</span>, whether the Pin is in <span class="words" data-synonyms="High;Tall" title="">High</span> state or Low state will be returned when <span class="words" data-synonyms="use;utilize" title="">utilizing</span> this command.</span></p><div><span style="color: black;">Syntax: gpio.read(pin)</span></div><div><span style="color: black;"> On the <span class="words" data-synonyms="function;work" title="">work</span> <span class="words" data-synonyms="type;sort" title="">sort</span> the Pin number to <span class="words" data-synonyms="read;perused;examined;studied" title="">read</span>, this will return a number based on the High or <span class="words" data-synonyms="Low;Moo" title="">Low</span> on the Pin side, <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> the Pin is in the <span class="words" data-synonyms="high;tall" title="">tall</span> state this will return 1 and <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in case</span> it is <span class="words" data-synonyms="low;moo" title="">moo</span> state this will return 0.</span></div><div><span style="color: black;">Example: gpio.read(7)</span></div><div><h2><span style="color: black;">gpio.write():</span></h2><p><span style="color: black;">This command will make the Pin to go <span class="words" data-synonyms="High;Tall" title="">High</span> or <span class="words" data-synonyms="Low;Moo" title="">Low</span>, we <span class="words" data-synonyms="use;utilize" title="">utilize</span> this command to set a Pin to go <span class="words" data-synonyms="High;Tall" title="">High</span> or <span class="words" data-synonyms="Low;Moo" title="">Low</span>, <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> you <span class="words" data-synonyms="want;need" title="">need</span> to turn on and off a <span class="words" data-synonyms="Led;Driven" title="">Driven</span> this command can be <span class="words" data-synonyms="used;utilized" title="">utilized</span> in such situations.</span></p><div><span style="color: black;">Syntax: gpio.write(pin, state)</span></div><div><span style="color: black;"> Pin: enter the <span class="words" data-synonyms="pin;stick" title="">Pin</span> <span class="words" data-synonyms="that you;that you simply;merely;that you just;simply" title="">that you simply</span> <span class="words" data-synonyms="want;need" title="">need</span> to <span class="words" data-synonyms="change;alter" title="">change</span> the state to <span class="words" data-synonyms="high;tall" title="">high</span> or Low State: <span class="words" data-synonyms="High;Tall" title="">High</span> or <span class="words" data-synonyms="Low;Moo" title="">Low</span>, gpio.HIGH or gpio.LOW</span></div><div> </div><div><span style="color: black;">Example:</span></div><div><span style="color: black;"> pin = 7</span></div><div><span style="color: black;"> gpio.mode(pin, gpio.OUTPUT)</span></div><div><span style="color: black;"> gpio.write(pin, gpio.HIGH)</span></div><div><span style="color: black;"> above program will set the D7 pin of Nodemcu to go <span class="words" data-synonyms="High;Tall" title="">High</span>, on <span class="words" data-synonyms="the first;the primary" title="">the primary</span> line <span class="words" data-synonyms="pin;stick" title="">Pin</span> is assigned to variable 7, and on the <span class="words" data-synonyms="second;moment" title="">moment</span> line ‘D7’ <span class="words" data-synonyms="pin;stick" title="">Pin</span> as set to Output and on the third line ‘D7’ <span class="words" data-synonyms="pin;stick" title="">Pin</span> has made to HIGH <span class="words" data-synonyms="which will;which can;which is able to" title="">which is able</span> <span class="words" data-synonyms="write;compose;type in" title="">type in</span> <span class="words" data-synonyms="value;esteem" title="">esteem</span> 1 to the <span class="words" data-synonyms="pin;stick" title="">Pin</span>, <span class="words" data-synonyms="which will;which can;which is able to" title="">which can</span> make to to <span class="words" data-synonyms="glow;shine;gleam" title="">gleam</span> <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> you <span class="words" data-synonyms="connect;interface" title="">interface</span> a <span class="words" data-synonyms="Led;Driven" title="">Led</span> to the <span class="words" data-synonyms="pin;stick" title="">Pin</span> ‘D7’,</span></div><h2><span style="color: black;">gpio.trig() :</span></h2><div><span style="color: black;"><span style="font-size: 14.4px;">This command act as </span><span class="words" data-synonyms="interrupt;hinder" style="font-size: 14.4px;" title="">interrupt work during</span><span style="font-size: 14.4px;"> programming, </span><span class="words" data-synonyms="using;utilizing" style="font-size: 14.4px;" title="">utilizing</span><span style="font-size: 14.4px;"> this command can cause the program to execute certain </span><span class="words" data-synonyms="function;work" style="font-size: 14.4px;" title="">work</span><span style="font-size: 14.4px;"> when the specific Pin</span><span style="font-size: 14.4px;"> is triggered, this </span><span class="words" data-synonyms="function;work" style="font-size: 14.4px;" title="">work</span><span style="font-size: 14.4px;"> will not be accessible on</span><span class="words" data-synonyms="if;on the off chance that;in the event that;in case" style="font-size: 14.4px;" title=""> the off chance that</span><span style="font-size: 14.4px;"> GPIO_INTERRPUT_ENABLE was undefined at the time of compile.</span></span></div><div><div><span style="color: black;">Syntax: gpio.trig(pin, <span class="words" data-synonyms="type;sort" title="">type</span> [, function(level)]) Choose <span class="words" data-synonyms="pin;stick" title="">Pin</span> 1 to 12, as the <span class="words" data-synonyms="pin;stick" title="">Pin</span> D0 or GPIO16 <span class="words" data-synonyms="is not;isn't" title="">isn't </span><span class="words" data-synonyms="support;bolster;back" title="">back</span> <span class="words" data-synonyms="interrupt;hinder" title="">interrupt</span> or any other function.</span></div><div><span style="color: black;">Type: “up”, “down”, “both”, “low”, “high” which <span class="words" data-synonyms="represent;speak to" title="">speak to</span> rising edge, falling edge, both edge, <span class="words" data-synonyms="low;moo" title="">low</span> level, high-level trigger mode, <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> you <span class="words" data-synonyms="want;need" title="">need</span> to <span class="words" data-synonyms="choose;select" title="">select</span> the <span class="words" data-synonyms="interrupt;hinder" title="">interrupt</span> to occur when the <span class="words" data-synonyms="pin;stick" title="">Pin</span> goes <span class="words" data-synonyms="low;moo" title="">low</span>, you <span class="words" data-synonyms="should;ought to" title="">ought to</span> <span class="words" data-synonyms="choose;select" title="">select</span> low as <span class="words" data-synonyms="type;sort" title="">type</span>, <span class="words" data-synonyms="which means;which suggests;which implies" title="">which implies</span> the <span class="words" data-synonyms="pin;stick" title="">Pin</span> will be actively <span class="words" data-synonyms="high;tall">tall</span> when the <span class="words" data-synonyms="pin;stick" title="">Pin</span> goes to <span class="words" data-synonyms="low;moo" title="">low</span> state it <span class="words" data-synonyms="should;ought to" title="">ought to</span> <span class="words" data-synonyms="stop;halt" title="">halt</span> the <span class="words" data-synonyms="function;work">work</span> and call the function to execute <span class="words" data-synonyms="during;amid" title="">amid</span> interrupt.</span></div><div> </div><div><span style="color: black;">Function(level) callback <span class="words" data-synonyms="function;work" title="">work</span> when triggered.</span></div><div> </div><div><span style="color: black;"> Example:</span></div><div><span style="color: black;">local <span class="words" data-synonyms="pin;stick" title="">Pin</span> = 5 function pinValue () print(‘The <span class="words" data-synonyms="pin;stick" title="">Pin</span> value’..gpio.read(pin)) end</span></div><div><span style="color: black;">gpio.mode(pin, gpio.INT)</span></div><div><span style="color: black;">gpio.trig(pin, ‘HIGH’, pinValue)</span></div></div></div><h2><span style="color: black;">adc.read() :</span></h2><div><span style="color: black;">samples the ADC.</span><br /><span style="color: black;">Syntax : adc.read(channel)</span><br /><span style="color: black;">There is only one channel available with esp devices so always choose 0, may in future devices we can expect more ADC with ESP chips. This will return the sampled value in</span><br /><span style="color: black;">number.</span><br /><span style="color: black;">Example : val = adc.read(0)</span></div><div> </div><div><span style="color: black;">file.open()</span><br /><span style="color: black;">This function allows to open any file in the system for editing or creating a new file, this function access to all the existing files in the system if we want to create any new file using this function can only be done, for creating a new file, we need to open a file in write mode. All the file.open() function must be closed with the file. close function.</span></div><div> </div><div><span style="color: black;">Syntax: file.open(filename, mode)</span><br /><span style="color: black;">Filename, the file to be opened. There are different modes available to work on the files.</span><br /><span style="color: black;">“r”: read mode (default mode in the file access)</span><br /><span style="color: black;">“w”: write mode</span><br /><span style="color: black;">“a”: append mode ( adding data to existing file)</span><br /><span style="color: black;">“r+”: update mode. All previous data are preserved</span><br /><span style="color: black;">“w+”: update mode, all previous data is erased</span><br /><span style="color: black;">“a+”: append update mode, previous data is preserved, writing is only allowed at the end of the file.</span></div><div><span style="color: black;">Example</span><br /><span style="color: black;">file.open(“init.lua”, “r”)</span><br /><span style="color: black;">print(file.readline())</span><br /><span style="color: black;">file.close()</span></div><h2><span style="color: black;">Wi-Fi API</span></h2><div><div><span style="color: black;">Very <span class="words" data-synonyms="important;critical;imperative;vital" title="">imperative</span> API’s <span class="words" data-synonyms="available;accessible" title="">available</span> with NodeMCU firmware, this <span class="words" data-synonyms="allows;permits" title="">permits</span> NodeMCU dev kit or ESP8266 chips <span class="words" data-synonyms="to connect;to associate;to put through (telephone)" title="">to connect</span> with other <span class="words" data-synonyms="devices;gadgets" title="">devices</span> and <span class="words" data-synonyms="access;get to" title="">get to</span> <span class="words" data-synonyms="information;data" title="">data</span> from <span class="words" data-synonyms="internet;web" title="">web</span> and allow a <span class="words" data-synonyms="user;client" title="">client</span> to control a <span class="words" data-synonyms="device;gadget" title="">device</span> from any <span class="words" data-synonyms="part;portion" title="">part</span> of the world, on-chip Wi-Fi SoC is what made the ESP most <span class="words" data-synonyms="popular;prevalent;well known" title="">popular</span> among <span class="words" data-synonyms="hobbyist;specialist" title="">specialist</span> and it <span class="words" data-synonyms="grows;develops" title="">develops</span> to the <span class="words" data-synonyms="phenomenal;marvelous;extraordinary;amazing" title="">marvelous</span> rate at this time. wifi.getchannel()</span></div><div><span style="color: black;">This <span class="words" data-synonyms="function;work" title="">work</span> gets the current wifi channel <span class="words" data-synonyms="that is;that's" title="">that's </span><span class="words" data-synonyms="currently;right now;as of now" title="">as of now</span> <span class="words" data-synonyms="connected;associated" title="">associated</span>. When this function called in the program this will return the wifi channel name.</span></div><div><span style="color: black;"> Syntax: wifi.getchannel()</span></div><div><span style="color: black;"> Example: print(wifi.getchannel())</span></div></div><h2><span style="color: black;">PWM API</span></h2><div><span style="color: black;">Pulse Width Modulation API allows us to use any of the I/O pin as a PWM pin except the D0 pin of NodeMCU DEV KIT, this API will be very useful when controlling LED’s, Motors and many more devices which require PWM functions to do crazy things.</span><br /><span style="color: black;">pwm.setup() This function allows setting a pin to PWM mode, only 6 pins can be set to PWM mode at the most case.</span><br /><span style="color: black;">Syntax: pwm.setup(pin, clock, duty)</span><br /><span style="color: black;">Pins from 1 to 12 can be chosen for PWM</span><br /><span style="color: black;">Clock frequency should be set between 1- 1000, PWM frequency.</span><br /><span style="color: black;">Duty cycle should be between 0-1023, max is 1023(10bit)</span><br /><span style="color: black;">Example: pwm.setup(1, 100, 512) this example set the ‘D1’ pin as pwm output and frequency is 100 hz and duty cycle is 512.</span><br /><span style="color: black;">pwm.start()</span></div><div><span style="color: black;">This function starts the PWM, the waveform is applied to the GPIO pin.</span><br /><span style="color: black;">Syntax: pwm.start(pin)</span><br /><span style="color: black;">pwm.stop()</span><br /><span style="color: black;">This function pause the output of the PWM waveform.</span><br /><span style="color: black;">Syntax: pwm.stop(pin)</span><br /><span style="color: black;">pwm.setduty()</span><br /><span style="color: black;">This function allows to set the duty cycle for a pin.</span><br /><span style="color: black;">Syntax: pwm.setduty(pin, duty)</span></div><div><span style="color: black;">Example:</span></div><div><span style="color: black;">pwm.setup(1, 500, 512)</span><br /><span style="color: black;">pwm.setup(2, 500, 512)</span><br /><span style="color: black;">pwm.setup(3, 500, 512)</span><br /><span style="color: black;">pwm.start(1)</span><br /><span style="color: black;">pwm.start(2)</span><br /><span style="color: black;">pwm.start(3)</span><br /><span style="color: black;">function led(r, g, b)</span><br /><span style="color: black;">pwm.setduty(1, g)</span><br /><span style="color: black;">pwm.setduty(2, b)</span><br /><span style="color: black;">pwm.setduty(3, r)</span><br /><span style="color: black;">end</span><br /><span style="color: black;">led(512, 0, 0) — set led to red</span><br /><span style="color: black;">led(0, 0, 512) — set led to blue.</span></div><div> </div><div>Summary:</div><div>Today we have discussed these issues for this important Internet of Thing NodeMcu Project Making. If you want more Project internet of Thing NodeMcu, you must learn more from the internet in addition to the above. There are several Internet of Thing NodeMcu ideas given in this <a href="https://www.mechatronicslab.net/iot-projects/" rel="noopener noreferrer" target="_blank">link </a>From here you can get ideas about the Internet of Thing NodeMcu.</div><div> </div><h2><span style="color: black;">That book helped me create this tutorial</span></h2><div><span style="color: black;"><a href="https://www.amazon.com/How-program-ESP8266-Lua-Getting-ebook/dp/B01BLN6EDG/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=223daccae0403a86ac80adecc191ddf2&language=en_US" rel="noopener noreferrer" style="color: black;" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01BLN6EDG&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01BLN6EDG" style="border: none; margin: 0px;" width="1" /></span></div><div> </div><h2><span style="color: black;">Visit to get more tutorials on IoT project</span></h2><h2 class="page-title is-large uppercase"><span style="color: black;"><a href="https://www.mechatronicslab.net/category/internet-of-things/" rel="noopener noreferrer" style="color: black;" target="_blank">INTERNET OF THINGS</a></span></h2><h2> </h2>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-71384716657473307952022-02-25T21:30:00.001+06:002022-02-25T21:30:00.151+06:00Installing the Arduino IDE for the ESP8266 | IoT Tutorial<h1 style="text-align: left;">Installing the Arduino IDE for the ESP8266 | IoT Tutorial</h1><p>Today I show Installing the Arduino IDE for the ESP8266 Step by step complete Process. Fast you have to need Download Arduino software from here <a href="http://www.arduino.cc/en/main/software" rel="noopener noreferrer" target="_blank">http://www.arduino.cc/en/main/software</a>. Then set up a normal way. After Finish Setup you have to need to chack up the drive if the driver has installed properly then ok <span data-synonyms="Now;Presently" title="">Now</span>, <span data-synonyms="you need;you would like;you wish" title="">you would like</span> <span data-synonyms="to take;to require" title="">to require</span> a <span data-synonyms="follow;take after" title="">take after</span> steps to be able to <span data-synonyms="configure;arrange;design" title="">configure</span> the ESP8266 with the Arduino IDE:</p><p>1. Start the Arduino IDE and open the Preferences window.<br />2. Enter the following URL into the Additional Board Manager URLs field:http://arduino.esp8266.com/stable/package_esp8266com_index.json</p><p><img alt="Additional Board Manager URLs" class="alignnone size-medium wp-image-609" height="179" src="https://www.mechatronicslab.net/my_uploads/2020/06/Additional-Board-Manager-URLs-300x179.jpg" width="300" /></p><p>3. Open Boards Manager from the Tools | Board menu and install the esp8266 platform as shown here and install :</p><p><img alt="" class="alignnone size-medium wp-image-610" height="168" src="https://www.mechatronicslab.net/my_uploads/2020/06/Install-ESP-Board-300x168.jpg" width="300" /></p><h2>Connecting your module to your Wi-Fi network:</h2><p><span class="words" data-synonyms="Now;Presently" title="Click to edit and show the other synonyms">Now</span>, we are <span class="words" data-synonyms="going to;getting to;progressing to;attending to;reaching to;planning to;aiming to" title="">going to</span> check whether the ESP8266 and the Arduino IDE are working correctly, and <span class="words" data-synonyms="connect;interface" title="">interface</span> your chip to your <span class="words" data-synonyms="local;neighborhood;nearby" title="">local</span> Wi-Fi network.</p><div><p>To do so, let's</p><pre class="EnlighterJSRAW" data-enlighter-language="generic">// Import required libraries
#include <ESP8266WiFi.h>
// WiFi parameters
const char* ssid = "Mechatronics";
const char* password = "Password";
void setup(void)
{
// Start Serial
Serial.begin(115200);
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
}</pre><p>perform the following steps:</p></div><div> 1. First, we <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">got to</span> write the code <span class="words" data-synonyms="and then;and after that" title="">and after that</span> <span class="words" data-synonyms="upload;transfer" title="">transfer</span> it to the board. The code is simple; we just <span class="words" data-synonyms="want;need" title="">need</span> <span class="words" data-synonyms="to connect;to associate;to put through (telephone)" title="">to connect</span> to the <span class="words" data-synonyms="local;neighborhood;nearby" title="">local</span> Wi-Fi <span class="words" data-synonyms="network;organize;arrange" title="">network</span> and print the IP address of the board. <span class="words" data-synonyms="This is;This is often;Typically;Usually;This can be" title="">This is often</span> the code <span class="words" data-synonyms="to connect;to associate;to put through (telephone)" title="">to connect</span> to the <span class="words" data-synonyms="network;organize;arrange" title="">network</span>:</div><div><p><span class="words" data-synonyms="You can;You'll;You'll be able to" title="">You'll </span><span class="words" data-synonyms="simply;basically;essentially" title="">basically</span> <span class="words" data-synonyms="copy;duplicate" title="">copy</span> the lines of the <span class="words" data-synonyms="preceding;going before" title="">going before</span> code <span class="words" data-synonyms="and then;and after that" title="">and after that</span> <span class="words" data-synonyms="paste;glue" title="">paste</span> them into the ESP8266 Arduino IDE <span class="words" data-synonyms="that you;that you simply;merely;that you just;simply" title="Click to edit and show the other synonyms">that you</span> downloaded <span class="words" data-synonyms="earlier;prior" title="">earlier</span>. Of course, put your own Wi-Fi <span class="words" data-synonyms="name;title" title="">title</span> and <span class="words" data-synonyms="password;secret word;watchword" title="">password</span> <span class="words" data-synonyms="in the;within the" title="">within the</span> code. <span class="words" data-synonyms="Save;Spare" title="">Save</span> this <span class="words" data-synonyms="file;record" title="">record</span> with a <span class="words" data-synonyms="name;title" title="">title</span> of your choice</p><div> </div><div>. 2. <span class="words" data-synonyms="Now;Presently" title="">Now</span>, <span class="words" data-synonyms="navigate;explore" title="">explore</span> to <span class="words" data-synonyms="Tools;Devices;Instruments;Apparatuses" title="">Tools</span> | <span class="words" data-synonyms="Boards;Sheets" title="">Boards</span> and select Generic ESP8266 Module. Also, select <span class="words" data-synonyms="the correct;the right;the proper" title="">the correct</span> Serial <span class="words" data-synonyms="port;harbour" title="">port</span> that <span class="words" data-synonyms="corresponds;compares" title="">compares</span> to the FTDI converter that you are using.</div><div> </div><div>3. After that, we <span class="words" data-synonyms="need to;got to;have to be compelled to;ought to" title="">have to be</span> put the board <span class="words" data-synonyms="in the;within the" title="">within the</span> bootloader mode, so we can program it. To do so, <span class="words" data-synonyms="connect;interface" title="">interface</span> the <span class="words" data-synonyms="pin;stick" title="">pin</span> GPIO to the ground, <span class="words" data-synonyms="via;through;by means of" title="">by means of</span> the cable we plugged into GPIO 0. <span class="words" data-synonyms="Then;At that point" title="">At that point</span>, <span class="words" data-synonyms="power;control" title="">control</span> cycle the board by <span class="words" data-synonyms="switching;exchanging" title="">exchanging</span> the power supply off <span class="words" data-synonyms="and then;and after that" title="">and after that</span> on again.</div><div> </div><div>4. <span class="words" data-synonyms="Now;Presently" title="">Now</span>, <span class="words" data-synonyms="upload;transfer" title="">transfer</span> the code to the board and open the Serial <span class="words" data-synonyms="monitor;screen" title="">screen</span> when this is done. Set the Serial <span class="words" data-synonyms="monitor;screen" title="">screen</span> speed to 115200. <span class="words" data-synonyms="Now;Presently" title="">Now</span>, <span class="words" data-synonyms="disconnect;detach;disengage" title="">disconnect</span> the cable between GPIO and GND and <span class="words" data-synonyms="power;control" title="">power</span> cycle the board <span class="words" data-synonyms="again;once more" title="">once more</span>. You <span class="words" data-synonyms="should;ought to" title="">ought to</span> see the <span class="words" data-synonyms="following;taking after" title="">taking after</span> message:</div><div><img alt="" class="alignnone size-medium wp-image-611" height="179" src="https://www.mechatronicslab.net/my_uploads/2020/06/ip-show-300x179.jpg" width="300" /></div><div>Now Complet to Installing Arduino IDE in ESP8266 Congrsulation</div><div> </div></div><h2>Visit to get more tutorials on IoT project</h2><h2 class="page-title is-large uppercase"><a href="https://www.mechatronicslab.net/category/internet-of-things/" rel="noopener noreferrer" target="_blank">INTERNET OF THINGS</a></h2>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0tag:blogger.com,1999:blog-4417693449812870969.post-82565407786578420512022-02-18T09:54:00.001+06:002022-02-18T09:54:00.158+06:00How to Connecting a Push Switch in Raspberry pi<h1 style="text-align: left;">How to Connecting a Push Switch in Raspberry pi</h1>You want to connect a switch to your Raspberry Pi so that when you press it, Today i show you How to Connecting a Push Switch in raspberry pi
<h3>Push Switch:</h3>
<em>Photo by:<a href="https://components101.com/switches/push-button#:~:text=Push%20Button%20Switch&text=Push%20buttons%20allow%20us%20to,the%20SCR%20by%20gate%20terminal." rel="noopener noreferrer" target="_blank">https://components101.com/</a></em><div>
<img alt="Push-button-Pinout" class="alignnone size-medium wp-image-591" height="184" src="https://www.mechatronicslab.net/my_uploads/2020/06/Push-button-Pinout-300x184.gif" width="300" /> </div><div> Push-Buttons are normally-open tactile switches. Push buttons allow us to power the circuit or make any particular connection only when we press the button. Simply, it makes the circuit connected when pressed and breaks when released. A push-button is also used for triggering of the SCR by gate terminal.
<h2>Components Required :</h2>
<div>
1.<a href="https://amzn.to/30CuX4j" rel="noopener noreferrer" target="_blank">Raspberry pi</a></div><div>
<a href="https://www.amazon.com/Raspberry-Model-2019-Quad-Bluetooth/dp/B07TD42S27/ref=as_li_ss_il?crid=1LTDDS9HKXRQU&dchild=1&keywords=raspberry+pi+4&qid=1592023138&s=electronics&sprefix=raspberry,stripbooks-intl-ship,408&sr=1-1&linkCode=li2&tag=sarful-20&linkId=1c9a74126719ba78c4a70147525a85c8&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07TD42S27&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B07TD42S27" width="1" /> </div><div> 2.<a href="https://amzn.to/3hattUC" rel="noopener noreferrer" target="_blank">Breadboard</a></div><div>
<a href="https://www.amazon.com/MCIGICM-Breadboard-Solderless-Prototype-Protoboard/dp/B07ZLLGW69/ref=as_li_ss_il?dchild=1&keywords=breadboard&qid=1591713794&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyRk1SSk82VzY2MTlLJmVuY3J5cHRlZElkPUEwNjkzMDU4MkdEMjk1RFBLQTY4OCZlbmNyeXB0ZWRBZElkPUEwOTE5MDY4QlhSNTZYUzIxNU5IJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=ddab21d4186dbf9b42343ca535ff9348&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07ZLLGW69&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a> </div><div> 3. <a href="https://amzn.to/2Yh9OK9" rel="noopener noreferrer" target="_blank">Connecting wire</a></div><div>
<a href="https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=as_li_ss_il?dchild=1&keywords=connecting+wire&qid=1591713657&sr=8-2&linkCode=li2&tag=sarful-20&linkId=480327a004dc9ad1de2502ef71c38142&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B07GD2BWPY&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a>
<div>5.<a href="https://amzn.to/2XOd3Zt" rel="noopener noreferrer" target="_blank"> Power Supply</a> </div><div><a href="https://www.amazon.com/NorthPada-Raspberry-Supply-Charger-Adapter/dp/B01N336XEU/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+Power+Supply&qid=1591023680&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExTVhEWFgyQUNZUzNUJmVuY3J5cHRlZElkPUExMDQwNDAxM0RFSzQ3NTk0WFRBWiZlbmNyeXB0ZWRBZElkPUEwMjQxODU4OUM5UVRMR0VYMldQJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==&linkCode=li2&tag=sarful-20&linkId=9f77e3fa477583d05d36cfb5ae86b98b&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B01N336XEU&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=B01N336XEU" width="1" /></div>
5.<a href="https://amzn.to/2MV2v5s" rel="noopener noreferrer" target="_blank">Push Button Switch</a></div><div>
<a href="https://www.amazon.com/6x6x4-5mm-Momentary-Tactile-Button-Switch/dp/B008DS1GY0/ref=as_li_ss_il?ie=UTF8&linkCode=li2&tag=sarful-20&linkId=8443be8b71b0e38a1b7b9599f06fc87c&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B008DS1GY0&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a>
<h3>This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions</h3>
<h3><a href="https://amzn.to/3fwoHiX" rel="noopener noreferrer" target="_blank">Raspberry Pi Cookbook</a></h3>
<a href="https://www.amazon.com/Raspberry-Pi-Cookbook-Software-Solutions/dp/1492043222/ref=as_li_ss_il?dchild=1&keywords=raspberry+pi+4&qid=1592023631&s=books&sr=1-1&linkCode=li2&tag=sarful-20&linkId=56e1bdaf33c43ae42fe87daf90f8aeb4&language=en_US" rel="noopener noreferrer" target="_blank"><img border="0" src="https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1492043222&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=sarful-20&language=en_US" /></a><img alt="" border="0" height="1" src="https://ir-na.amazon-adsystem.com/e/ir?t=sarful-20&language=en_US&l=li2&o=1&a=1492043222" width="1" />
<h3>Circuit diagram Push Switch Raspberry pi :</h3>
shows how to connect a tactile push switch using a breadboard and jumper wires.
<img alt="Button in raspberrypi" class="alignnone size-medium wp-image-592" height="300" src="https://www.mechatronicslab.net/my_uploads/2020/06/Button-in-raspberrypi-1-249x300.png" width="249" />
<h2>Code Push Switch Raspberry pi:</h2>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(18)
if input_state == False:
print('Button Pressed')
time.sleep(0.2)
</pre>
You will need to run the program You can see:
Button Pressed
Button Pressed
<span class="words" data-synonyms="You will;You'll;You may" title="Click to edit and show the other synonyms">ou may</span> <span class="words" data-synonyms="notice;take note" title="">take note</span> that the switch is wired so that when it is <span class="words" data-synonyms="pressed;squeezed" title="">squeezed</span>, <span class="words" data-synonyms="it will;it'll">it'll </span><span class="words" data-synonyms="connect;interface" title="">interface</span> Pin 18 <span class="words" data-synonyms="configured;arranged;designed" title="">arranged</span> as an input to GND. The input PIN is <span class="words" data-synonyms="normally;ordinarily;regularly" title="">regularly</span> pulled up to 3.3V by the <span class="words" data-synonyms="optional;discretionary" title="">discretionary</span> <span class="words" data-synonyms="argument;contention" title="">contention</span> pull_up_down=GPIO.PUD_UP in GPIO.setup. This means that <span class="words" data-synonyms="when you;once you;after you">once you</span> <span class="words" data-synonyms="read;perused;examined;studied">examined</span> the input <span class="words" data-synonyms="value;esteem">esteem</span> <span class="words" data-synonyms="using;utilizing">utilizing</span> GPIO.input, <span class="words" data-synonyms="False;Untrue;Wrong" title="">Untrue</span> will be returned <span class="words" data-synonyms="if;on the off chance that;in the event that;in case">in the event that</span> the button is <span class="words" data-synonyms="pressed;squeezed">squeezed</span>. </div><div><span class="words" data-synonyms="This is;This is often;Typically;Usually;This can be" title=""><br /></span></div><div><span class="words" data-synonyms="This is;This is often;Typically;Usually;This can be" title="">Typically </span>a <span class="words" data-synonyms="little;small" title="">small</span> <span class="words" data-synonyms="counterintuitive;outlandish;irrational" title="">irrational</span>.
Each GPIO <span class="words" data-synonyms="pin;stick" title="">pin</span> has software-configurable pull-up and pull-down resistors. When <span class="words" data-synonyms="using a;employing a" title="">using a</span> GPIO pin as an input, you'll design these resistors so that one, either, or <span class="words" data-synonyms="neither;not one or the other" title="">not one or the other</span> of the resistors </div><div><br /></div><div>is <span class="words" data-synonyms="enabled;empowered" title="">empowered</span>, <span class="words" data-synonyms="using;utilizing" title="">utilizing</span> the optional pull_up_down parameter to GPIO.setup. <span class="words" data-synonyms="If;On the off chance that;In the event that;In case" title="">In case</span> this parameter is <span class="words" data-synonyms="omitted;overlooked;excluded" title="">excluded</span>, then neither resistor will be <span class="words" data-synonyms="enabled;empowered" title="">empowered</span>.
This <span class="words" data-synonyms="leaves;clears out;takes off" title="">takes off</span> the input floating, which means that its <span class="words" data-synonyms="value;esteem" title="">esteem</span> cannot be <span class="words" data-synonyms="relied;depended" title="">depended</span> upon and <span class="words" data-synonyms="it will;it'll" title="">it'll </span><span class="words" data-synonyms="drift;float" title="">float</span> between <span class="words" data-synonyms="high;tall" title="">tall</span> and low depending on what it picks up <span class="words" data-synonyms="in the;within the" title="">within the</span> way of electrical noise. If it is set to GPIO.PUD_UP, the pull-up resistor is <span class="words" data-synonyms="enabled;empowered" title="">empowered</span>; <span class="words" data-synonyms="if;on the off chance that;in the event that;in case" title="">in the event that</span> it is set to GPIO.PUD_DOWN, the pull-down resistor is <span class="words" data-synonyms="enabled;empowered" title="">empowered</span>.
<h2>If you want to know more about raspberry pi then click on the link below</h2>
<h4 class="page-title is-large uppercase"><a href="https://www.mechatronicslab.net/category/raspberry-pi/raspberry-pi-tutorials-for-beginners/" rel="noopener noreferrer" target="_blank">RASPBERRY PI TUTORIALS FOR BEGINNERS</a></h4>
</div></div>Mechatronics LABhttp://www.blogger.com/profile/08496873183214129660noreply@blogger.com0