<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-427527960386608258</id><updated>2025-08-23T23:31:03.787-07:00</updated><category term="arduino"/><category term="esp8266"/><category term="beginner"/><category term="LED"/><category term="raspberrypi"/><category term="python"/><category term="advanced"/><category term="facerecognition"/><category term="opencv"/><category term="sensehat"/><category term="ala"/><category term="ledmatrix"/><category term="wifiesp"/><category term="example"/><category term="intermediate"/><category term="max7219"/><category term="oscope"/><category term="strip"/><title type='text'>Yet Another Arduino Blog</title><subtitle type='html'>Arduino projects about LED animations and small robots</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>26</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-3353349401870232839</id><published>2017-02-22T14:50:00.003-08:00</published><updated>2017-02-22T14:52:48.255-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="facerecognition"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Face recognition example</title><content type='html'>In this post I will show you a very simple example of how to recognize faces inside an image using &lt;b&gt;Python 3&lt;/b&gt; and &lt;b&gt;OpenCV&lt;/b&gt; library.&lt;br /&gt;
&lt;br /&gt;
First of all you have to install the prerequisite software as described in &lt;a href=&quot;http://yaab-arduino.blogspot.com/2017/02/install-python-3-opencv-windows.html&quot;&gt;this post&lt;/a&gt;. Keep in mind that you need to install &lt;i&gt;&lt;b&gt;OpenCV with contrib module&lt;/b&gt;&lt;/i&gt; to use face recognition APIs otherwise you will get an error like this: &lt;i&gt;AttributeError: module &#39;cv2.cv2&#39; has no attribute &#39;face&#39;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Download the &lt;a href=&quot;https://github.com/bportaluri/PyFaceRec&quot; target=&quot;_blank&quot;&gt;PyFaceRec repository&lt;/a&gt; in a directory of your choice. In the examples we assume you have downloaded it into C:\PyFaceRec.&lt;br /&gt;
&lt;br /&gt;
The example described here is located in the&amp;nbsp;&lt;i&gt;SimpleFaceRecognition&lt;/i&gt;&amp;nbsp;folder and attempt to identify faces of the members of the famous pop group Abba.&lt;br /&gt;
&lt;br /&gt;
The faces to be detected are located into the &lt;i&gt;data&lt;/i&gt; sub-directory.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXKXjN-mzkOd_a4TStQ2UXqjynh7tCY0jKFDWN3r4lDfh3iBbUIQ3ospnY-TRtGdHw5WopAu_7GGeGJppi8SY4Wunc1xdW1x7ODsYCmTLrFmamY-cj56EX2HkTHJh98z6xRkD_0nPBewE/s1600/faces.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;56&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXKXjN-mzkOd_a4TStQ2UXqjynh7tCY0jKFDWN3r4lDfh3iBbUIQ3ospnY-TRtGdHw5WopAu_7GGeGJppi8SY4Wunc1xdW1x7ODsYCmTLrFmamY-cj56EX2HkTHJh98z6xRkD_0nPBewE/s400/faces.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
While the faces database used to train the algorithm is located in the &lt;i&gt;facesdb&lt;/i&gt; sub-directory.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmoRGFJF9rV8g9YwgVWyFHdnPRNzwGYX6fqTUEBFwbEswfXmEWYV4iOp6dSyNh5c8xfnIvOkAWBz1IBC-PIG5OlTBfodoLsAKSbt2eQiiivRlry-T6lcwGU8XwvTFVIuQeOcRwDuCCi8g/s1600/Agnetha.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmoRGFJF9rV8g9YwgVWyFHdnPRNzwGYX6fqTUEBFwbEswfXmEWYV4iOp6dSyNh5c8xfnIvOkAWBz1IBC-PIG5OlTBfodoLsAKSbt2eQiiivRlry-T6lcwGU8XwvTFVIuQeOcRwDuCCi8g/s400/Agnetha.png&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuxhspq-9tY9_bW-8PAl1UIDyYIJNGe7FbeTC54xgo4KquJ0hoSJ8gyXxGMmP29zhUXhyMwFAxChcsSRb9gbwaIBiaWuZSph8RfEwJBJLkgUhBs53p87KN39_jPw9ASYhML2lcqDQ48b4/s1600/AnniFrid.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuxhspq-9tY9_bW-8PAl1UIDyYIJNGe7FbeTC54xgo4KquJ0hoSJ8gyXxGMmP29zhUXhyMwFAxChcsSRb9gbwaIBiaWuZSph8RfEwJBJLkgUhBs53p87KN39_jPw9ASYhML2lcqDQ48b4/s400/AnniFrid.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQK6GB-q_QiUq707PXq-42BFg4SAZV5y8C6pQ_QkJ_aetZwW6Vzn6Hll_Z_RMnMCvTL7OWZy_gwVtm0eEmQjeobq8RYZR7LHJl_1Fvs2WeF4BhPNEWFqIqPojozuHo8b2Tc9JA0MQSeXM/s1600/Benny.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQK6GB-q_QiUq707PXq-42BFg4SAZV5y8C6pQ_QkJ_aetZwW6Vzn6Hll_Z_RMnMCvTL7OWZy_gwVtm0eEmQjeobq8RYZR7LHJl_1Fvs2WeF4BhPNEWFqIqPojozuHo8b2Tc9JA0MQSeXM/s400/Benny.png&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYvNf1BZpuBf_cwTsYCFWaT82iZ1lVDdqhgPDRE85kHFAUaULxi0PYUJEco0TLbGhiRxlw-N2nHbdhmW0UzD_Ibvl4QsP_dRkOPRwAmPoWjIS7U1J2lOWUcJw-OWBbMtI8bo5UyapvEU4/s1600/Bjorn.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYvNf1BZpuBf_cwTsYCFWaT82iZ1lVDdqhgPDRE85kHFAUaULxi0PYUJEco0TLbGhiRxlw-N2nHbdhmW0UzD_Ibvl4QsP_dRkOPRwAmPoWjIS7U1J2lOWUcJw-OWBbMtI8bo5UyapvEU4/s400/Bjorn.png&quot; width=&quot;350&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Note that all the images have a resolution of 200x200 pixels. This is required by the algorithm.&lt;br /&gt;
&lt;br /&gt;
Now lets try to run the example. Open a command Prompt, move into he&amp;nbsp;&lt;i&gt;SimpleFaceDetection&lt;/i&gt;&amp;nbsp;folder an run the sample script as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;cd C:\PyFaceRec\SimpleFaceRecognition
python simple_face_recognition.py&lt;/pre&gt;
&lt;br /&gt;
You should get an output like this.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHfvAYaAfU1TBhmSzNNykmwlh1FgSQWsAw9RW9VcYcl8p-h_orTcEy571YdaWT0LoYSLA_YzHhdHOpfQkiUKWfUrpFA5rXk2nTDaSM2fYQVql-bWRQWJ6OTKkKB-iBDiYzNOwPne5jRcg/s1600/facerec.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;227&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHfvAYaAfU1TBhmSzNNykmwlh1FgSQWsAw9RW9VcYcl8p-h_orTcEy571YdaWT0LoYSLA_YzHhdHOpfQkiUKWfUrpFA5rXk2nTDaSM2fYQVql-bWRQWJ6OTKkKB-iBDiYzNOwPne5jRcg/s400/facerec.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
After having loaded the images from the training database, the program shows you the best match found for each face in the &lt;i&gt;data&lt;/i&gt; folder. You can see that each face has been correctly identified.&lt;br /&gt;
&lt;br /&gt;
The OpenCV library provides different algorithms for face recognition. Try yourself to change algorithm used by un-commenting a different line in the &lt;i&gt;simple_face_recognition.py&lt;/i&gt; script.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;recognizer = cv2.face.createFisherFaceRecognizer()
#recognizer = cv2.face.createEigenFaceRecognizer()
#recognizer = cv2.face.createLBPHFaceRecognizer()&lt;/pre&gt;
&lt;br /&gt;
You will see that other algorithms provide non-optimal results. This is not always true and really depends on the data you are working with.&lt;br /&gt;
&lt;br /&gt;
Another important thing is that for a correct face detection &lt;b&gt;both the face to be recognized and the faces used for training should have similar lighting conditions&lt;/b&gt;. This simple rule is clearly not true in our sample. That&#39;s why the distance is so high denoting a low accuracy of the detection.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/3353349401870232839/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2017/02/face-recognition-example.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/3353349401870232839'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/3353349401870232839'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2017/02/face-recognition-example.html' title='Face recognition example'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXKXjN-mzkOd_a4TStQ2UXqjynh7tCY0jKFDWN3r4lDfh3iBbUIQ3ospnY-TRtGdHw5WopAu_7GGeGJppi8SY4Wunc1xdW1x7ODsYCmTLrFmamY-cj56EX2HkTHJh98z6xRkD_0nPBewE/s72-c/faces.png" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-33043657568628683</id><published>2017-02-21T13:16:00.001-08:00</published><updated>2017-02-22T14:51:08.789-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="facerecognition"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Face detection example</title><content type='html'>In this post I will show you a very simple example of how to detect faces inside an image using Python 3 and OpenCV library.&lt;br /&gt;
&lt;br /&gt;
First of all you have to install the prerequisite software as described in &lt;a href=&quot;http://yaab-arduino.blogspot.com/2017/02/install-python-3-opencv-windows.html&quot;&gt;this post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Download the &lt;a href=&quot;https://github.com/bportaluri/PyFaceRec&quot;&gt;PyFaceRec repository&lt;/a&gt; in a directory of your choice. In the examples we assume you have downloaded it into C:\PyFaceRec.&lt;br /&gt;
&lt;br /&gt;
The example described here is located in the&amp;nbsp;&lt;i&gt;SimpleFaceDetection&lt;/i&gt;&amp;nbsp;folder and automatically identifies faces in a picture of the famous pop group Abba.&lt;br /&gt;
Open a command Prompt, move into the&amp;nbsp;SimpleFaceDetection&amp;nbsp;folder an run the sample script as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;cd C:\PyFaceRec\SimpleFaceDetection
python simple_face_detection.py&lt;/pre&gt;
&lt;br /&gt;
You should get an output like this.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLAUqtbVR5YHmxzFIQhOxcMbyejb179YQEffz4LOEgTL74smQqMpf6nk62uYkq0BTXLHkbhN6v8-XySchkq6f5dBza0svOBizZzCFjfHKYy6Dr-mml77exAN9iB_hiPMoS4gNHu1zwHFQ/s1600/abba.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLAUqtbVR5YHmxzFIQhOxcMbyejb179YQEffz4LOEgTL74smQqMpf6nk62uYkq0BTXLHkbhN6v8-XySchkq6f5dBza0svOBizZzCFjfHKYy6Dr-mml77exAN9iB_hiPMoS4gNHu1zwHFQ/s400/abba.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The source is quite self-explanatory.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;# Import the OpenCV library
import cv2

# Load the sample image
image = cv2.imread(&#39;data/abba.jpg&#39;)

# Load the OpenCV classifier to detect faces
faceCascade = cv2.CascadeClassifier(&#39;data/haarcascade_frontalface_default.xml&#39;)

# Detect faces in the image
faces = faceCascade.detectMultiScale(
    image,
    scaleFactor=1.2,
    minNeighbors=5,
    minSize=(50, 50)
)

# The faces variable now contains an array of Nx4 elements
# where N is the number faces detected

print(&quot;Found&quot;, len(faces), &quot;faces&quot;)

# Draw a rectangle around each face
for (x, y, w, h) in faces:
    cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)

# Display the image
cv2.imshow(&quot;Faces found&quot;, image)

# Wait for any key before exiting
cv2.waitKey(0)&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/33043657568628683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2017/02/face-detection-example.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/33043657568628683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/33043657568628683'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2017/02/face-detection-example.html' title='Face detection example'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLAUqtbVR5YHmxzFIQhOxcMbyejb179YQEffz4LOEgTL74smQqMpf6nk62uYkq0BTXLHkbhN6v8-XySchkq6f5dBza0svOBizZzCFjfHKYy6Dr-mml77exAN9iB_hiPMoS4gNHu1zwHFQ/s72-c/abba.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-3086563824140702894</id><published>2017-02-20T12:57:00.000-08:00</published><updated>2017-02-22T14:52:02.342-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="facerecognition"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Face detection and recognition with Python and OpenCV</title><content type='html'>This page is collecting a set of experiments on face detection and recognition using Python 3 and OpenCV library. The proposed examples have an increasing complexity to help you understand how this works.&lt;br /&gt;
The examples are based on Windows and Raspberry PI.&lt;br /&gt;
&lt;br /&gt;
First of all we need to make a clear distinction between face detection and face recognition. These two terms are too often misused in the various articles I have found.&lt;br /&gt;
&lt;b&gt;Face Detection&lt;/b&gt;&amp;nbsp;detects the faces in the image. The output will be one ore more rectangles on the faces detected in the image.&lt;br /&gt;
&lt;b&gt;Face Recognition&lt;/b&gt;&amp;nbsp;identifies the face in input using a faces database. A single face should be given as input, and the output will be the name or class of the image.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
The &lt;a href=&quot;https://github.com/bportaluri/PyFaceRec&quot; target=&quot;_blank&quot;&gt;PyFaceRec repository&lt;/a&gt; is shared on GitHub with all the described examples ready to be used and modified.&lt;/div&gt;
&lt;br /&gt;
Here is the full set of posts on this topic.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://yaab-arduino.blogspot.com/2017/02/install-python-3-opencv-windows.html&quot;&gt;Install Python 3 and OpenCV library on Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install&amp;nbsp;Python 3 and OpenCV library on RaspberryPI (ToDo)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://yaab-arduino.blogspot.com/2017/02/face-detection-example.html&quot;&gt;Face detection example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://yaab-arduino.blogspot.com/2017/02/face-recognition-example.html&quot;&gt;Face recognition example&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/3086563824140702894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2017/02/face-detection-recognition-python-opencv.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/3086563824140702894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/3086563824140702894'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2017/02/face-detection-recognition-python-opencv.html' title='Face detection and recognition with Python and OpenCV'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-8748534901104445475</id><published>2017-02-19T01:54:00.000-08:00</published><updated>2017-02-21T13:19:55.852-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberrypi"/><title type='text'>Install Python 3 and OpenCV on Windows</title><content type='html'>In this post I will describe the easiest way of installing Python 3 and OpenCV library on Windows for face detection and recognition.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Install Python 3&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Go to the &lt;a href=&quot;https://www.python.org/downloads/&quot; target=&quot;_blank&quot;&gt;Python download page&lt;/a&gt; and download the latest version of Python 3 for Windows. This example has been tested with Python 3.6.&lt;br /&gt;
&lt;br /&gt;
Launch the installer and ensure the &#39;Add Python to PATH&#39; checkbox is selected.&lt;br /&gt;
Wait for the installation to complete, open a Command Prompt and type &#39;python&#39;. You should see something like this.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;C:\Python&amp;gt;&lt;b&gt;python&lt;/b&gt;
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&lt;/pre&gt;
&lt;br /&gt;
Type &#39;quit()&#39; to exit the python shell.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Install OpenCV library&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
If you just need the face detection (no recognition) all you need is the basic OpenCV library. It can be easily installed with no hassle with pip command.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;pip install opencv-python&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Install OpenCV library with contrib module&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To be able to use the face recognition algorithms, you will need the &#39;contrib&#39; module that is not included in the standard OpenCV build. Many people suggest to build the library manually to solve the problem but there is a simpler solution documented in&amp;nbsp;&lt;a href=&quot;https://www.scivision.co/install-opencv-python-windows/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;this post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Download the appropriate opencv+contrib&amp;nbsp;.whl file from&amp;nbsp;&lt;a href=&quot;http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv&quot; target=&quot;_blank&quot;&gt;this page&lt;/a&gt;. The file to download should be: &lt;i&gt;opencv_python-3.2.0+contrib-cpXX-cp36m-winYYY.whl&lt;/i&gt;. Where XX is your Python version and YYY is your Windows 32/64 bit flavor.&lt;br /&gt;
For example, assuming you have Python 3.6 running on Windows 64 bit you must download: opencv_python-3.2.0+contrib-cp36-cp36m-win_amd64.whl&lt;br /&gt;
&lt;br /&gt;
Now open a Command Prompt with admin rights and type the following command to install:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;pip install opencv_python-3.2.0+contrib-cp36-cp36m-win_amd64.whl&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Test face detection&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
You can now move on to the &lt;a href=&quot;http://yaab-arduino.blogspot.com/2017/02/face-detection-example.html&quot;&gt;face detection example&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/8748534901104445475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2017/02/install-python-3-opencv-windows.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8748534901104445475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8748534901104445475'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2017/02/install-python-3-opencv-windows.html' title='Install Python 3 and OpenCV on Windows'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-2700633856644052487</id><published>2016-08-17T14:52:00.000-07:00</published><updated>2016-08-17T14:52:11.205-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="raspberrypi"/><category scheme="http://www.blogger.com/atom/ns#" term="sensehat"/><title type='text'>Automatic orientation of Sense HAT display</title><content type='html'>In this post I will show you how to automatically detect the position of the Raspberry PI using the Sense HAT accelerometer sensor and rotate the display accordingly.&lt;br /&gt;
&lt;br /&gt;
The &lt;i&gt;&lt;b&gt;auto_rotate_display&lt;/b&gt;&lt;/i&gt; function in the script below is doing all the logic. It&#39;s reading sensors data to detect the orientation and rotating the Sense HAT display by calling the set_rotation function.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;import time
from sense_hat import SenseHat

MSG_COLOR = [200,0,160]
BKG_COLOR = [0,0,0]
SCROLL_SPEED = 0.06
MESSAGE = &quot;Can&#39;t loose my head&quot;


def auto_rotate_display():
  # read sensors data to detect orientation
  x = round(sense.get_accelerometer_raw()[&#39;x&#39;], 0)
  y = round(sense.get_accelerometer_raw()[&#39;y&#39;], 0)

  rot = 0
  if x == -1:
    rot=90
  elif y == -1:
    rot=180
  elif x == 1:
    rot=270

  # rotate the display according to the orientation
  print (&quot;Current orientation x=%s y=%s  rotating display by %s degrees&quot; % (x, y, rot))
  sense.set_rotation(rot)


sense = SenseHat()

while True:
  auto_rotate_display()
  sense.show_message(MESSAGE, scroll_speed=SCROLL_SPEED, text_colour=MSG_COLOR, back_colour=BKG_COLOR)
  time.sleep(1)
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/2700633856644052487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2016/08/automatic-orientation-of-sense-hat-display.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/2700633856644052487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/2700633856644052487'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2016/08/automatic-orientation-of-sense-hat-display.html' title='Automatic orientation of Sense HAT display'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-7121337635367111467</id><published>2016-08-17T13:23:00.005-07:00</published><updated>2016-08-17T13:53:08.523-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="raspberrypi"/><category scheme="http://www.blogger.com/atom/ns#" term="sensehat"/><title type='text'>Accurate temperature reading from Raspberry PI Sense HAT</title><content type='html'>When I first received the Sense HAT for my Raspberry PI 3 I decided to start building a nice weather station using the embedded environmental sensors and RGB LED matrix.&lt;br /&gt;
From a quick experiment it turns out that the temperature readings are not accurate. The problem is caused by thermal conduction from the Pi CPU to the humidity and pressure sensors on the Sense HAT.&lt;br /&gt;
I have experimented few algorithms and I have found the following formula to be the most reliable. It basically compensate the temperature reading (t) with the CPU temperature (tCpu).&lt;br /&gt;
&lt;i&gt;tCorr = t - ((tCpu-t)/1.5&lt;/i&gt;)&lt;br /&gt;
&lt;br /&gt;
Here is the full script to print each 5 seconds the environmental data including the corrected temperature.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;import os
import time
from sense_hat import SenseHat

def get_cpu_temp():
  res = os.popen(&quot;vcgencmd measure_temp&quot;).readline()
  t = float(res.replace(&quot;temp=&quot;,&quot;&quot;).replace(&quot;&#39;C\n&quot;,&quot;&quot;))
  return(t)


sense = SenseHat()

while True:
  t = sense.get_temperature_from_humidity()
  t_cpu = get_cpu_temp()
  h = sense.get_humidity()
  p = sense.get_pressure()

  # calculates the real temperature compesating CPU heating
  t_corr = t - ((t_cpu-t)/1.5)
  
  print(&quot;t=%.1f  t_cpu=%.1f  t_corr=%.1f  h=%d  p=%d&quot; % (t, t_cpu, t_corr, round(h), round(p)))
  
  time.sleep(5)
&lt;/pre&gt;
&lt;br /&gt;
Running this script I have noticed that the CPU temperature reading is not very stable making the corrected temperature a little bit unstable. To fix this issue I have decided to apply a moving average to the temperature reading.&lt;br /&gt;
As a further improvement I&#39;m also the temperature both from the humidity and pressure sensors and calculating the average.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;import os
import time
from sense_hat import SenseHat

# get CPU temperature
def get_cpu_temp():
  res = os.popen(&quot;vcgencmd measure_temp&quot;).readline()
  t = float(res.replace(&quot;temp=&quot;,&quot;&quot;).replace(&quot;&#39;C\n&quot;,&quot;&quot;))
  return(t)

# use moving average to smooth readings
def get_smooth(x):
  if not hasattr(get_smooth, &quot;t&quot;):
    get_smooth.t = [x,x,x]
  get_smooth.t[2] = get_smooth.t[1]
  get_smooth.t[1] = get_smooth.t[0]
  get_smooth.t[0] = x
  xs = (get_smooth.t[0]+get_smooth.t[1]+get_smooth.t[2])/3
  return(xs)


sense = SenseHat()

while True:
  t1 = sense.get_temperature_from_humidity()
  t2 = sense.get_temperature_from_pressure()
  t_cpu = get_cpu_temp()
  h = sense.get_humidity()
  p = sense.get_pressure()

  # calculates the real temperature compesating CPU heating
  t = (t1+t2)/2
  t_corr = t - ((t_cpu-t)/1.5)
  t_corr = get_smooth(t_corr)
  
  print(&quot;t1=%.1f  t2=%.1f  t_cpu=%.1f  t_corr=%.1f  h=%d  p=%d&quot; % (t1, t2, t_cpu, t_corr, round(h), round(p)))
  
  time.sleep(5)
&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/7121337635367111467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2016/08/accurate-temperature-reading-sensehat.html#comment-form' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/7121337635367111467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/7121337635367111467'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2016/08/accurate-temperature-reading-sensehat.html' title='Accurate temperature reading from Raspberry PI Sense HAT'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-8704347332199507065</id><published>2016-08-17T03:05:00.002-07:00</published><updated>2016-08-17T03:37:11.631-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ledmatrix"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberrypi"/><category scheme="http://www.blogger.com/atom/ns#" term="sensehat"/><title type='text'>Display two digits numbers on the Raspberry PI Sense HAT</title><content type='html'>Here is a small Python script to display two digits numbers on the Raspberry PI Sense HAT led matrix.&lt;br /&gt;
&lt;br /&gt;
The script is very useful if you want to display humidity and temperature without scrolling.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAF291RGxwvN9LgpsJFcvrwDZuJJJqyG0a8-iKzKW9LcLCe0glDh4zhKpVP1nOSOBt3pWfr69FMbn4Ej1gveWELm_4roIeStlYx6hJBcKqCJ89bOPznE8lD408TMUUk6pQ8Csk1u9XURg/s1600/two_digits_display.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;285&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAF291RGxwvN9LgpsJFcvrwDZuJJJqyG0a8-iKzKW9LcLCe0glDh4zhKpVP1nOSOBt3pWfr69FMbn4Ej1gveWELm_4roIeStlYx6hJBcKqCJ89bOPznE8lD408TMUUk6pQ8Csk1u9XURg/s400/two_digits_display.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The &lt;i&gt;show_number&lt;/i&gt; function accepts the number to be displayed and RGB values of the color to be used.&lt;br /&gt;
Here is the full script. &lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;from sense_hat import SenseHat
import time

OFFSET_LEFT = 1
OFFSET_TOP = 2

NUMS =[1,1,1,1,0,1,1,0,1,1,0,1,1,1,1,  # 0
       0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,  # 1
       1,1,1,0,0,1,0,1,0,1,0,0,1,1,1,  # 2
       1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,  # 3
       1,0,0,1,0,1,1,1,1,0,0,1,0,0,1,  # 4
       1,1,1,1,0,0,1,1,1,0,0,1,1,1,1,  # 5
       1,1,1,1,0,0,1,1,1,1,0,1,1,1,1,  # 6
       1,1,1,0,0,1,0,1,0,1,0,0,1,0,0,  # 7
       1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,  # 8
       1,1,1,1,0,1,1,1,1,0,0,1,0,0,1]  # 9

# Displays a single digit (0-9)
def show_digit(val, xd, yd, r, g, b):
  offset = val * 15
  for p in range(offset, offset + 15):
    xt = p % 3
    yt = (p-offset) // 3
    sense.set_pixel(xt+xd, yt+yd, r*NUMS[p], g*NUMS[p], b*NUMS[p])

# Displays a two-digits positive number (0-99)
def show_number(val, r, g, b):
  abs_val = abs(val)
  tens = abs_val // 10
  units = abs_val % 10
  if (abs_val &amp;gt; 9): show_digit(tens, OFFSET_LEFT, OFFSET_TOP, r, g, b)
  show_digit(units, OFFSET_LEFT+4, OFFSET_TOP, r, g, b)


################################################################################
# MAIN

sense = SenseHat()
sense.clear()

for i in range(0, 100):
  show_number(i, 200, 0, 60)
  time.sleep(0.2)

sense.clear()
&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/8704347332199507065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2016/08/display-two-digits-numbers-on-raspberry.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8704347332199507065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8704347332199507065'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2016/08/display-two-digits-numbers-on-raspberry.html' title='Display two digits numbers on the Raspberry PI Sense HAT'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAF291RGxwvN9LgpsJFcvrwDZuJJJqyG0a8-iKzKW9LcLCe0glDh4zhKpVP1nOSOBt3pWfr69FMbn4Ej1gveWELm_4roIeStlYx6hJBcKqCJ89bOPznE8lD408TMUUk6pQ8Csk1u9XURg/s72-c/two_digits_display.jpg" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-6682878667380943613</id><published>2016-06-03T07:39:00.000-07:00</published><updated>2016-08-17T02:30:42.098-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="advanced"/><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberrypi"/><title type='text'>Raspberry PI - Arduino communication over USB serial</title><content type='html'>The Raspberry Pi is a fine little computer board with a lot of features and very good connectivity especially on version 3 with the integrated WiFi.&lt;br /&gt;
However, when dealing with I/O and sensors has a lot of limitations and is lacking the reliability of Arduino board and availability of libraries to interface it with any kind of device or sensor.&lt;br /&gt;
&lt;br /&gt;
That&#39;s why I have decided to develop my own approach to integrate the two famous boards to fulfill my own set of requirements:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Use &lt;b&gt;Raspberry Pi as a master device&lt;/b&gt; to develop the main application and connect to the Internet.&lt;/li&gt;
&lt;li&gt;Use &lt;b&gt;Java on the Raspberry Pi&lt;/b&gt;. This may sound a strange choice but I&#39;m planning to use it to build an OSGi application for IoT.&lt;/li&gt;
&lt;li&gt;Use &lt;b&gt;Arduino board as a slave device&lt;/b&gt; to interact with several sensors.&lt;/li&gt;
&lt;li&gt;Use a &lt;b&gt;simple USB cable&lt;/b&gt; to power the Arduino board and exchange data.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to connect Arduino board to a Raspberry PI using a simple USB cable. This will power the Arduino and provide a serial communication between the two little boards.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh55Lynj_8HkizWCVpTd-apRZd7RIQojtl0Q0ANZ94gnRvd3dQ037hrJlqHUhyphenhyphenL15LqtcLEBn9ACYQaJmeVWxBhhfJOzayIox9TqEQxZHBgQQyil1EC9_0mnMum6YO27UMj6MNEgGu2K28/s1600/ArduRasPi.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh55Lynj_8HkizWCVpTd-apRZd7RIQojtl0Q0ANZ94gnRvd3dQ037hrJlqHUhyphenhyphenL15LqtcLEBn9ACYQaJmeVWxBhhfJOzayIox9TqEQxZHBgQQyil1EC9_0mnMum6YO27UMj6MNEgGu2K28/s320/ArduRasPi.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;
Arduino&lt;/h4&gt;
&lt;br /&gt;
First step is to load and test the Arduino sketch to allow to retrieve the current milliseconds and toggle the on-board LED as described in &lt;a href=&quot;http://yaab-arduino.blogspot.com/2016/05/interact-with-arduino-through-serial.html&quot;&gt;this article&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Raspberry PI&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
First step is to free the serial interface on the RasPI disabling shell and kernel messages via UART.&lt;br /&gt;
Run &lt;i&gt;raspi-conf&lt;/i&gt; utility from the command prompt:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;$ sudo raspi-config&lt;/pre&gt;
&lt;br /&gt;
Identify the Serial option and disable it. If is in the advanced menu in recent versions of Raspbian (9, A8).&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF6TlqK9s3L4fMDkOJeptoPIEzNZb_U2vK0hwhnaW59x4hwOR29eDIU14MemcpCr_dJZNZpi5L8B25uZm2AXOke0oMZKyV9vR0RMCIcXvUhXqtGSWevABkPSWxS_EFg02iYpba-HkQpAo/s1600/raspi-config-serial.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;201&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF6TlqK9s3L4fMDkOJeptoPIEzNZb_U2vK0hwhnaW59x4hwOR29eDIU14MemcpCr_dJZNZpi5L8B25uZm2AXOke0oMZKyV9vR0RMCIcXvUhXqtGSWevABkPSWxS_EFg02iYpba-HkQpAo/s320/raspi-config-serial.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Enter the following command to reboot your Raspberry Pi board:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;$ sudo reboot&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Install RxTx library&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
On the Raspberry PI side we will use the RxTx library. Install it with the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;sudo apt-get install librxtx-java&lt;/pre&gt;
&lt;br /&gt;
You can see that the native libraries are installed into the &lt;i&gt;/usr/lib/jni&lt;/i&gt; directory and the java client is installed in /usr/share/java.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;ls -la /usr/lib/jni/librxtx*
ls -la /usr/share/java/RXTX*&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Java app&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Import &lt;a href=&quot;https://docs.google.com/uc?export=download&amp;amp;id=0B6PxDhwK5tSJbENmd0FnMzBFWG8&quot; target=&quot;_blank&quot;&gt;this Java project&lt;/a&gt; into Eclipse and build it. It is a slightly improved version of the &lt;a href=&quot;http://rxtx.qbang.org/wiki/index.php/Two_way_communcation_with_the_serial_port&quot; target=&quot;_blank&quot;&gt;official RxTx sample&lt;/a&gt;.&lt;br /&gt;
Now copy the three generated class files to your Raspberry Pi device into the &lt;i&gt;/home/pi&lt;/i&gt; directory and run the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/RXTXcomm.jar:. ArduRasPi /dev/ttyUSB0 9600&lt;/pre&gt;
&lt;br /&gt;
This will run the ArduRasPi program connecting to Arduino on the /dev/ttyUSB0 port and 9600 baud.&lt;br /&gt;
&lt;br /&gt;
You should now be able to issue commands to Arduino and receive the correct answer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEYDsIMxEfTC900T10DW2JM4vhOwYFe9TFQwEsuFeInCBlQzEB1YLka4EioV6GJUe2R2hm22KsTFVvozEf2X1B2pV7VJa3N9mfXBtgkwStjtLwCv40aUJQT_sYVvoe-w5oQFLffu1vkR0/s1600/ArduRasPi.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEYDsIMxEfTC900T10DW2JM4vhOwYFe9TFQwEsuFeInCBlQzEB1YLka4EioV6GJUe2R2hm22KsTFVvozEf2X1B2pV7VJa3N9mfXBtgkwStjtLwCv40aUJQT_sYVvoe-w5oQFLffu1vkR0/s400/ArduRasPi.png&quot; width=&quot;500&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;References&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://readwrite.com/2014/05/07/arduino-vs-raspberry-pi-projects-diy-platform/&quot; target=&quot;_blank&quot;&gt;Arduino Vs. Raspberry Pi: Which Is The Right DIY Platform For You?&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.drdobbs.com/jvm/control-an-arduino-from-java/240163864&quot;&gt;Control an Arduino from Java&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.lediouris.net/RaspberryPI/Arduino/RPi.read.write.Arduino/readme.html&quot;&gt;Raspberry PI reads and writes data from Arduino, in Java&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://playground.arduino.cc/Interfacing/Java&quot;&gt;Arduino and Java&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/6682878667380943613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2016/06/raspberry-pi-arduino-communication-usb-serial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/6682878667380943613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/6682878667380943613'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2016/06/raspberry-pi-arduino-communication-usb-serial.html' title='Raspberry PI - Arduino communication over USB serial'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh55Lynj_8HkizWCVpTd-apRZd7RIQojtl0Q0ANZ94gnRvd3dQ037hrJlqHUhyphenhyphenL15LqtcLEBn9ACYQaJmeVWxBhhfJOzayIox9TqEQxZHBgQQyil1EC9_0mnMum6YO27UMj6MNEgGu2K28/s72-c/ArduRasPi.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-1237818507875576776</id><published>2016-05-25T12:56:00.000-07:00</published><updated>2016-05-25T14:02:01.599-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><title type='text'>Interact with Arduino through serial</title><content type='html'>In this post I will show how to use the USB serial interface to issue commands and retrieve output from an Arduino board.
The main goal of this project is to build a simple interface to use Arduino as a &#39;sensors hub&#39; and integrate it with other more complex devices like Raspberry PI or and PC.&lt;br /&gt;
&lt;br /&gt;
Now plug your Arduino board to the PC and upload the following sketch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;int PIN_LED = 13;

void setup()
{
  pinMode(PIN_LED, OUTPUT);
  
  Serial.begin(9600);

  Serial.println(&quot;Welcome to ArduinoSerialControl&quot;);
  Serial.println(&quot;Enter &#39;t&#39; to retrieve current millis&quot;);
  Serial.println(&quot;Enter &#39;l&#39; to toggle LED on pin 13&quot;);
}

void loop()
{
  int bytes=Serial.available();
  if (bytes &amp;gt; 0)
  {
    char c = Serial.read();
    switch (c)
    {
    case &#39;t&#39;:
      // return the uptime in milliseconds
      Serial.print(&quot;millis=&quot;);
      Serial.println(millis());
      break;
    case &#39;l&#39;:
      // toggle on-board led connected to pin 13
      digitalWrite(PIN_LED, !digitalRead(PIN_LED));
      Serial.print(&quot;LED status is &quot;);
      Serial.println(digitalRead(PIN_LED));
      break;
    }
  }
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Open the serial monitor and set the baud rate to 9600. Try sending commands using the serial console.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXzxPFRtQcNxcPvB90lqSiDdAxkPhyRWK6mHZyfoJYBLQjtVupH0-GmlyH1kUZIjaKXM_ff-9YDsCjxettTHSgC-DzKLBJ48i80ZIwh4F_rdfEquHV2PfQP6cCmLcx1e5rg_i9iSMpitI/s1600/ArduinoSerialControl.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;253&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXzxPFRtQcNxcPvB90lqSiDdAxkPhyRWK6mHZyfoJYBLQjtVupH0-GmlyH1kUZIjaKXM_ff-9YDsCjxettTHSgC-DzKLBJ48i80ZIwh4F_rdfEquHV2PfQP6cCmLcx1e5rg_i9iSMpitI/s320/ArduinoSerialControl.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
This is just an experiment. If you want to build a solid communication using &lt;a href=&quot;https://www.arduino.cc/en/Reference/Firmata&quot; target=&quot;_blank&quot;&gt;Firmata protocol&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://forums.trossenrobotics.com/tutorials/how-to-diy-128/complete-control-of-an-arduino-via-serial-3300/&quot;&gt;Complete Control Of An Arduino Via Serial&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/1237818507875576776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2016/05/interact-with-arduino-through-serial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/1237818507875576776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/1237818507875576776'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2016/05/interact-with-arduino-through-serial.html' title='Interact with Arduino through serial'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXzxPFRtQcNxcPvB90lqSiDdAxkPhyRWK6mHZyfoJYBLQjtVupH0-GmlyH1kUZIjaKXM_ff-9YDsCjxettTHSgC-DzKLBJ48i80ZIwh4F_rdfEquHV2PfQP6cCmLcx1e5rg_i9iSMpitI/s72-c/ArduinoSerialControl.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-5189892801262312991</id><published>2016-01-09T04:07:00.001-08:00</published><updated>2016-01-09T04:10:07.106-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ala"/><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="LED"/><title type='text'>Nativity scene with Arduino and ALA library</title><content type='html'>Here are my last creations with Arduino and my &lt;a href=&quot;http://yaab-arduino.blogspot.com/p/ala.html&quot;&gt;ALA library&lt;/a&gt;.&lt;br /&gt;
An Arduino Uno board is driving a WS2812 RGB LED strip and some other LEDs through a TLC5940 chip. The full sketch is less than 100 rows of code!&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;h4&gt;
Normal version&lt;/h4&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/Il8a3SVYJ74/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;270&quot; src=&quot;https://www.youtube.com/embed/Il8a3SVYJ74?feature=player_embedded&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;h4&gt;
Disco version&lt;/h4&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/lXRCmzAPkYE/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;270&quot; src=&quot;https://www.youtube.com/embed/lXRCmzAPkYE?feature=player_embedded&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Arduino sketch&lt;/h4&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;#include &quot;AlaLed.h&quot;
#include &quot;AlaLedRGB.h&quot;

#define DAY_LEN 12000

AlaLed houses1;
AlaLed houses2;
AlaLedRgb rgbStrip;

AlaColor palRed_[] = { 0xFF0000 };
AlaPalette palRed = { 1, palRed_ };
AlaColor palBlue_[] = { 0x0000FF };
AlaPalette palBlue = { 1, palBlue_ };
AlaColor palGreen_[] = { 0x00FF00 };
AlaPalette palGreen = { 1, palGreen_ };

// RGB palette with black
AlaColor alaPalRgbBlack_[] = { 0xFF0000, 0x000000, 0x00FF00, 0x000000, 0x0000FF, 0x000000 };
AlaPalette alaPalRgbBlack = { 6, alaPalRgbBlack_ };

AlaSeq houses1Seq[] =
{
  { ALA_FADEOUT,          1000, 1000 },
  { ALA_FADEOUT,          1000, 1000 },
  { ALA_FADEOUT,          1000, 1000 },

  { ALA_PIXELSMOOTHSHIFTRIGHT,  800, DAY_LEN },
  { ALA_PIXELSMOOTHBOUNCE,1000, DAY_LEN },
  { ALA_STROBO,            400, DAY_LEN },
  { ALA_SPARKLE,           800, DAY_LEN },
  
  { ALA_STROBO,           1000, 3000 },
  { ALA_FADEOUT,          1000, 1000 },
  { ALA_OFF,              5000, 5000 },
  { ALA_ENDSEQ,              0,    0 }
};

AlaSeq houses2Seq[] =
{
  { ALA_FADEOUT,          1000, 1000 },
  { ALA_FADEOUT,          1000, 1000 },
  { ALA_FADEOUT,          1000, 1000 },

  { ALA_GLOW,              800, DAY_LEN },
  { ALA_SPARKLE2,          500, DAY_LEN },
  { ALA_STROBO,            400, DAY_LEN },
  { ALA_SPARKLE,           1000, DAY_LEN },
  
  { ALA_STROBO,           1000, 3000 },
  { ALA_FADEOUT,          1000, 1000 },
  { ALA_OFF,              5000, 5000 },
  { ALA_ENDSEQ,              0,    0 }
};

AlaSeq rgbStripSeq[] =
{
  { ALA_FADEOUT,          1000, 1000, palRed },
  { ALA_FADEOUT,          1000, 1000, palBlue },
  { ALA_FADEOUT,          1000, 1000, palGreen },

  { ALA_MOVINGGRADIENT,   2000, DAY_LEN, alaPalRgbBlack },
  { ALA_LARSONSCANNER,    3000, DAY_LEN, palBlue },
  { ALA_LARSONSCANNER2,    800, DAY_LEN, palRed },
  { ALA_SPARKLE,          3000, DAY_LEN, alaPalParty },

  { ALA_STROBO,           1000, 3000, palBlue },
  { ALA_FADEOUT,          1000, 1000, palBlue },
  { ALA_OFF,              5000, 5000 },
  { ALA_ENDSEQ,              0,    0 }
};

byte houses1Pin[] = { 1,3,4,2 };
byte houses2Pin[] = { 5,6,7,8,9,10, 11,12,13,14 };
byte rgbStripPin = 2;


void setup()
{
  houses1.initTLC5940(4, houses1Pin);
  houses1.setAnimation(houses1Seq);
  
  houses2.initTLC5940(10, houses2Pin);
  houses2.setAnimation(houses2Seq);
  
  rgbStrip.initWS2812(50, rgbStripPin);
  rgbStrip.setBrightness(0x888888);
  rgbStrip.setAnimation(rgbStripSeq);
}

void loop()
{
  houses1.runAnimation();
  houses2.runAnimation();
  rgbStrip.runAnimation();
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/5189892801262312991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2016/01/nativity-scene-with-arduino-and-ala.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/5189892801262312991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/5189892801262312991'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2016/01/nativity-scene-with-arduino-and-ala.html' title='Nativity scene with Arduino and ALA library'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/Il8a3SVYJ74/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-8461848175745060384</id><published>2015-12-30T09:43:00.000-08:00</published><updated>2016-08-30T00:16:52.060-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><title type='text'>How to sprintf a float with Arduino</title><content type='html'>Arduino has a small limitation in &lt;i&gt;sprintf&lt;/i&gt; function that does not print correctly float numbers.&lt;br /&gt;
The following test sketch demonstrates the problem&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;void setup()
{
  Serial.begin(115200);
}
 
void loop()
{
  float f = 123.12F;
  Serial.print(&quot;Original value: &quot;);
  Serial.println(f);

  char str[50];
  &lt;b&gt;sprintf(str, &quot;String value: %f&quot;, f);&lt;/b&gt;
  Serial.println(str);
  
  Serial.println();
  delay(2000);
}&lt;/pre&gt;
&lt;br /&gt;
You can see from the screenshot below that the float is always formatted a question mark &#39;?&#39;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9saWl4Xnzywhf2iwLPGB_JVDyaZqvEcFikRklbeQ1X2KncTX5r4oowTSOJQuWOKDbFKVSHPLhRy2v1pY1k3U4r1C782sUIuM0xZvJ2K5rwcsrGpaFffitIKeE81uKJ7yZ30GW48DQbtw/s1600/float-sprintf-1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;254&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9saWl4Xnzywhf2iwLPGB_JVDyaZqvEcFikRklbeQ1X2KncTX5r4oowTSOJQuWOKDbFKVSHPLhRy2v1pY1k3U4r1C782sUIuM0xZvJ2K5rwcsrGpaFffitIKeE81uKJ7yZ30GW48DQbtw/s320/float-sprintf-1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h3&gt;
Using integer trick&lt;/h3&gt;
&lt;br /&gt;
There is a little trick to correctly print the float value using &lt;i&gt;sprintf&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;sprintf(str, &quot;String value: %d.%02d&quot;, (int)f, (int)(f*100)%100);&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
This trick works well only with positive numbers and formats the float with two fixed decimals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyeIZ-Fvrq4hfntHWgdsN1bE4BoNvFviXZgaMZV4jK-fHfUkuB57Oi7NYsdF7P-E3KmwCamfxHfGbyQW72izkiZVYmMQQfAA66Kofb-4o8lF3xWsTbe0-NT3Qhb_yOzvUbuHLnW77E134/s1600/float-sprintf-2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;254&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyeIZ-Fvrq4hfntHWgdsN1bE4BoNvFviXZgaMZV4jK-fHfUkuB57Oi7NYsdF7P-E3KmwCamfxHfGbyQW72izkiZVYmMQQfAA66Kofb-4o8lF3xWsTbe0-NT3Qhb_yOzvUbuHLnW77E134/s320/float-sprintf-2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h3&gt;
Using dtostrf function&lt;/h3&gt;
&lt;br /&gt;
A better solution is to use the &lt;b&gt;&lt;i&gt;dtostrf&lt;/i&gt;&lt;/b&gt; function. It it is more flexible and works well also with negative numbers.&lt;br /&gt;
These two lines of code will write a string into the buffer with &lt;i&gt;strcpy&lt;/i&gt; function and the append the float value using the &lt;i&gt;dtostrf&lt;/i&gt; function.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;strcpy(str, &quot;String value using dtostrf: &quot;);
dtostrf(f, 2, 2, &amp;amp;str[strlen(str)]);&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/8461848175745060384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/how-to-sprintf-float-with-arduino.html#comment-form' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8461848175745060384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8461848175745060384'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/how-to-sprintf-float-with-arduino.html' title='How to sprintf a float with Arduino'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9saWl4Xnzywhf2iwLPGB_JVDyaZqvEcFikRklbeQ1X2KncTX5r4oowTSOJQuWOKDbFKVSHPLhRy2v1pY1k3U4r1C782sUIuM0xZvJ2K5rwcsrGpaFffitIKeE81uKJ7yZ30GW48DQbtw/s72-c/float-sprintf-1.png" height="72" width="72"/><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-217585525308471305</id><published>2015-12-28T14:53:00.000-08:00</published><updated>2015-12-28T15:22:13.142-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="wifiesp"/><title type='text'>Installing WiFiEsp library</title><content type='html'>The easiest way of installing the &lt;a href=&quot;http://yaab-arduino.blogspot.com/p/wifiesp.html&quot;&gt;WiFiEsp library&lt;/a&gt; in the Arduino IDE is using the Arduino Library Manager.&lt;br /&gt;
&lt;br /&gt;
Launch the Arduino IDE and select &lt;i&gt;Sketch - Include Library - Manage Libraries&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjWLeL6PiM3-14DebdChl6mH9hi0NyoCxp8U_6oeirSIKSu-GAPJ8EAiJeBpyz5D_VuTaPfnLRfw9qQzQp4_1Zo0VWP9_tsPdA__uVhz4yNgaCPxnmiOA76QKYRZLzh5j-q-KUXaRlwyY/s1600/wifiesp-install-1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjWLeL6PiM3-14DebdChl6mH9hi0NyoCxp8U_6oeirSIKSu-GAPJ8EAiJeBpyz5D_VuTaPfnLRfw9qQzQp4_1Zo0VWP9_tsPdA__uVhz4yNgaCPxnmiOA76QKYRZLzh5j-q-KUXaRlwyY/s320/wifiesp-install-1.png&quot; width=&quot;267&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Arduino Library Manager will open. All you have to do is search for &#39;WiFiEsp&#39; and hit the &#39;Install&#39; button.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzaUUIFAFlwC2My1f_b1cWY4j7jNOul5mJvKf_Ym3MRzzM3vHZI9y5pZLHmnidUKbSMl-9iOGsGJlwUNiXyUqAK2WqkH_WAstA4gg6UfulavTHNumuAHUQLVSDDON-yvmADnbpiKVHMgE/s1600/wifiesp-install-2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzaUUIFAFlwC2My1f_b1cWY4j7jNOul5mJvKf_Ym3MRzzM3vHZI9y5pZLHmnidUKbSMl-9iOGsGJlwUNiXyUqAK2WqkH_WAstA4gg6UfulavTHNumuAHUQLVSDDON-yvmADnbpiKVHMgE/s320/wifiesp-install-2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After the library has been installed you can open one of the examples.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_2RbT2AYJCBENV2ig3cI8w89_9TwNQ99U_B8rnS7XtI5IBtSC_JXD41plEU7qsE2t6NtrfoYN8TR9CRpxORj60IxNBDRsJs9ZtOWVAhfr0NkKgYsnUBtArGWk7TYIOfvCIYTHrs54myw/s1600/wifiesp-install-3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;305&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_2RbT2AYJCBENV2ig3cI8w89_9TwNQ99U_B8rnS7XtI5IBtSC_JXD41plEU7qsE2t6NtrfoYN8TR9CRpxORj60IxNBDRsJs9ZtOWVAhfr0NkKgYsnUBtArGWk7TYIOfvCIYTHrs54myw/s320/wifiesp-install-3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Alternative download&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
If you want to manually install the library you can dowload it from &lt;a href=&quot;https://github.com/bportaluri/WiFiEsp&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt; and deal yourself with the installation process.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/217585525308471305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/installing-wifiesp-library.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/217585525308471305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/217585525308471305'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/installing-wifiesp-library.html' title='Installing WiFiEsp library'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjWLeL6PiM3-14DebdChl6mH9hi0NyoCxp8U_6oeirSIKSu-GAPJ8EAiJeBpyz5D_VuTaPfnLRfw9qQzQp4_1Zo0VWP9_tsPdA__uVhz4yNgaCPxnmiOA76QKYRZLzh5j-q-KUXaRlwyY/s72-c/wifiesp-install-1.png" height="72" width="72"/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-3914284158677595740</id><published>2015-12-27T15:05:00.000-08:00</published><updated>2016-01-01T02:18:39.383-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="advanced"/><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="esp8266"/><title type='text'>Flashing ESP8266 firmware v1.5 using Arduino Uno</title><content type='html'>I have to admit that I had some bad experience when trying to flash new firmwares to my ESP-01 modules but today I have found an easy and reliable way to flash &lt;b&gt;ESP8266 firmware v1.5 (AT v0.51)&lt;/b&gt; using my Arduino Uno board as an FTDI controller.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Prerequisites&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;/ul&gt;
You need the following items:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;A Windows PC with Arduino IDE installed&lt;/li&gt;
&lt;li&gt;An Arduino Uno board&lt;/li&gt;
&lt;li&gt;A reliable connection between ESP-01 module and Arduino board. This procedure is based on my &lt;a href=&quot;http://www.instructables.com/id/Cheap-Arduino-WiFi-Shield-With-ESP8266/&quot; target=&quot;_blank&quot;&gt;cheap Arduino WiFi shield with ESP-01&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Wiring&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
First of all you have to build my &lt;a href=&quot;http://www.instructables.com/id/Cheap-Arduino-WiFi-Shield-With-ESP8266/&quot; target=&quot;_blank&quot;&gt;cheap Arduino WiFi shield with ESP8266&lt;/a&gt;. This will provide a solid foundation for powering the ESP module and setup the communication to the Arduino board.&lt;br /&gt;
Ensure you are able to issue simple AT commands to the ESP-01 board before proceeding. &lt;br /&gt;
&lt;br /&gt;
Now modify the wiring as follows.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Remove ATmega328P chip from the Arduino board. By removing the microcontroller you can use the Arduino Uno onboard FTDI interface to directly communicate with the ESP module.&lt;/li&gt;
&lt;li&gt;Connect ESP&#39; RDX pin to the RX pin of Arduino (pin 0).&lt;/li&gt;
&lt;li&gt;Connect ESP&#39;s TXD pin to the TX pin of Arduino (pin 1).&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEbkjcbSUdvtpgLGjYKq4obJf6QxpXI1PMI5GwbSLZmhN0ZYD0ZDKja4YIiGnFqM_nY4C9Ybojq_V9h1MRxCaPo0vsqNg3Ge20fWiw609ikSMX4yVjvWnvB7PNmaLP9Nt1G9gZF9jOhfM/s1600/IMG_20151227_001446.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEbkjcbSUdvtpgLGjYKq4obJf6QxpXI1PMI5GwbSLZmhN0ZYD0ZDKja4YIiGnFqM_nY4C9Ybojq_V9h1MRxCaPo0vsqNg3Ge20fWiw609ikSMX4yVjvWnvB7PNmaLP9Nt1G9gZF9jOhfM/s320/IMG_20151227_001446.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh66hAZgoZnNEBlrQXtFjopX2hjyW6HUboL8cMEaKx2iqL7E7Zko-eWgCd4IpY2s9tCN8eKNb_pqMY2jIxls2Ng8cOuRSvnaeLK-H-apGZ22bYS29ItMXfgYboJfbEZMkb7SF2v152utNE/s1600/IMG_20151227_232611.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh66hAZgoZnNEBlrQXtFjopX2hjyW6HUboL8cMEaKx2iqL7E7Zko-eWgCd4IpY2s9tCN8eKNb_pqMY2jIxls2Ng8cOuRSvnaeLK-H-apGZ22bYS29ItMXfgYboJfbEZMkb7SF2v152utNE/s320/IMG_20151227_232611.jpg&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Test connectivity&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Open the Arduino IDE, select the correct port and open the serial monitor.&lt;br /&gt;
You should be able to issue AT commands and get a nice output. Try &#39;AT&#39; and &#39;AT+GMR&#39; commands.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0PpbbYL241h0qSz96AzIdvvNqtRZk7Q77kKXqhyphenhyphenVCt_UOuvIZ3CUKnXlN_UN1Y9gsjAINKifCQupz8vtidPBYrlrcxI5E4lzO0eHt7ZjGWQ8RJsVGhEGa2tX3l2OGDu3yh6FAnOy9wI4/s1600/arduino-esp.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0PpbbYL241h0qSz96AzIdvvNqtRZk7Q77kKXqhyphenhyphenVCt_UOuvIZ3CUKnXlN_UN1Y9gsjAINKifCQupz8vtidPBYrlrcxI5E4lzO0eHt7ZjGWQ8RJsVGhEGa2tX3l2OGDu3yh6FAnOy9wI4/s320/arduino-esp.png&quot; width=&quot;303&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
If you do not get any output you can try the following.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The serial monitor baud rate must correspond to the ESP UART baud rate. Old modules have 9600, newer ones have 115200.&lt;/li&gt;
&lt;li&gt;Try different settings for the &#39;Line ending&#39; option of the serial monitor. For my ESP module I have to set it to &#39;Both NL &amp;amp; CR&#39; as you can see in the screenshot.&lt;/li&gt;
&lt;/ul&gt;
Try different combinations until you are able to correctly interact with the ESP module using the serial monitor.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Download firmware and tools&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Download the following files and extract them&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;&lt;i&gt;esp_iot_sdk_v1.5.0_15_11_27.zip&lt;/i&gt;&lt;/b&gt; from &lt;a href=&quot;http://bbs.espressif.com/viewtopic.php?f=46&amp;amp;t=1442&quot; target=&quot;_blank&quot;&gt;Espressif site&lt;/a&gt; (&lt;a href=&quot;http://bbs.espressif.com/download/file.php?id=989&quot; target=&quot;_blank&quot;&gt;direct link&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;i&gt;FLASH_DOWNLOAD_TOOLS_v2.4_150924.rar&lt;/i&gt;&lt;/b&gt; from &lt;a href=&quot;http://bbs.espressif.com/viewtopic.php?f=57&amp;amp;t=433&quot; target=&quot;_blank&quot;&gt;Espressif site&lt;/a&gt; (&lt;a href=&quot;http://bbs.espressif.com/download/file.php?id=856&quot; target=&quot;_blank&quot;&gt;direct link&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h3&gt;
Flash it!&lt;/h3&gt;
To put the ESP module in flashing mode you must connect ESP&#39;s GPIO0 pin to ground.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Unplug the Arduino board from the PC&lt;/li&gt;
&lt;li&gt;Put a jumper between GND and GPIO0 pin (see photo)&lt;/li&gt;
&lt;li&gt;Plug the Arduino board to the PC.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdxjAUiNpYDL6YfyFjM9sJBFeBbEBcB4d89FyDl_84iEJR99ylTnRNE5b9pthIPrdht_4p6po6O8hQffKrklGpZ5At5u16o_7HPR1WUEsfZ_uMrf4VKATAbYebh35BxfCmGDlf9VsV35E/s1600/IMG_20151227_232634.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdxjAUiNpYDL6YfyFjM9sJBFeBbEBcB4d89FyDl_84iEJR99ylTnRNE5b9pthIPrdht_4p6po6O8hQffKrklGpZ5At5u16o_7HPR1WUEsfZ_uMrf4VKATAbYebh35BxfCmGDlf9VsV35E/s320/IMG_20151227_232634.jpg&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Follow these steps to flash the new firmware to the ESP-01 board.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Close the Arduino IDE if still opened &lt;/li&gt;
&lt;li&gt;Launch the ESP flash download tool (&lt;i&gt;ESP_DOWNLOAD_TOOL_V2.4.exe&lt;/i&gt;) you have previously extracted&lt;/li&gt;
&lt;li&gt;Apply the following settings&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Bin files&lt;/b&gt; (from the esp_iot_sdk extracted zip file) : &lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;bin\at\noboot\&lt;b&gt;eagle.flash.bin&lt;/b&gt; - 0x00000&lt;/li&gt;
&lt;li&gt;bin\at\noboot\&lt;b&gt;eagle.irom0text.bin&lt;/b&gt; - 0x40000 &lt;/li&gt;
&lt;li&gt;bin\&lt;b&gt;blank.bin&lt;/b&gt; - 0xfe000&lt;/li&gt;
&lt;li&gt;bin\&lt;b&gt;blank.bin&lt;/b&gt; - 0x7e000&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;&lt;b&gt;Flash size&lt;/b&gt;: 8MBit&lt;/li&gt;
&lt;li&gt;&lt;b&gt;COM port&lt;/b&gt;: choose your Arduino COM port&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Baud rate&lt;/b&gt;: 115200 or 345600 (this is not related to the ESP baud rate &lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHVveUKPFKTXWf7qhad0SS72qRnxKGE7YpDpDgMZ8rRZKlhlp1v2nF681a5hfaLaLUeG2HbWdGhTC9LLATRo1vuaLZ68aQrm5CUoo3i4AnAX-BJiV-BruCRQx_ms-cIpoqsc9qby5-wSk/s1600/flash_1.5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHVveUKPFKTXWf7qhad0SS72qRnxKGE7YpDpDgMZ8rRZKlhlp1v2nF681a5hfaLaLUeG2HbWdGhTC9LLATRo1vuaLZ68aQrm5CUoo3i4AnAX-BJiV-BruCRQx_ms-cIpoqsc9qby5-wSk/s320/flash_1.5.png&quot; width=&quot;220&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;Now press the START button and wait for the flashing process to complete.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwkH4lLIm_cX0x6Lv8jNeMLThndCLOiWoESx2FXvQ2lChhgn-ZoruMUQT1q7WJhoRwWymRhpKxq5XqoS7aFbr2yxX9GeEsnQZLv3RmPQg0v6QXuRqaiZDQGdw9brUheRT6GnX6guyBeTI/s1600/flash_1.5_ok.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwkH4lLIm_cX0x6Lv8jNeMLThndCLOiWoESx2FXvQ2lChhgn-ZoruMUQT1q7WJhoRwWymRhpKxq5XqoS7aFbr2yxX9GeEsnQZLv3RmPQg0v6QXuRqaiZDQGdw9brUheRT6GnX6guyBeTI/s320/flash_1.5_ok.png&quot; width=&quot;220&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now press the STOP button and close the flashing tool.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Test connectivity and set default UART speed&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Before proceeding it is better to verify that the new firmware is working fine.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Unplug the Arduino board from the PC&lt;/li&gt;
&lt;li&gt;Remove the jumper between GND and GPIO0 pin&lt;/li&gt;
&lt;li&gt;Plug the Arduino board to the PC&lt;/li&gt;
&lt;/ol&gt;
Open the Arduino IDE, select the correct COM port and open the serial monitor.&lt;br /&gt;
Test connectivity with &#39;AT&#39; and &#39;AT+GMR&#39; commands. The correct settings for the ESP firmware v1.5 are:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Speed: 115200&lt;/li&gt;
&lt;li&gt;Line ending: Both NL &amp;amp; CR&lt;/li&gt;
&lt;/ul&gt;
If you are going to use the ESP-01 module with Arduino Uno you have to lower the default baud rate because the SoftwareSerial interface maximum speed is around 38400 bps. I suggest to set the ESP module to use 9600 or 19200 bps. To set the correct baud rate use this command:&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;AT+UART_DEF=9600,8,1,0,0&lt;/pre&gt;
&lt;br /&gt;
Now set the serial monitor speed to 9600 and test again the communication.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Rebuild your ESP WiFi shield&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Remove the modifications made to the ESP shield.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Insert the ATmega328P chip back into the Arduino board&lt;/li&gt;
&lt;li&gt;Connect ESP&#39; RDX pin to Arduino pin 7&lt;/li&gt;
&lt;li&gt;Connect ESP&#39;s TXD pin to Arduino pin 6&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Compile and upload the updated sketch and you should be able to correctly interact with the ESP module.&lt;br /&gt;
&lt;br /&gt;
Your ESP8266 board is now flashed with the updated firmware and ready to be used for your connected projects!&lt;br /&gt;
&lt;br /&gt;
Don&#39;t forget to take a look at my &lt;a href=&quot;http://yaab-arduino.blogspot.it/p/wifiesp.html&quot;&gt;WiFiEsp library for Arduino&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/3914284158677595740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/flashing-esp8266-firmware-arduino.html#comment-form' title='24 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/3914284158677595740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/3914284158677595740'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/flashing-esp8266-firmware-arduino.html' title='Flashing ESP8266 firmware v1.5 using Arduino Uno'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEbkjcbSUdvtpgLGjYKq4obJf6QxpXI1PMI5GwbSLZmhN0ZYD0ZDKja4YIiGnFqM_nY4C9Ybojq_V9h1MRxCaPo0vsqNg3Ge20fWiw609ikSMX4yVjvWnvB7PNmaLP9Nt1G9gZF9jOhfM/s72-c/IMG_20151227_001446.jpg" height="72" width="72"/><thr:total>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-830639526584836016</id><published>2015-12-06T02:35:00.002-08:00</published><updated>2015-12-21T06:08:09.407-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="esp8266"/><title type='text'>Cheap Arduino WiFi Shield with ESP8266-01</title><content type='html'>If you want to connect your Arduino with the internet the standard choice is the &lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoWiFiShield&quot; target=&quot;_blank&quot;&gt;Arduino WiFi shield&lt;/a&gt;. However, this is too much expensive since it costs more than 80 USD. Cheaper alternatives based on CC3000 chipset are not meeting my expectations so I have decided to build my own Arduino WiFi shield.&lt;br /&gt;
&lt;br /&gt;
My requirements for the shield are:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;As much as cheap as possible (less than 10 USD)&lt;/li&gt;
&lt;li&gt;Arduino library compatible with the standard Ethernet/WiFi libraries&lt;/li&gt;
&lt;li&gt;Breadboard-friendly (no soldering needed)&lt;/li&gt;
&lt;/ul&gt;
The idea was simply to find a cheap replacement of the standard WiFi shield being able to reuse existing samples and code developed for Ethernet and WiFi shields.&lt;br /&gt;
&lt;br /&gt;
The obvious choice for the WiFi module is the ESP8266-01. ESP8266-01 is great and cheap but there are some problems and limitations:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Arduino boards are typically powered at 5V while ESP8266 needs a &lt;b&gt;3.3V 
power source&lt;/b&gt;. The Arduino 3.3V 
output pin cannot provide the power needed by the ESP (up to 250mA). This can be solved using a &lt;b&gt;3.3V voltage regulator&lt;/b&gt; like the LM1117, LD1117, LD33V or AMS1117. There are 
even more cheaper solutions but I decided to go with a AMS1117 module.&lt;/li&gt;
&lt;li&gt;ESP8266 connector is &lt;b&gt;not breadboard-friendly&lt;/b&gt;. Using the &lt;b&gt;technique described in &lt;a href=&quot;http://yaab-arduino.blogspot.com/2015/12/esp8266-plug-breadboard.html&quot;&gt;this post&lt;/a&gt;&lt;/b&gt; is easy to plug the ESP into a breadboard with no additional hardware.&lt;/li&gt;
&lt;li&gt;ESP8266 default firmware uses AT commands and there is &lt;b&gt;no good library&lt;/b&gt; for the ESP with a programming model similar to the WiFi library. There are some improved firmwares around but I want to use the stock firmware. I have developed &lt;b&gt;my own &lt;a href=&quot;http://yaab-arduino.blogspot.com/2015/05/esp8266-wifi-library.html&quot;&gt;EspWiFi library&lt;/a&gt;&lt;/b&gt; so I can use any existing Arduino WiFi sketch with few little code changes.&lt;/li&gt;
&lt;/ol&gt;
Components&lt;br /&gt;
&lt;ol&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;ESP8266-01 module (3 USD)&lt;/li&gt;
&lt;li&gt;AMS1117 module - 5V To 3.3V DC-DCPower Supply (1 USD)&lt;/li&gt;
&lt;li&gt;Breadboard (2 USD)&lt;/li&gt;
&lt;li&gt;Capacitor (any 10-100 uF is ok)&lt;/li&gt;
&lt;li&gt;2 or 3 resistors&lt;/li&gt;
&lt;li&gt;Jumper wires&lt;/li&gt;
&lt;li&gt;Arduino ProtoShield (3 USD)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
All these components allows you to build a &lt;b&gt;WiFi shield for less than 10 USD&lt;/b&gt; !&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHkwPcUydTVy335LlOCUJcDbiQFblq_79P5hnYJSFXj10Evqo6tsTmD7yvKIPvHwIsHYP8090vRyGSDS9pOEnJgO_phCMH1jCHxRrdJMIuVIHswZfYZBuMjSS0xfDeCtLBp7Xl-oBsEAU/s1600/esp8266-wifi-shield.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;295&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHkwPcUydTVy335LlOCUJcDbiQFblq_79P5hnYJSFXj10Evqo6tsTmD7yvKIPvHwIsHYP8090vRyGSDS9pOEnJgO_phCMH1jCHxRrdJMIuVIHswZfYZBuMjSS0xfDeCtLBp7Xl-oBsEAU/s400/esp8266-wifi-shield.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Look at &lt;a href=&quot;http://www.instructables.com/id/Cheap-Arduino-WiFi-Shield-With-ESP8266/&quot;&gt;this Instructable&lt;/a&gt; for detailed instructions about how to build the ESP WiFi shield.&lt;br /&gt;
&lt;br /&gt;
After having built it you can try my &lt;a href=&quot;http://yaab-arduino.blogspot.com/p/wifiesp.html&quot; target=&quot;_blank&quot;&gt;WiFiEsp library&lt;/a&gt; to connect your Arduino projects to the Internet.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/830639526584836016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/cheap-arduino-wifi-shield-with-esp8266.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/830639526584836016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/830639526584836016'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/cheap-arduino-wifi-shield-with-esp8266.html' title='Cheap Arduino WiFi Shield with ESP8266-01'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHkwPcUydTVy335LlOCUJcDbiQFblq_79P5hnYJSFXj10Evqo6tsTmD7yvKIPvHwIsHYP8090vRyGSDS9pOEnJgO_phCMH1jCHxRrdJMIuVIHswZfYZBuMjSS0xfDeCtLBp7Xl-oBsEAU/s72-c/esp8266-wifi-shield.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-8073461392525225287</id><published>2015-12-04T15:13:00.000-08:00</published><updated>2015-12-04T15:15:50.327-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="esp8266"/><title type='text'>How to plug the ESP8266-01 module to a breadboard</title><content type='html'>One of the most annoying problems of the ESP8266-01 module is that it is not possible to plug it into a breadboard for fast prototyping.&lt;br /&gt;
Today I was discussing with another Arduino fan and we were looking at existing solutions to this common problem. All the existing solutions were complex to implement or are costing more than the ESP module itself.&lt;br /&gt;
I ended up with a &lt;b&gt;smart and free solution with no additional hardware required&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
The solution is easy and requires only a small screwdriver to remove the plastic spacers and pliers to bend the ESP&#39;s pins. &lt;br /&gt;
Pictures are more clear than words in this case.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSgImMJN4C930PMZZSjYkolTcD_Mi_EVimnEQ3mxRG65Ov_QTptE4n1hcOcUtVWwZMLUSG1wEWnZaBdstKko5zqysIJz7AXrGC4ah0viVUlKqpkQXtN5yYi_uSAhcjZw0MnEct8xyYwqk/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSgImMJN4C930PMZZSjYkolTcD_Mi_EVimnEQ3mxRG65Ov_QTptE4n1hcOcUtVWwZMLUSG1wEWnZaBdstKko5zqysIJz7AXrGC4ah0viVUlKqpkQXtN5yYi_uSAhcjZw0MnEct8xyYwqk/s320/1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwg_Quh6ohKtCBzdhRqXkD6bE2o9QaoeE5F2a41v7Y3T7LWRvyE6xr9Htb-4uEqUZW1XaDwQOLdcGihC3PmNk44RU5MNyxH-QKf7FVEVhuhBj0To4vL4bfLJrfF-hj1r1SlGcAkAuO334/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;239&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwg_Quh6ohKtCBzdhRqXkD6bE2o9QaoeE5F2a41v7Y3T7LWRvyE6xr9Htb-4uEqUZW1XaDwQOLdcGihC3PmNk44RU5MNyxH-QKf7FVEVhuhBj0To4vL4bfLJrfF-hj1r1SlGcAkAuO334/s320/2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCK_Jt0jgo10UAwuH3TCFZCP-JT7r6hE48y5OV_8M5Oi4a7ImCLYOuHgqO25gV_yH0yZiTfxgbDFtx-x8JGPDg5ogajwr4irsNCRAippvcG3wXeOC1SFYrKtiQ1KWzyxdUcqDdPwQZbdg/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;256&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCK_Jt0jgo10UAwuH3TCFZCP-JT7r6hE48y5OV_8M5Oi4a7ImCLYOuHgqO25gV_yH0yZiTfxgbDFtx-x8JGPDg5ogajwr4irsNCRAippvcG3wXeOC1SFYrKtiQ1KWzyxdUcqDdPwQZbdg/s320/3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsJpTVNQoaBG7mG3uycHxVJZJ3E13bVIPyL26KO0YN2hWvfYABTD5V0yLHcwOg1TqS4_CjbyOj1YhuEXw7BhLRL7_npFNd06GKKP3V1ezXR_XPEM5xNVLloWaI7wEauaqsRD-kQOHrgtM/s1600/4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;284&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsJpTVNQoaBG7mG3uycHxVJZJ3E13bVIPyL26KO0YN2hWvfYABTD5V0yLHcwOg1TqS4_CjbyOj1YhuEXw7BhLRL7_npFNd06GKKP3V1ezXR_XPEM5xNVLloWaI7wEauaqsRD-kQOHrgtM/s320/4.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhenxCHOCGuXJ6mbp0qiKBAzB3SLj4j_XNUicQuxgNxjUdDz5mIndXonRjxCOosb_F6rcQLW_S4WQAKZ7wl5neEFq3I03rs5aVxch-XE6KMbucZD_cwjyoPbp2hqILOWW16YUZJY980ZQU/s1600/5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;231&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhenxCHOCGuXJ6mbp0qiKBAzB3SLj4j_XNUicQuxgNxjUdDz5mIndXonRjxCOosb_F6rcQLW_S4WQAKZ7wl5neEFq3I03rs5aVxch-XE6KMbucZD_cwjyoPbp2hqILOWW16YUZJY980ZQU/s320/5.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span id=&quot;goog_474282142&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_474282143&quot;&gt;&lt;/span&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/8073461392525225287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/esp8266-plug-breadboard.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8073461392525225287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8073461392525225287'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/12/esp8266-plug-breadboard.html' title='How to plug the ESP8266-01 module to a breadboard'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSgImMJN4C930PMZZSjYkolTcD_Mi_EVimnEQ3mxRG65Ov_QTptE4n1hcOcUtVWwZMLUSG1wEWnZaBdstKko5zqysIJz7AXrGC4ah0viVUlKqpkQXtN5yYi_uSAhcjZw0MnEct8xyYwqk/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-4827187582053243834</id><published>2015-05-18T14:47:00.001-07:00</published><updated>2015-12-29T11:15:07.725-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="esp8266"/><category scheme="http://www.blogger.com/atom/ns#" term="wifiesp"/><title type='text'>ESP8266 WiFi library</title><content type='html'>After several nights spent developing and tweaking I finally have a working ESP8266 WiFi library called &lt;b&gt;WiFiEsp&lt;/b&gt;.&lt;br /&gt;
The main characteristic of the WiFiEsp library is that is fully compatible with the standard library for the Arduino WiFi shield. This gives a cheap alternative to the expensive WiFi shield to connect Arduino to the Internet.&lt;br /&gt;
It uses hardware Serial1 if exists or emulate a second serial port on pins 6 and 7.&lt;br /&gt;
You can &lt;a href=&quot;https://github.com/bportaluri/WiFiEsp&quot; target=&quot;_blank&quot;&gt;download WiFiEsp library&lt;/a&gt; from GitHub. &lt;br /&gt;
Please give it a try and tell me what you think.&lt;br /&gt;
&lt;br /&gt;
Here is a small sketch that connects to a WiFi network. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;#include &quot;WiFiEsp.h&quot;

// Emulate Serial1 on pins 7/6 if not present
#ifndef HAVE_HWSERIAL1
#include &quot;SoftwareSerial.h&quot;
SoftwareSerial Serial1(6, 7); // RX, TX
#endif

char ssid[] = &quot;Twim&quot;;            // your network SSID (name)
char pass[] = &quot;12345678&quot;;        // your network password

void setup()
{
  Serial.begin(115200);  // initialize serial for debugging
  Serial1.begin(9600);   // initialize serial for ESP
  WiFi.init(&amp;Serial1);   // initialize ESP serial port

  if (WiFi.status() == WL_NO_SHIELD) {   // check for the presence of the shield
    Serial.println(&quot;WiFi shield not present&quot;);
    while (true);                        // don&#39;t continue:
  }
}

void loop()
{
  // attempt to connect to Wifi network:
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(&quot;Attempting to connect to WPA SSID: &quot;);
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:
    WiFi.begin(ssid, pass);
  }

  // you&#39;re connected now, so print out the data:
  Serial.println(&quot;You&#39;re connected to the network&quot;);
  
  IPAddress ip = WiFi.localIP();
  Serial.print(&quot;IP Address: &quot;);
  Serial.println(ip);

  delay(10000);
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/4827187582053243834/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/05/esp8266-wifi-library.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/4827187582053243834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/4827187582053243834'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/05/esp8266-wifi-library.html' title='ESP8266 WiFi library'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-2167991743905860546</id><published>2015-05-02T02:27:00.003-07:00</published><updated>2015-05-02T02:29:25.874-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="ledmatrix"/><category scheme="http://www.blogger.com/atom/ns#" term="max7219"/><title type='text'>Beating heart with Arduino and a MAX7219 8x8 LED matrix</title><content type='html'>This is a very simple project to display a beating heart using and Arduino board and a 8x8 LED matrix driven by a MAX7219 chip.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlX1kRkZ9al21_pTfphrRwsmusaBshOguDlomJ6tXJMHMqacSam-RbKBwxT0jp07HuhgpHta5DbO6-LyhXYQBQZ6G1sfSA_tYX3NMhNk79zeAMvMiJiJYfakHFyje4GtJ0rCyLHsIMSBI/s1600/IMG_20150502_112644.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlX1kRkZ9al21_pTfphrRwsmusaBshOguDlomJ6tXJMHMqacSam-RbKBwxT0jp07HuhgpHta5DbO6-LyhXYQBQZ6G1sfSA_tYX3NMhNk79zeAMvMiJiJYfakHFyje4GtJ0rCyLHsIMSBI/s1600/IMG_20150502_112644.jpg&quot; height=&quot;320&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
The wiring is very simple.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;MAX7219 VCC pin &amp;gt; Arduino 5V pin&lt;/li&gt;
&lt;li&gt;MAX7219 GND pin &amp;gt; Arduino GND pin&lt;/li&gt;
&lt;li&gt;MAX7219 DIN pin &amp;gt; Arduino pin 2&lt;/li&gt;
&lt;li&gt;MAX7219 CS pin &amp;gt; Arduino pin 3&lt;/li&gt;
&lt;li&gt;MAX7219 CLOCK pin &amp;gt; Arduino pin 4&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
The Arduino sketch is not using any library so this is 
also good to understand how to directly drive the MAX7219 chip through 
registers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;int ANIMDELAY = 100;  // animation delay, deafault value is 100
int INTENSITYMIN = 0; // minimum brightness, valid range [0,15]
int INTENSITYMAX = 8; // maximum brightness, valid range [0,15]

int DIN_PIN = 2;      // data in pin
int CS_PIN = 3;       // load (CS) pin
int CLK_PIN = 4;      // clock pin

// MAX7219 registers
byte MAXREG_DECODEMODE = 0x09;
byte MAXREG_INTENSITY  = 0x0a;
byte MAXREG_SCANLIMIT  = 0x0b;
byte MAXREG_SHUTDOWN   = 0x0c;
byte MAXREG_DISPTEST   = 0x0f;

const unsigned char heart[] =
{
  B01100110,
  B11111111,
  B11111111,
  B11111111,
  B01111110,
  B00111100,
  B00011000,
  B00000000
};



void setup ()
{
  pinMode(DIN_PIN, OUTPUT);
  pinMode(CLK_PIN, OUTPUT);
  pinMode(CS_PIN, OUTPUT);

  // initialization of the MAX7219
  setRegistry(MAXREG_SCANLIMIT, 0x07);
  setRegistry(MAXREG_DECODEMODE, 0x00);  // using an led matrix (not digits)
  setRegistry(MAXREG_SHUTDOWN, 0x01);    // not in shutdown mode
  setRegistry(MAXREG_DISPTEST, 0x00);    // no display test
  setRegistry(MAXREG_INTENSITY, 0x0f &amp;amp; INTENSITYMIN);

  // draw hearth
  setRegistry(1, heart[0]);
  setRegistry(2, heart[1]);
  setRegistry(3, heart[2]);
  setRegistry(4, heart[3]);
  setRegistry(5, heart[4]);
  setRegistry(6, heart[5]);
  setRegistry(7, heart[6]);
  setRegistry(8, heart[7]);
}


void loop ()
{
  // second beat
  setRegistry(MAXREG_INTENSITY, 0x0f &amp;amp; INTENSITYMAX);
  delay(ANIMDELAY);
  
  // switch off
  setRegistry(MAXREG_INTENSITY, 0x0f &amp;amp; INTENSITYMIN);
  delay(ANIMDELAY);
  
  // second beat
  setRegistry(MAXREG_INTENSITY, 0x0f &amp;amp; INTENSITYMAX);
  delay(ANIMDELAY);
  
  // switch off
  setRegistry(MAXREG_INTENSITY, 0x0f &amp;amp; INTENSITYMIN);
  delay(ANIMDELAY*6);
}


void setRegistry(byte reg, byte value)
{
  digitalWrite(CS_PIN, LOW);

  putByte(reg);   // specify register
  putByte(value); // send data

  digitalWrite(CS_PIN, LOW);
  digitalWrite(CS_PIN, HIGH);
}

void putByte(byte data)
{
  byte i = 8;
  byte mask;
  while (i &amp;gt; 0)
  {
    mask = 0x01 &amp;lt;&amp;lt; (i - 1);        // get bitmask
    digitalWrite( CLK_PIN, LOW);   // tick
    if (data &amp;amp; mask)               // choose bit
      digitalWrite(DIN_PIN, HIGH); // send 1
    else
      digitalWrite(DIN_PIN, LOW);  // send 0
    digitalWrite(CLK_PIN, HIGH);   // tock
    --i;                           // move to lesser bit
  }
}
&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/2167991743905860546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/05/beating-heart-with-arduino-and-max7219.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/2167991743905860546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/2167991743905860546'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/05/beating-heart-with-arduino-and-max7219.html' title='Beating heart with Arduino and a MAX7219 8x8 LED matrix'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlX1kRkZ9al21_pTfphrRwsmusaBshOguDlomJ6tXJMHMqacSam-RbKBwxT0jp07HuhgpHta5DbO6-LyhXYQBQZ6G1sfSA_tYX3NMhNk79zeAMvMiJiJYfakHFyje4GtJ0rCyLHsIMSBI/s72-c/IMG_20150502_112644.jpg" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-5202969801751879210</id><published>2015-04-01T08:56:00.000-07:00</published><updated>2015-12-05T04:02:42.318-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="esp8266"/><title type='text'>ESP8266 wiring schemas</title><content type='html'>In this page I want to collect some examples (of increasing complexity) to connect the ESP8266 to Arduino boards.&lt;br /&gt;
All the wiring schemes and examples are based on an Arduino One and an 8-pins ESP8266 module also know as ESP-01. Arduino pins 6 and 7 will be used as a second serial port using SoftwareSerial library as described &lt;a href=&quot;http://yaab-arduino.blogspot.com/2015/03/debugging-esp8266-commands-with-arduino.html&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;
&lt;tr bgcolor=&quot;#ddd&quot;&gt;
    &lt;th&gt;Schema&lt;/th&gt;
    &lt;th&gt;Power&lt;/th&gt;
    &lt;th&gt;RX&lt;/th&gt;
    &lt;th&gt;TX&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;1) Basic&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;2) Powering with diodes&lt;/td&gt;
    &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;3) Powering with Zener diode&lt;/td&gt;
    &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;4) Powering with voltage regulator&lt;/td&gt;
    &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;5) RX level shifter with resistors&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;6) RX level shifter with diode&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
    &lt;td&gt;Y&lt;/td&gt;
    &lt;td&gt;N&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
1) Basic &lt;/h3&gt;
Here are the ESP-01 pins.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjJ0E3YnTIhfnccz0yblX8J16wvT1q0ASMI2HB7FUAw3ykU0HvyeOi-wn3HPrt0-PyXNXeFhwjcOWADqn9xFhHoSkQsPz-B4hMKqDZTvbfFxoh7r5Rd0Cr2_WCWIw3AFm1KTrJh3gVY8/s1600/esp8266_pinout.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjJ0E3YnTIhfnccz0yblX8J16wvT1q0ASMI2HB7FUAw3ykU0HvyeOi-wn3HPrt0-PyXNXeFhwjcOWADqn9xFhHoSkQsPz-B4hMKqDZTvbfFxoh7r5Rd0Cr2_WCWIw3AFm1KTrJh3gVY8/s1600/esp8266_pinout.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The most basic connection scheme is this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk6CpQBFCne8xwL_s01uSoDiE-ft2VlnZpXWGej5ju2aiWp06Lo0TCAZHq26V0GnlVQuQQVkSYaduq4Y34fQbpZrjDJptdUXfR0Sm259xkuiHrgF77LKqgIlY83Yd6evMKz4iBzbfmBjY/s1600/ESP8266_arduino_basic_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk6CpQBFCne8xwL_s01uSoDiE-ft2VlnZpXWGej5ju2aiWp06Lo0TCAZHq26V0GnlVQuQQVkSYaduq4Y34fQbpZrjDJptdUXfR0Sm259xkuiHrgF77LKqgIlY83Yd6evMKz4iBzbfmBjY/s1600/ESP8266_arduino_basic_bb.png&quot; width=&quot;385&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Wiring&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Arduino 3.3v power &amp;gt; breadboard red power rail&lt;/li&gt;
&lt;li&gt;Arduino GND &amp;gt; breadboard black ground rail&lt;/li&gt;
&lt;li&gt;ESP8266 GND &amp;gt; ground rail&lt;/li&gt;
&lt;li&gt;ESP8266 VCC &amp;gt; power rail&lt;/li&gt;
&lt;li&gt;ESP8266 CH_PD &amp;gt; power rail&lt;/li&gt;
&lt;li&gt;ESP8266 TXD &amp;gt; Arduino Digital Pin #6 (RX pin using software serial)&lt;/li&gt;
&lt;li&gt;ESP8266 RXD &amp;gt; Arduino Digital Pin #7 (TX pin using software serial)&lt;/li&gt;
&lt;li&gt;A 100uF (or larger) capacitor helps to absorb current spikes&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
This schema has three main problems:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Power source&lt;/b&gt;: Arduino boards are typically powered at 5V while ESP8266 needs a 3.3V power source. The ESP can draw up to 250mA while the Arduino Uno 3.3V output pin can provide only 50mA. A capacitor can help but it&#39;s not enough.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;RX&lt;/b&gt;: The 5V Arduino TX serial output needs to be shifted to the 3.3V ESP RX input. However, simple prototypes can be built without this because the ESP has a built in protection.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;TX&lt;/b&gt;: The 3.3V ESP TX output should be enough for the 5V Arduino digital input. A reliable project may need a level shifter.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
The next wiring schemes will show different approaches to provide a reliable 3.3V power source to the ESP.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
2) Powering with diodes&lt;/h3&gt;
Since the &lt;b&gt;Arduino 5V pin&lt;/b&gt; can provide 200mA we can use this to power the ESP. This schema is very cheap and simple allowing to use simple and cheap diodes to convert the 5V to 3.6V. Suitable diodes are the 1N4148 (300 mA) or the 1N4007 (1 A). &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNdO4HJAobGLP_ptu7vA_25K26zk8yWpysZYPMeW-fqyoE-acgsGfyLb-rLKfV5Ed4trZet7MrwT4pIR-FLwDSW3NCRxVcNFIbDc_MiDfLhm4_vVLbShwWI9AliY-XttZ_kOpqdeCVSkI/s1600/ESP8266_arduino_power_diodes_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNdO4HJAobGLP_ptu7vA_25K26zk8yWpysZYPMeW-fqyoE-acgsGfyLb-rLKfV5Ed4trZet7MrwT4pIR-FLwDSW3NCRxVcNFIbDc_MiDfLhm4_vVLbShwWI9AliY-XttZ_kOpqdeCVSkI/s1600/ESP8266_arduino_power_diodes_bb.png&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
3) Powering with Zener diode&lt;/h3&gt;
An alternative cheap approach is to use a 1N5226 3.3V Zener diode to power the ESP as described &lt;a href=&quot;http://www.instructables.com/id/Level-Shifting-Between-TTL-and-CMOS/step4/Using-a-Zener-Diode/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvynxLRhjJloG06TLSnv7Q6pzAP7uEANxqLCbP4HJXL6T0syAmx3JBa-pK4WySWKiThuVqdGV0l_PRDeZjqRBCX6pwlqeO9iRWydNpo_4Sz7J3KI5iUiXpokKkFqqwowO0E8zLQUV1wlg/s1600/ESP8266_arduino_power_zener_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvynxLRhjJloG06TLSnv7Q6pzAP7uEANxqLCbP4HJXL6T0syAmx3JBa-pK4WySWKiThuVqdGV0l_PRDeZjqRBCX6pwlqeO9iRWydNpo_4Sz7J3KI5iUiXpokKkFqqwowO0E8zLQUV1wlg/s1600/ESP8266_arduino_power_zener_bb.png&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
4) Powering with voltage regulator (LM1117/LD1117)&lt;/h3&gt;
Several cheap 3.3V regulators are available on the market. A very common and cheap one is the LM1117 (or LD1117). With such regulator you can convert the 5V power used for Arduino to the 3.3V needed by the ESP.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX2gWV-NPEo26Rp49R-yaVighyphenhyphenCMhrx58w6bvBAiOhbxRxJbyDmvpyujwVvAPeJx2ptFNa2EMfq6ufTXWhMn4KqNcC8OFv4DvROTFthSlsV2BoWDkawJF2un5fFqeYSecAkO1cNV5B8EE/s1600/ESP8266_arduino_power_lm1117_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX2gWV-NPEo26Rp49R-yaVighyphenhyphenCMhrx58w6bvBAiOhbxRxJbyDmvpyujwVvAPeJx2ptFNa2EMfq6ufTXWhMn4KqNcC8OFv4DvROTFthSlsV2BoWDkawJF2un5fFqeYSecAkO1cNV5B8EE/s1600/ESP8266_arduino_power_lm1117_bb.png&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
An AMS1117 module is also a great choice.&lt;br /&gt;
A generic voltage regulator like the LM317T can be used as described in &lt;a href=&quot;http://www.esp8266.com/viewtopic.php?f=8&amp;amp;t=2031&quot; target=&quot;_blank&quot;&gt;this post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
5) RX level shifter with resistors&lt;/h3&gt;
&amp;nbsp;The 5V output from the Arduino TX pin can be shifted to 3.3V using a resistor &lt;a href=&quot;http://appnote.avrportal.com/calculator/resistor-voltage-divider&quot; target=&quot;_blank&quot;&gt;voltage divider&lt;/a&gt;.&lt;br /&gt;
&amp;nbsp;In this schema I have used &lt;b&gt;three 220 Ohm resistors&lt;/b&gt; for an output current of 7.5 mA.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_tIU1ZpExs0hn0hnuCCCeBQMr-JlEl24G9v43eEqkChN77hjGKzIPPzNYbJEChtut3Cpr82pBhvB3aXlqo4kSQ4F5_o1VBAMrlJqhsdzGaohLP69A-Jh2c6wI658f3tVrR3o1uEUPMcA/s1600/ESP8266_arduino_tx_resistor_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_tIU1ZpExs0hn0hnuCCCeBQMr-JlEl24G9v43eEqkChN77hjGKzIPPzNYbJEChtut3Cpr82pBhvB3aXlqo4kSQ4F5_o1VBAMrlJqhsdzGaohLP69A-Jh2c6wI658f3tVrR3o1uEUPMcA/s320/ESP8266_arduino_tx_resistor_bb.png&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
6) RX level shifter with Diode&lt;/h3&gt;
&lt;br /&gt;
You can use a 1N4148 diode on the Arduino TX pin as well to lower the voltage of the signal.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpfBZfCxho82Ap_qcIRP0CBamEPcrFNmFyzUlwpRerjtRZYjlwF0kfKwrDoC8pBm2wIKBqNjLoMm5v1Wg2D0Ez7mwTWY2vyy9R4bqDPhY4pFkVs-k-m0VP2AoGru8lwJevOR19bLY-_k8/s1600/ESP8266_arduino_tx_diode_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpfBZfCxho82Ap_qcIRP0CBamEPcrFNmFyzUlwpRerjtRZYjlwF0kfKwrDoC8pBm2wIKBqNjLoMm5v1Wg2D0Ez7mwTWY2vyy9R4bqDPhY4pFkVs-k-m0VP2AoGru8lwJevOR19bLY-_k8/s1600/ESP8266_arduino_tx_diode_bb.png&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Putting all together&lt;/h3&gt;
&lt;br /&gt;
Now pick your preferred schemes to build your perfect Arduino/ESP wiring.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
References&lt;/h3&gt;
&lt;br /&gt;
&lt;a href=&quot;http://jamesreubenknowles.com/level-shifting-stragety-experments-1741&quot;&gt;5V to 3.3V Logic Level Shifting&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/5202969801751879210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/03/esp8266-wiring-schemas.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/5202969801751879210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/5202969801751879210'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/03/esp8266-wiring-schemas.html' title='ESP8266 wiring schemas'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjJ0E3YnTIhfnccz0yblX8J16wvT1q0ASMI2HB7FUAw3ykU0HvyeOi-wn3HPrt0-PyXNXeFhwjcOWADqn9xFhHoSkQsPz-B4hMKqDZTvbfFxoh7r5Rd0Cr2_WCWIw3AFm1KTrJh3gVY8/s72-c/esp8266_pinout.png" height="72" width="72"/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-5915863611006785082</id><published>2015-03-31T00:50:00.001-07:00</published><updated>2016-06-03T04:23:18.003-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="esp8266"/><title type='text'>ESP8266 Resources</title><content type='html'>&lt;br /&gt;
Here is my current list of links for the ESP8266 and Arduino.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Wiring&lt;/h3&gt;
&lt;ul&gt;
&lt;/ul&gt;
I have collected some wiring schemes of increasing complexity in &lt;a href=&quot;http://yaab-arduino.blogspot.co.uk/2015/03/esp8266-wiring-schemas.html&quot;&gt;this post&lt;/a&gt;.&lt;br /&gt;
However I have developed my own wiring scheme and described it in this &lt;a href=&quot;http://www.instructables.com/id/Cheap-Arduino-WiFi-Shield-With-ESP8266/&quot; target=&quot;_blank&quot;&gt;Instructable&lt;/a&gt;. I think is easier for many people to start with a solid and tested scheme.&lt;br /&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h3&gt;
Libraries&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;&lt;a href=&quot;https://github.com/bportaluri/WiFiEsp&quot; target=&quot;_blank&quot;&gt;WiFiEsp&lt;/a&gt;&lt;/b&gt; : This is my own library. It is designed to be very similar to standard Arduino Ethernet and WiFi shield libraries. The idea is to be able to reuse existing sketches and projects with this cheap ESP module. You can find more information on &lt;a href=&quot;http://yaab-arduino.blogspot.com/p/wifiesp.html&quot;&gt;this post&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/itead/ITEADLIB_Arduino_WeeESP8266&quot; target=&quot;_blank&quot;&gt;ITEADLIB_Arduino_WeeESP8266&lt;/a&gt; : Seems to be the most stable and reliable ESP library at the moment (Apr 2015).&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/Diaoul/arduino-ESP8266&quot; target=&quot;_blank&quot;&gt;arduino-ESP8266&lt;/a&gt; : Seems a good library &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.thaieasyelec.com/downloads/EWLM107/TEE_ESP_WIFI.7z&quot; target=&quot;_blank&quot;&gt;ThaiEasyElec (TEE_ESP)&lt;/a&gt; : Works only with SoftwareSerial, low level functions, poor documentation, no website or GIT repository.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/iot-playground/Arduino/tree/master/Esp8266EasyIoT&quot; target=&quot;_blank&quot;&gt;ESP8266 EasyIoT&lt;/a&gt; :&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/adafruit/Adafruit_ESP8266&quot; target=&quot;_blank&quot;&gt;Adafruit&lt;/a&gt;: Seems a good library, debugging functions, missing high level functions.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/tuanpmt/espduino&quot; target=&quot;_blank&quot;&gt;espduino&lt;/a&gt; : Wifi library (Chip ESP8266 Wifi soc) for Arduino using SLIP protocol (custom firmware) via serial port. &lt;a href=&quot;https://github.com/tuanpmt/espduino/releases/tag/v0.1-alpha&quot; target=&quot;_blank&quot;&gt;Release 0.1&lt;/a&gt; was based on AT commands.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/giannoug/ESP8266&quot; target=&quot;_blank&quot;&gt;ESP8266&lt;/a&gt; : Another library. Nothing special.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/chiknhed/esp8266_client&quot; target=&quot;_blank&quot;&gt;ESP8266_client&lt;/a&gt; :&amp;nbsp; A lightweight library for client connections. Nothing special.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/sleemanj/ESP8266_Simple&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;ESP8266_Simple&lt;/a&gt; :&amp;nbsp; Well documented, works only with SoftwareSerial, few functions.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h3&gt;
Reference documentation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://nurdspace.nl/ESP8266&quot; target=&quot;_blank&quot;&gt;Nurdspace&lt;/a&gt; : This is the homepage for a lot of ESP8266 information: &lt;a href=&quot;https://nurdspace.nl/images/e/e0/ESP8266_Specifications_English.pdf&quot; target=&quot;_blank&quot;&gt;specifications&lt;/a&gt;, &lt;a href=&quot;https://nurdspace.nl/File:ESP8266_Specifications_English.pdf&quot; target=&quot;_blank&quot;&gt;datasheet&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/espressif/esp8266_at/wiki&quot; target=&quot;_blank&quot;&gt;AT commands&lt;/a&gt;: Official AT commands documentation from Espressif. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h3&gt;
Flashing the firmware &lt;/h3&gt;
I have developed &lt;a href=&quot;http://yaab-arduino.blogspot.com/2015/12/flashing-esp8266-firmware-arduino.html&quot;&gt;my own procedure&lt;/a&gt; using Arduino board for flashing the ESP.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://bbs.espressif.com/viewforum.php?f=46&quot; target=&quot;_blank&quot;&gt;Espressif firmware&lt;/a&gt; : This is the standard firmware for the ESP8266.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/folderview?id=0B_ctPy0pJuW6d1FqM1lvSkJmNU0&amp;amp;usp=sharing&quot; target=&quot;_blank&quot;&gt;AT-thinker Firmware&lt;/a&gt; : An alternative firmware is provided by AT-thinker with few additional commands.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.esp8266.com/viewtopic.php?f=6&amp;amp;t=2634#p16574&quot; target=&quot;_blank&quot;&gt;Flashing new firmware to ESP-01 modules&lt;/a&gt; :&amp;nbsp;Flashing new firmware (v1.1 and above) to ESP-01 modules with&amp;nbsp;512kb flash size.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mbed.org/users/sschocke/code/WiFiLamp/wiki/Updating-ESP8266-Firmware&quot; target=&quot;_blank&quot;&gt;Updating the ESP8266 firmware&lt;/a&gt; :Wiring scheme. Old XTCOM utility used.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.xess.com/blog/esp8266-reflash/&quot; target=&quot;_blank&quot;&gt;ESP8266: Reflash Dance!&lt;/a&gt; : Good article using esp8266_flasher tool&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blog.electrodragon.com/cloud-updating-your-wi07c-esp8266-now/&quot; target=&quot;_blank&quot;&gt;Cloud updating your Wi07C ESP8266 now!&lt;/a&gt; : Shows how to update the ESP8266 firmware from internet.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Other resources&lt;/h3&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://bbs.espressif.com/&quot; target=&quot;_blank&quot;&gt;Espressif forum&lt;/a&gt;: &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.esp8266.com/&quot; target=&quot;_blank&quot;&gt;ESP8266 forum&lt;/a&gt; : This is a community forum 
centered around the ESP8266. Everything is here, but probably best to 
read this stuff after going through a complete design example.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.electrodragon.com/w/Wi07c&quot; target=&quot;_blank&quot;&gt;Electrodragon wiki&lt;/a&gt; : Wiki page with multiple sets of information and links for using the ESP8266.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://espressif.com/en/products/esp8266/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Espressif&lt;/a&gt; is the 
manufacturer of the ESP8266. Their site is pretty much a bunch of 
marketing hoo-hah and you&#39;ll have to &quot;contact&quot; them for more 
information. Not too useful.&lt;/li&gt;
&lt;li&gt;http://blog.electrodragon.com/esp8266-gpio-test-edited-firmware/ : A 
demo of turning the LEDs on the ESP8266 board on/off over the Wifi link.&lt;/li&gt;
&lt;li&gt;http://scargill.wordpress.com : Peter Scargill has been pretty thorough 
in documenting his experiences in getting the ESP8266 up and running and
 delving into some of the capabilities of the chip. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/5915863611006785082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/03/esp8266-resources.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/5915863611006785082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/5915863611006785082'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/03/esp8266-resources.html' title='ESP8266 Resources'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-5032202571579859536</id><published>2015-03-28T14:56:00.000-07:00</published><updated>2015-12-17T23:59:37.184-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="esp8266"/><category scheme="http://www.blogger.com/atom/ns#" term="intermediate"/><title type='text'>Debugging ESP8266 commands with Arduino Uno</title><content type='html'>I have recently received an ESP8266 that is a tiny and cheap WiFi module that can be controlled through serial interface commands. I have read several blogs and forums to understand how to make it work. I finally found my own approach of testing this little toy.&lt;br /&gt;
&lt;br /&gt;
ESP8266 pins are described in this diagram.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjJ0E3YnTIhfnccz0yblX8J16wvT1q0ASMI2HB7FUAw3ykU0HvyeOi-wn3HPrt0-PyXNXeFhwjcOWADqn9xFhHoSkQsPz-B4hMKqDZTvbfFxoh7r5Rd0Cr2_WCWIw3AFm1KTrJh3gVY8/s1600/esp8266_pinout.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjJ0E3YnTIhfnccz0yblX8J16wvT1q0ASMI2HB7FUAw3ykU0HvyeOi-wn3HPrt0-PyXNXeFhwjcOWADqn9xFhHoSkQsPz-B4hMKqDZTvbfFxoh7r5Rd0Cr2_WCWIw3AFm1KTrJh3gVY8/s1600/esp8266_pinout.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
These are few important things I have discovered:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;Power&lt;/b&gt; - The ESP8266 needs 3.3V power. The ESP can draw up to 250mA while the Arduino Uno 3.3 output pin can provide only 50mA. In serious project you need a good 3.3V power source but for playing and debugging the Arduino Uno 3.3V output pin can be enough.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;CH_PD pin&lt;/b&gt; - The CH_PD pin needs to be held high so connect it to VCC also.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;TX/RX&lt;/b&gt; -In theory you TX and RX pins accept 3.3V so you need level shifters to adapt Arduino&#39;s 5V signals. However, I found out that it just works without level shifters.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Debugging&lt;/b&gt; - To debug the ESP&#39;s commands you need 2 serial ports. One (the default one) is used by the Arduino Serial Monitor so it can be used to debug. The ESP will be attached to the second serial port but unfortunately the Arduino Uno has just one serial port. Some approaches require additional hardware or an Arduino Mega but I have found that the Software Serial library allows to emulate a serial port so I will use this simpler approach.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;h3&gt;
Wiring&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6CfG4A6ecF64CXyrnouhbdSG1FutxIgqLPGzt3gy8GOijqQEr6TcoUMZngYZ62BX5-lWPRvhiFIm2sO17g2lv7aJkFTnkcTtDO410YTJ64ZLX3VyzTi2S9_2gyvUeRtabk_uoxVkIquQ/s1600/ESP8266_arduino_basic_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6CfG4A6ecF64CXyrnouhbdSG1FutxIgqLPGzt3gy8GOijqQEr6TcoUMZngYZ62BX5-lWPRvhiFIm2sO17g2lv7aJkFTnkcTtDO410YTJ64ZLX3VyzTi2S9_2gyvUeRtabk_uoxVkIquQ/s1600/ESP8266_arduino_basic_bb.png&quot; width=&quot;385&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;NOTE: This is not a perfect wiring scheme because it doesn&#39;t use level shifters. Use at your own risk!&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Connections are:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Arduino 3.3v power &amp;gt; breadboard red power rail&lt;/li&gt;
&lt;li&gt;Arduino GND &amp;gt; breadboard black ground rail&lt;/li&gt;
&lt;li&gt;ESP8266 GND &amp;gt; ground rail&lt;/li&gt;
&lt;li&gt;ESP8266 VCC &amp;gt; power rail &lt;/li&gt;
&lt;li&gt;ESP8266 CH_PD &amp;gt; power rail&lt;/li&gt;
&lt;li&gt;ESP8266 TXD &amp;gt; Arduino Digital Pin #6 (RX pin using software serial)&lt;/li&gt;
&lt;li&gt;ESP8266 RXD &amp;gt; Arduino Digital Pin #7 (TX pin using software serial)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h3&gt;
Code&lt;/h3&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;#include &quot;SoftwareSerial.h&quot;

SoftwareSerial esp8266(6, 7); // RX, TX

void setup()
{
  Serial.begin(115200); // serial port used for debugging
  esp8266.begin(9600);  // your ESP&#39;s baud rate might be different
}
 
void loop()
{
  if(esp8266.available())  // check if the ESP is sending a message
  {
    while(esp8266.available())
    {
      char c = esp8266.read();  // read the next character.
      Serial.write(c);  // writes data to the serial monitor
    }
  }
 
  if(Serial.available())
  {
    delay(10);  // wait to let all the input command in the serial buffer

    // read the input command in a string
    String cmd = &quot;&quot;;
    while(Serial.available())
    {
      cmd += (char)Serial.read();
    }

    // print the command and send it to the ESP
    Serial.println(&quot;---------------------&quot;);
    Serial.print(&quot;&amp;gt;&amp;gt; &quot;);
    Serial.println(cmd);
    Serial.println(&quot;---------------------&quot;);
    esp8266.println(cmd); // send the read character to the esp8266
  }
}&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
Commands&lt;/h3&gt;
Now that you have wired your ESP and uploaded the sketch to Arduino you can open the serial monitor and play with the &#39;AT&#39; commands.&lt;br /&gt;
Remember to set the baud rate to 115200. Newer ESP modules also require to send NL &amp;amp; CR characters.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEDQ7bRUse5G3_WcKX36B90X4rDGyUXEh_2wzJeMzsCmCWAcSFx8p5SkSHH-Wv-hpZBS8mTkYUHbIwHZlcTLPmYGDc0fMbeltN6BIFR7OBPGWdq5F1q_4bqnLlwrymrTu8COCfN52hbc8/s1600/esp8266_serial_monitor.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;239&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEDQ7bRUse5G3_WcKX36B90X4rDGyUXEh_2wzJeMzsCmCWAcSFx8p5SkSHH-Wv-hpZBS8mTkYUHbIwHZlcTLPmYGDc0fMbeltN6BIFR7OBPGWdq5F1q_4bqnLlwrymrTu8COCfN52hbc8/s1600/esp8266_serial_monitor.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The main ESP8266 AT commands are listed here.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;AT&lt;/b&gt; - Test &lt;/li&gt;
&lt;li&gt;&lt;b&gt;AT+RST&lt;/b&gt; - Reset&lt;/li&gt;
&lt;li&gt;&lt;b&gt;AT+CWLAP&lt;/b&gt; - List WiFi available networks&lt;/li&gt;
&lt;li&gt;&lt;b&gt;AT+CWJAP=&quot;SSID&quot;,&quot;PWD&quot;&lt;/b&gt; - Connect to a network (change SSID and PWD to match your access point)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;AT+CWJAP?&lt;/b&gt; - Check if connected successfully&lt;/li&gt;
&lt;/ul&gt;
For a full list of commands refer to &lt;a href=&quot;http://www.pighixxx.com/test/2014/12/esp8266/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;this document&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/5032202571579859536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/03/debugging-esp8266-commands-with-arduino.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/5032202571579859536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/5032202571579859536'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/03/debugging-esp8266-commands-with-arduino.html' title='Debugging ESP8266 commands with Arduino Uno'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjJ0E3YnTIhfnccz0yblX8J16wvT1q0ASMI2HB7FUAw3ykU0HvyeOi-wn3HPrt0-PyXNXeFhwjcOWADqn9xFhHoSkQsPz-B4hMKqDZTvbfFxoh7r5Rd0Cr2_WCWIw3AFm1KTrJh3gVY8/s72-c/esp8266_pinout.png" height="72" width="72"/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-4907660861816195781</id><published>2015-03-05T10:12:00.002-08:00</published><updated>2015-03-13T03:33:37.456-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ala"/><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="example"/><title type='text'>Animation of five LEDs using Arduino PWM output pins</title><content type='html'>This example is part of the &lt;a href=&quot;http://yaab-arduino.blogspot.com/p/ala.html&quot;&gt;ALA&lt;/a&gt; (Arduino Light Animation) library and shows how to create animations using some LEDs and an Arduino board.&lt;br /&gt;
Checkout this small video to see how the animations look like. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dzP0i7P1FxQVg2x5sU_qH5XHK0QZT6WA-n1axx7Xv0MDB4c9djoHOGgYDC1HIkrh73Z4wXshpNXeR4l9ohH0g&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Circuit&lt;/h3&gt;
The circuit is really simple. Just five red LEDs connected to five analog output pins of the Arduino and five 220 Ohm resistors.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm5Y2jHu5ee2nr78SFnx0OTR08x8eKLHV3uomNWmMsy1-t8B9EexMEwkBQotSRCY9UDHE3SKov-a5vYt1glCzayOZxoF2dpLPZDX-dugcTQYXoEOMJp_R07klOU9_Tj4SzUOnTRGwdPSI/s1600/AlaLedSet_schem.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm5Y2jHu5ee2nr78SFnx0OTR08x8eKLHV3uomNWmMsy1-t8B9EexMEwkBQotSRCY9UDHE3SKov-a5vYt1glCzayOZxoF2dpLPZDX-dugcTQYXoEOMJp_R07klOU9_Tj4SzUOnTRGwdPSI/s1600/AlaLedSet_schem.png&quot; height=&quot;298&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Code&lt;/h3&gt;
You have to download and install the ALA library from &lt;a href=&quot;http://yaab-arduino.blogspot.com/p/ala.html&quot;&gt;here&lt;/a&gt; first.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;#include &amp;lt;AlaLed.h&amp;gt;

AlaLed leds;
byte pins[] = { 5, 6, 9, 10, 11 };

AlaSeq seq[] =
{
  { ALA_FADEIN, 1000, 1000 },
  { ALA_ON, 1000, 1000 },
  { ALA_FADEOUT, 1000, 1000 },
  { ALA_BARSHIFTRIGHT, 1000, 1000 },
  { ALA_BARSHIFTLEFT, 1000, 1000 },
  { ALA_OFF, 1000, 1000 },
  { ALA_PIXELSHIFTRIGHT, 700, 1400 },
  { ALA_PIXELSHIFTLEFT, 700, 1400 },
  { ALA_BLINKALT, 500, 3000 },
  { ALA_PIXELSMOOTHSHIFTRIGHT, 1000, 4000 },
  { ALA_PIXELSMOOTHSHIFTLEFT, 1000, 4000 },
  { ALA_FADEINOUT, 1000, 4000 },
  { ALA_COMET, 1000, 4000 },
  { ALA_GLOW, 1000, 4000 },
  { ALA_STROBO, 200, 4000 },
  { ALA_ENDSEQ, 0, 0 }
};


void setup()
{
  leds.initPWM(3, pins);
  leds.setAnimation(seq);
}

void loop()
{
  leds.runAnimation();
}
&lt;/pre&gt;
&lt;br /&gt;
I have designed the ALA library with simplicity in mind. You just need to initialize the &lt;i&gt;AlaLed&lt;/i&gt; object in the &lt;i&gt;setup&lt;/i&gt; function passing the number of LEDs you want to drive. Then you call the &lt;i&gt;runAnimation&lt;/i&gt; method passing an array of triplets to describe the desired animation sequence. Finally you have to call the &lt;i&gt;runAnimation&lt;/i&gt; method in the &lt;i&gt;loop&lt;/i&gt; function to animate your LEDs.&lt;br /&gt;
The tricky part is the AlaSeq structure that is made by 3 fields:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;A numeric code identifying the desired animation. Valid codes are listed in the Ala.h header file.&lt;/li&gt;
&lt;li&gt;The animation loop duration in milliseconds.&lt;/li&gt;
&lt;li&gt;The animation total duration in milliseconds.&lt;/li&gt;
&lt;/ol&gt;
The last entry in the array must be ALA_ENDSEQ to close the animation sequence.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/4907660861816195781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/03/animation-leds-arduino-pwm.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/4907660861816195781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/4907660861816195781'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/03/animation-leds-arduino-pwm.html' title='Animation of five LEDs using Arduino PWM output pins'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm5Y2jHu5ee2nr78SFnx0OTR08x8eKLHV3uomNWmMsy1-t8B9EexMEwkBQotSRCY9UDHE3SKov-a5vYt1glCzayOZxoF2dpLPZDX-dugcTQYXoEOMJp_R07klOU9_Tj4SzUOnTRGwdPSI/s72-c/AlaLedSet_schem.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-8777448831699811175</id><published>2015-02-01T13:52:00.000-08:00</published><updated>2015-11-26T14:42:30.719-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="advanced"/><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="oscope"/><title type='text'>Fast sampling from analog input</title><content type='html'>The first part of the &lt;a href=&quot;http://yaab-arduino.blogspot.com/p/oscope.html&quot;&gt;OScope project&lt;/a&gt; is to implement the Arduino sketch to read the input values from an analog pin. In this article will describe how to achieve a reliable sampling of analog signals up to 615 KHz using some advanced techniques.&lt;br /&gt;
&lt;br /&gt;
Arduino provides an convenient way to read analog input this using the &lt;i&gt;analogRead()&lt;/i&gt; function. Without going into much details the &lt;i&gt;analogRead()&lt;/i&gt; function takes 100 microseconds leading to a theoretical sampling rate of 9600 Hz. You can read more about this topic &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,6549.0.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The following piece of code takes 1000 samples using the &lt;i&gt;analogRead()&lt;/i&gt; calculates some statistics.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;void setup()
{
  Serial.begin(115200);
  pinMode(A0, INPUT);
}

void loop()
{
  long t0, t;

  t0 = micros();
  for(int i=0; i&amp;lt;1000; i++) {
    analogRead(A0);
  }
  t = micros()-t0;  // calculate elapsed time

  Serial.print(&quot;Time per sample: &quot;);
  Serial.println((float)t/1000);
  Serial.print(&quot;Frequency: &quot;);
  Serial.println((float)1000*1000000/t);
  Serial.println();
  delay(2000);
}
&lt;/pre&gt;
&lt;br /&gt;
This code gives 112us per sample for a &lt;b&gt;8928 Hz sampling rate&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
So how can we increase sampling rate?&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Speedup the analogRead() function&lt;/h3&gt;
&lt;br /&gt;
We now need a little more details. The ADC clock is 16 MHz divided by a &#39;prescale factor&#39;. The &lt;b&gt;prescale is set by default to 128&lt;/b&gt; which leads to 16MHz/128 = 125 KHz ADC clock. Since a conversion takes 13 ADC clocks, the &lt;b&gt;default sample rate is about 9600 Hz&lt;/b&gt; (125KHz/13).&lt;br /&gt;
Adding few lines of code in the setup() function we can &lt;b&gt;set an ADC prescale to 16&lt;/b&gt; to have a clock of 1 MHz and a &lt;b&gt;sample rate of 76.8KHz&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

void setup()
{
  sbi(ADCSRA, ADPS2);
  cbi(ADCSRA, ADPS1);
  cbi(ADCSRA, ADPS0);
  ...
&lt;/pre&gt;
&lt;br /&gt;
The real frequency measured with the test program is 17us per sample for a &lt;b&gt;58.6 KHz sampling rate&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
The following table shows prescale values with registers values and theoretical sample rates. Note that prescale values below 16 are not recommended because the ADC clock is rated.&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;b&gt;Prescale&lt;/b&gt;&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;ADPS2 ADPS1 ADPS0&lt;/b&gt;&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Clock freq (MHz)&lt;/b&gt;&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Sampling rate (KHz)&lt;/b&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;2&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;0 0 1&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;8&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;615&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;4&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;0 1 0&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;4&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;307&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;8&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;0 1 1&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;2&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;153&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;16&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;1 0 0&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;1&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;76.8&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;32&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;1 0 1&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;0.5&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;38.4&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;64&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;1 1 0&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;0.25&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;19.2&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;128&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;1 1 1&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;0.125&lt;/td&gt;
  &lt;td style=&quot;text-align: center;&quot;&gt;9.6&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Interrupts&lt;/h3&gt;
&lt;br /&gt;
A better strategy is to avoid calling the &lt;i&gt;analogRead()&lt;/i&gt; function and use the &#39;ADC Free Running mode&#39;. This is a mode in which the ADC continuously converts the input and throws an interrupt at the end of each conversion. This approach has two major advantages:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Do not waste time waiting for the next sample allowing to execute additional logic in the loop function.&lt;/li&gt;
&lt;li&gt;Improve accuracy of sampling reducing jitter.&lt;/li&gt;
&lt;/ol&gt;
In this new test program I set the prescale to 16 as the example above getting a &lt;b&gt;76.8 KHz sampling rate&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;int numSamples=0;
long t, t0;

void setup()
{
  Serial.begin(115200);

  ADCSRA = 0;             // clear ADCSRA register
  ADCSRB = 0;             // clear ADCSRB register
  ADMUX |= (0 &amp;amp; 0x07);    // set A0 analog input pin
  ADMUX |= (1 &amp;lt;&amp;lt; REFS0);  // set reference voltage
  ADMUX |= (1 &amp;lt;&amp;lt; ADLAR);  // left align ADC value to 8 bits from ADCH register

  // sampling rate is [ADC clock] / [prescaler] / [conversion clock cycles]
  // for Arduino Uno ADC clock is 16 MHz and a conversion takes 13 clock cycles
  //ADCSRA |= (1 &lt;&lt; ADPS2) | (1 &lt;&lt; ADPS0);    // 32 prescaler for 38.5 KHz
  ADCSRA |= (1 &lt;&lt; ADPS2);                     // 16 prescaler for 76.9 KHz
  //ADCSRA |= (1 &lt;&lt; ADPS1) | (1 &lt;&lt; ADPS0);    // 8 prescaler for 153.8 KHz

  ADCSRA |= (1 &amp;lt;&amp;lt; ADATE); // enable auto trigger
  ADCSRA |= (1 &amp;lt;&amp;lt; ADIE);  // enable interrupts when measurement complete
  ADCSRA |= (1 &amp;lt;&amp;lt; ADEN);  // enable ADC
  ADCSRA |= (1 &amp;lt;&amp;lt; ADSC);  // start ADC measurements
}

ISR(ADC_vect)
{
  byte x = ADCH;  // read 8 bit value from ADC
  numSamples++;
}
  
void loop()
{
  if (numSamples&amp;gt;=1000)
  {
    t = micros()-t0;  // calculate elapsed time

    Serial.print(&quot;Sampling frequency: &quot;);
    Serial.print((float)1000000/t);
    Serial.println(&quot; KHz&quot;);
    delay(2000);
    
    // restart
    t0 = micros();
    numSamples=0;
  }
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to learn more on ADC Free Running mode and tweaking ADC register you can look at the following pages.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://sites.google.com/site/qeewiki/books/avr-guide/analog-input&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;‎AVR Guide - Analog Inputs&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/?ALLSTEPS&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Instructables - Girino - Fast Arduino Oscilloscope&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.instructables.com/id/Arduino-Audio-Input/?ALLSTEPS&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Instructables - Arduino Audio Input&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,6549.0.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Arduino Forum - Faster Analog Read&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/8777448831699811175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/02/fast-sampling-from-analog-input.html#comment-form' title='28 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8777448831699811175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8777448831699811175'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/02/fast-sampling-from-analog-input.html' title='Fast sampling from analog input'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>28</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-4689713616768716588</id><published>2015-01-11T03:15:00.002-08:00</published><updated>2015-01-29T09:30:22.118-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="LED"/><category scheme="http://www.blogger.com/atom/ns#" term="strip"/><title type='text'>Driving a LED strip with Arduino</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5cw0n9SWLxkbb_DZIg39pYx9UBhVeksuWLcBgUQR-cdD0F9XynJWHPPBxECQr4HdJWI1szoFVjq3DHwlMlPpDAhejgchVt6fOx2WuPP0A0qywLTPOOBC0uzA09IUhxh-oz4qKCZ3I6o4/s1600/smd5050_led_strips.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5cw0n9SWLxkbb_DZIg39pYx9UBhVeksuWLcBgUQR-cdD0F9XynJWHPPBxECQr4HdJWI1szoFVjq3DHwlMlPpDAhejgchVt6fOx2WuPP0A0qywLTPOOBC0uzA09IUhxh-oz4qKCZ3I6o4/s1600/smd5050_led_strips.jpg&quot; height=&quot;148&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Do you know those cheap LED strips?&lt;br /&gt;
&lt;br /&gt;
These are often called &quot;analog&quot; LED strips because you cannot control each pixel individually like you do with &quot;digital&quot; strips.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
Today we want to drive them using our Arduino board.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYM6X2bxuLVHObEU0BJlEm0c_1tnOJC0kuyc3dogufwLQkPYuiPliTlcH2cl8TGgFCYOXVHUftY-WL9QZDhXxbgGKzW7oc2HNhSnp09SHdtHmPC9x8TB7Q81Ew-hBRXbiPwKIAlX3DxeQ/s1600/IMG_20150111_121141.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYM6X2bxuLVHObEU0BJlEm0c_1tnOJC0kuyc3dogufwLQkPYuiPliTlcH2cl8TGgFCYOXVHUftY-WL9QZDhXxbgGKzW7oc2HNhSnp09SHdtHmPC9x8TB7Q81Ew-hBRXbiPwKIAlX3DxeQ/s1600/IMG_20150111_121141.jpg&quot; height=&quot;237&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Hardware&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Arduino Board&lt;/li&gt;
&lt;li&gt;MOSFET&lt;/li&gt;
&lt;li&gt;White LED strip&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
As MOSFET i have used I have used the IRF520 that comes with the Arduino starter kit but you can use any general purpose MOSFET (for example the popular STP16NF06).&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Schematic&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSrGkwN0hIfPulJtdbENGuCqJGC8B9LnWMEe1SILK3prSWg0TmpAEj7Bp5_JAeM-mi46DFlvqdORryRzsLaCDlZtE2EHw7iZqTjqXnvrrsWYkNfxlgFNGBebibalZyl4Dp8VNBUFGr0Q/s1600/LedStrip_schem.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSrGkwN0hIfPulJtdbENGuCqJGC8B9LnWMEe1SILK3prSWg0TmpAEj7Bp5_JAeM-mi46DFlvqdORryRzsLaCDlZtE2EHw7iZqTjqXnvrrsWYkNfxlgFNGBebibalZyl4Dp8VNBUFGr0Q/s1600/LedStrip_schem.png&quot; height=&quot;215&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU78zvg4ZwDIUBiSP7Vxx-2nCWOeqebjDaTxPSxekP2spfI5LV7vZrwqZbw__aUff1b8pLgjo6L31yB9SWn6f9W0faycIa7DDsR2GX1Rrf4sNOC2Gw8L2n6KJ5aroqzkReqIHCwBRsRbw/s1600/LedStrip_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU78zvg4ZwDIUBiSP7Vxx-2nCWOeqebjDaTxPSxekP2spfI5LV7vZrwqZbw__aUff1b8pLgjo6L31yB9SWn6f9W0faycIa7DDsR2GX1Rrf4sNOC2Gw8L2n6KJ5aroqzkReqIHCwBRsRbw/s1600/LedStrip_bb.png&quot; height=&quot;320&quot; width=&quot;305&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Code&lt;/h3&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;#define PIN 11      // control pin
#define DELAY 10    // 20ms internal delay; increase for slower fades

void setup() {
  pinMode(PIN, OUTPUT);
}

void loop() {
  // fade in
  for(int i=0; i&amp;lt;255; i++) {
    analogWrite(PIN, i);
    delay(DELAY);
  }

  // fade out
  for(int i=0; i&amp;lt;255; i++) {
    analogWrite(PIN, 255-i);
    delay(DELAY);
  }
}
&lt;/pre&gt;
&lt;br /&gt;
This is the code if you prefer a &quot;strobo effect&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;#define PIN 11      // control pin
#define DELAY 20    // 20ms internal delay; increase for slower pulse

void setup() {
  pinMode(PIN, OUTPUT);
}

void loop() {
  digitalWrite(PIN, HIGH);  // turn on
  delay(DELAY);             // wait few milliseconds
  digitalWrite(PIN, LOW);   // turn off
  delay(DELAY*10);          // wait some more time
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
References&lt;/h3&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blog.dcxn.com/2013/03/03/dimming-a-12v-led-strip-with-an-arduino/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Dimming a 12V LED Strip With an Arduino&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://learn.adafruit.com/rgb-led-strips/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;RGB LED Strips&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.jerome-bernard.com/blog/2013/01/12/rgb-led-strip-controlled-by-an-arduino/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;RGB Led Strip Controlled by an Arduino&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/4689713616768716588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/01/driving-led-strip-with-arduino.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/4689713616768716588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/4689713616768716588'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/01/driving-led-strip-with-arduino.html' title='Driving a LED strip with Arduino'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5cw0n9SWLxkbb_DZIg39pYx9UBhVeksuWLcBgUQR-cdD0F9XynJWHPPBxECQr4HdJWI1szoFVjq3DHwlMlPpDAhejgchVt6fOx2WuPP0A0qywLTPOOBC0uzA09IUhxh-oz4qKCZ3I6o4/s72-c/smd5050_led_strips.jpg" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-1401376164882057203</id><published>2015-01-10T07:31:00.001-08:00</published><updated>2015-01-12T05:38:00.993-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="LED"/><title type='text'>Fading colors with an RGB LED</title><content type='html'>In this post I will explain how to make a simple fading RGB LED.&lt;br /&gt;
The code smoothly fades an RGB LED using PWM through 3 different basic colors (red, green and blue).&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Hardware&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Arduino Board&lt;/li&gt;
&lt;li&gt;RGB LED&lt;/li&gt;
&lt;li&gt;3x Resistors 220 Ohm&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h3&gt;
Schematic&lt;/h3&gt;
The schematic is very simple. Just connect the common cathod (+) to the GND pin.
Then connect the 3 other leads to 3 PWM pins on your Arduino with a 220 Ohm resistor between.
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0MkyPVmQ51naK9DhjS0kspMA1qdcDAHpRUH68k0PBuTxQ1RsGjQMOu-jGe41Axyinp-0FuDg1QM_nprl4hkLGdqIGr41QLkkO-DJ12RvAolL8j9uMidN1YcTu0OMzeOeAejd3VXfTFSw/s1600/RgbLedFadingColors_schem.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0MkyPVmQ51naK9DhjS0kspMA1qdcDAHpRUH68k0PBuTxQ1RsGjQMOu-jGe41Axyinp-0FuDg1QM_nprl4hkLGdqIGr41QLkkO-DJ12RvAolL8j9uMidN1YcTu0OMzeOeAejd3VXfTFSw/s1600/RgbLedFadingColors_schem.png&quot; height=&quot;256&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxqk5lQKTW71J8qS7kNQ32HXQN8CyqOYsJrmzWJ-OwdGNCyyv2AhZG0KPFyX9StQZXSnFQVye8TRBHp9ORlD5O5USlCaMO9GDkTLOSwr_fCe2Swo8h914cwgfzfN-9LNhckPeq7c_x_ZU/s1600/RgbLedFadingColors_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxqk5lQKTW71J8qS7kNQ32HXQN8CyqOYsJrmzWJ-OwdGNCyyv2AhZG0KPFyX9StQZXSnFQVye8TRBHp9ORlD5O5USlCaMO9GDkTLOSwr_fCe2Swo8h914cwgfzfN-9LNhckPeq7c_x_ZU/s1600/RgbLedFadingColors_bb.png&quot; height=&quot;320&quot; width=&quot;218&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Code&lt;/h3&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;#define RED_PIN 9      // where the red pin is connected to
#define GREEN_PIN 10   // where the green pin is connected to
#define BLUE_PIN 11    // where the blue pin is connected to
#define DELAY 20       // 20ms internal delay; increase for slower fades

void setup() {
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
  pinMode(RED_PIN, OUTPUT);
}

void loop() {
  // fade from green to red
  for(int i=0; i&amp;lt;255; i++) {
    analogWrite(RED_PIN, i);
    analogWrite(GREEN_PIN, 255-i);
    analogWrite(BLUE_PIN, 0);
    delay(DELAY);
  }

  // fade from red to blue
  for(int i=0; i&amp;lt;255; i++) {
    analogWrite(RED_PIN, 255-i);
    analogWrite(GREEN_PIN, 0);
    analogWrite(BLUE_PIN, i);
    delay(DELAY);
  }

  // fade from blue to green
  for(int i=0; i&amp;lt;255; i++) {
    analogWrite(RED_PIN, 0);
    analogWrite(GREEN_PIN, i);
    analogWrite(BLUE_PIN, 255-i);
    delay(DELAY);
  }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
References&lt;/h3&gt;
&lt;a href=&quot;http://www.instructables.com/id/Fading-RGB-LED-Arduino/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Fading RGB LED (Arduino)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ColorCrossfader&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Arduino ColorCrossfader&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://arduino-info.wikispaces.com/RGB-LED&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;RGB LEDs&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-7-make-an-rgb-led-fader/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Make an RGB LED Fader&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/1401376164882057203/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/01/rgb-led-fading-colors-arduino.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/1401376164882057203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/1401376164882057203'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/01/rgb-led-fading-colors-arduino.html' title='Fading colors with an RGB LED'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0MkyPVmQ51naK9DhjS0kspMA1qdcDAHpRUH68k0PBuTxQ1RsGjQMOu-jGe41Axyinp-0FuDg1QM_nprl4hkLGdqIGr41QLkkO-DJ12RvAolL8j9uMidN1YcTu0OMzeOeAejd3VXfTFSw/s72-c/RgbLedFadingColors_schem.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-427527960386608258.post-8640971474911237055</id><published>2015-01-09T12:50:00.000-08:00</published><updated>2015-01-10T05:52:19.710-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="LED"/><title type='text'>LED Blink</title><content type='html'>This is the very first project of every Arduino owner... make a LED blink. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Hardware&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Arduino Board&lt;/li&gt;
&lt;li&gt;LED&lt;/li&gt;
&lt;li&gt;220 Ohm resistor &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h3&gt;
Schematic&lt;/h3&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgvw6OjbQY0bn2OIl-gHx-0jwbHUTwD-UwcnB0JEJYxr60QjAXFwGkDmjOCLGbHcs0HRhZrlHyoN99qt5fPoe8zQG7DrABliSuTCLXumzU7d2HGz1ZRCfQQZXv_xZtcEWCWbfJa6ek64I/s1600/LedBlink_schem.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgvw6OjbQY0bn2OIl-gHx-0jwbHUTwD-UwcnB0JEJYxr60QjAXFwGkDmjOCLGbHcs0HRhZrlHyoN99qt5fPoe8zQG7DrABliSuTCLXumzU7d2HGz1ZRCfQQZXv_xZtcEWCWbfJa6ek64I/s1600/LedBlink_schem.png&quot; height=&quot;332&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h3&gt;
Circuit&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh172l8TXtzAjHk-iPyZPgEPNspbdeAWvdum2AT2zm_IgcxT4cTDf9GzO69bzgb_rc2Ac8aIgeDtDk1ZYGQPI2gXY-OXcHQ2bpbau_v8GECAxqHLiW1jIyjoUsHci7GCaYkhcgw3sH3c5M/s1600/LedBlink_bb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh172l8TXtzAjHk-iPyZPgEPNspbdeAWvdum2AT2zm_IgcxT4cTDf9GzO69bzgb_rc2Ac8aIgeDtDk1ZYGQPI2gXY-OXcHQ2bpbau_v8GECAxqHLiW1jIyjoUsHci7GCaYkhcgw3sH3c5M/s1600/LedBlink_bb.png&quot; height=&quot;400&quot; width=&quot;277&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Code&lt;/h3&gt;
&lt;br /&gt;
&lt;pre class=&quot;post-code&quot;&gt;int pinLed = 13;

void setup() {                
  pinMode(led, OUTPUT);     
}

void loop() {
  digitalWrite(pinLed, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                  // wait for a second
  digitalWrite(pinLed, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                  // wait for a second
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
References&lt;/h3&gt;
&lt;a href=&quot;http://arduino.cc/en/Tutorial/Blink&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Arduino Blink example&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.instructables.com/id/Basic-Arduino-Tutorials-01-Blinking-LED/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Instructables tutorial&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
https://www.sparkfun.com/tutorials/219</content><link rel='replies' type='application/atom+xml' href='http://yaab-arduino.blogspot.com/feeds/8640971474911237055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://yaab-arduino.blogspot.com/2015/01/led-blink-arduino.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8640971474911237055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/427527960386608258/posts/default/8640971474911237055'/><link rel='alternate' type='text/html' href='http://yaab-arduino.blogspot.com/2015/01/led-blink-arduino.html' title='LED Blink'/><author><name>Bruno</name><uri>http://www.blogger.com/profile/13748160755424198810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgvw6OjbQY0bn2OIl-gHx-0jwbHUTwD-UwcnB0JEJYxr60QjAXFwGkDmjOCLGbHcs0HRhZrlHyoN99qt5fPoe8zQG7DrABliSuTCLXumzU7d2HGz1ZRCfQQZXv_xZtcEWCWbfJa6ek64I/s72-c/LedBlink_schem.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>