tag:blogger.com,1999:blog-32836810641006857212024-03-18T23:40:22.473-05:00Becker Maker BlogThe purpose of this blog is to record my progress on maker projects that I am working on.
I will tag each post with the name of the project to group posts together.Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.comBlogger143125tag:blogger.com,1999:blog-3283681064100685721.post-49246136533327026442019-02-23T14:35:00.000-06:002019-02-23T14:35:57.281-06:00Setting up Development EnvironmentI want to setup a development environment that I can use from anywhere. The goal is to be able to do coding on my laptop, one of my Raspberry Pis or, possibly, a Chromebook. I would like to use <a href="https://www.eclipse.org/" target="_blank">Eclipse</a> as the IDE and <a href="https://github.com/" target="_blank">Github</a> as the code repository.<br /><div>
<b></b><br /></div>
<div>
<b>Laptop Setup</b></div>
<div>
First, I am going to get the laptop working. </div>
<div>
<br /></div>
<div>
I have Eclipse installed on my laptop with the PHP add-in. In order to use Eclipse with Python, I need to install <a href="http://www.pydev.org/" target="_blank">PyDev</a>. The PyDev site has <a href="http://www.pydev.org/manual_101_install.html" target="_blank">instructions</a> to install and configure <span style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; display: inline !important; float: none; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">PyDev </span>in Eclipse.</div>
<br />I have Java 8 on my laptop and Eclipse 2018-12 (4.10.0). I do not have Python installed.<br /><br />Step one was to download the Python 2.7.16 64-bit installer for Windows 10 and install it on my laptop. I was able to execute Python from the command prompt so I know it is installed.<br /><br />Next, I followed the instructions on the PyDev site to install PyDev from within Eclipse. All you need to do is click Help / Install New Software and put in the URL for PyDev: http://www.pydev.org/updates<br /><br />After installing, I had to configure the Python Interpreter in Eclipse. I had to tell Eclipse where the python.exe file was on my PC.<br /><div>
<br /></div>
<div>
<b>Git</b></div>
<b></b>A few days ago, I used BitBucket on the web to create a GitHub repository for the HESA. I also installed Git for Windows on my laptop. I then cloned the GitHub repository to my PC. You must do this before you can do anything with Git on the PC.<br /><br /><div>
Today, I copied all of the HESA code on my laptop to the folder created by Git when I cloned the repository. Then, I used command line commands to upload my HESA py files to GitHub. </div>
<div>
<span style="font-family: "Courier New", Courier, monospace;"></span><span style="font-size: x-small;"></span><span style="color: lime;"></span><b></b><span style="background-color: black;"></span><br /></div>
<div>
<span style="background-color: black; color: lime; font-family: "Courier New", Courier, monospace; font-size: x-small;"><b>git add --all</b></span></div>
<div>
<span style="font-family: "Courier New", Courier, monospace;"></span><span style="font-size: x-small;"></span><span style="color: lime;"></span><b></b><span style="background-color: black;"></span><br /></div>
<div>
Then, I had to add my BitBucket email address by doing </div>
<div>
<br /></div>
<div>
<b><span style="background-color: black; color: lime; font-family: "Courier New", Courier, monospace; font-size: x-small;">git config --global <a href="http://user.email/">user.email</a> prodigal67@bitbucket.org</span></b></div>
<div>
<b></b><span style="font-family: "Courier New", Courier, monospace;"></span><span style="font-size: x-small;"></span><span style="color: lime;"></span><span style="background-color: black;"></span><br /></div>
<div>
Next, had to do </div>
<div>
<br /></div>
<div>
<span style="background-color: black; color: lime; font-family: "Courier New", Courier, monospace; font-size: x-small;">git commit -m 'Mit comments'</span></div>
<div>
<span style="font-family: "Courier New", Courier, monospace;"></span><span style="font-size: x-small;"></span><span style="color: lime;"></span><span style="background-color: black;"></span><br /></div>
<div>
This does a local commit. Finally, I did </div>
<div>
<span style="font-family: "Courier New", Courier, monospace;"></span><span style="font-size: x-small;"></span><b></b><span style="color: lime;"></span><span style="background-color: black;"></span><br /></div>
<div>
<span style="background-color: black; color: lime; font-family: "Courier New", Courier, monospace; font-size: x-small;"><b>git push</b></span></div>
<div>
<span style="font-family: "Courier New", Courier, monospace;"></span><span style="font-size: x-small;"></span><b></b><span style="color: lime;"></span><span style="background-color: black;"></span><br /></div>
<div>
to upload the files to the git repository. Now, I can see the files in the repository.</div>
<br />I repeated this process to get my Python module code in another repository in GitHub. <br /><div>
<br /></div>
<div>
<b>Raspberry Pi</b></div>
<b></b>Next, I moved on to my new Raspberry Pi 3+. It already has git installed and Python 3 and Eclipse.<br /><br />I used the command line options to clone the github repositories to the pi.<br /><br /><div>
Since Eclipse does not have the pydev extensions, I followed the same process to install them inside Eclipse.</div>
<div>
<br /></div>
<div>
That was all there is to it. Now, I can make code changes on my Pi or my PC and synchronize those changes through GitHub. </div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com1tag:blogger.com,1999:blog-3283681064100685721.post-86493909002111497932017-12-29T19:01:00.001-06:002017-12-29T19:01:45.137-06:00Setting up an EdgeRouter, Follow-up 1As mentioned in previous posts, I purchased and setup an <span style="-webkit-text-stroke-width: 0px; background-color: transparent; color: #222222; display: inline !important; float: none; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13.2px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 18.48px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> </span><a href="http://amzn.to/2zlJ8JA" style="-webkit-text-stroke-width: 0px; background-color: transparent; color: #249fa3; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13.2px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" target="_blank">EdgeRouter X</a><span style="-webkit-text-stroke-width: 0px; background-color: transparent; color: #222222; display: inline !important; float: none; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13.2px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 18.48px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> from </span><a href="https://www.ubnt.com/" style="-webkit-text-stroke-width: 0px; background-color: transparent; color: #249fa3; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13.2px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" target="_blank">Ubiquiti</a>. That all went relatively well and the device has been performing great. <br />
<b><br /></b>
<b>Minor Performance Issues</b><br />
Well, I did have a few instances where the internet port kept getting disconnected. This happened twice. Both times, it was later at night. I just stopped using the internet and went to bed. No one else complained so, it was no big deal. However, I'll have to keep an eye on it. I'd like to find a way to record the log file entries in a database. <br />
<br />
<b>Rules Update</b><br />
Last time, I created rules for all of the devices on my network. I decided to make rules for all devices, not just the ones I blocked. For now, there are some rules that block kids devices overnight. In the future, I will change the main ruleset to drop all traffic. Then, I will change the individual rules to allow traffic during specific times. This will keep the kids from spoofing their MAC address or using "unauthorized" devices.<br />
<br />
I may also make an additional rule to allow access to any device during daylight hours for any guests that come over. On the other hand, almost everyone who comes over has a phone with a data plan so it probably is unnecessary<br />
<br />
<b>Configuration Backed Up</b><br />
Today, I backed up the configuration. That was very easy. I probably should test it by restoring it but I'm scared I will brick the router.<br />
<b><br /></b>
<b>System Image Upgraded</b><br />
Finally, I downloaded the latest system image from the Ubiquiti web site and installed it. That also went smoothly. Interestingly, the options that were missing compared the manual are now there. For example, there is now a "Basic Setup" wizard option. I guess I should have done a system image update before I did any another configuration.<br />
<br />
<br />Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com1tag:blogger.com,1999:blog-3283681064100685721.post-9943878554506144542017-12-28T15:29:00.000-06:002017-12-28T15:29:01.511-06:00Setting up an EdgeRouter -- Blocking by device and time<span style="font-family: inherit;">In may <a href="http://beckermaker.blogspot.com/2017/12/setting-up-edgerouter-part-i.html" target="_blank">last post</a>, I described the initial setup of my new<span style="background-color: transparent; color: #222222; display: inline; float: none; font-size: 13.2px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 18.48px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> </span><a href="http://amzn.to/2zlJ8JA" style="background-color: transparent; color: #249fa3; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" target="_blank">EdgeRouter X</a><span style="background-color: transparent; color: #222222; display: inline; float: none; font-size: 13.2px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 18.48px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> by </span></span><span style="font-family: inherit;"><a href="https://www.ubnt.com/" style="background-color: transparent; color: #249fa3; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" target="_blank">Ubiquiti.</a> I connected it to my ISP, and pointed it to </span><span style="font-family: inherit;"><a href="https://www.opendns.com/" target="_blank">OpenDNS</a></span> as the DNS server. Now, I am going to setup a rule to block access to the internet for specific devices at specific times. In this way, I can effectively turn off the internet for my kid's devices overnight without turning off my internet access. Plus, each kid can have a different schedule. If I want to take away internet access as a punishment, I can easily do this by changing the settings for the specific kid's rule.<span style="font-family: inherit;"><span style="background-color: transparent; color: #222222; display: inline; float: none; font-family: inherit; font-size: 13.2px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 18.48px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></span></span><br />
<b></b><br />
<b>First Failed Attempt</b><br />
As an aside, on my first attempt, I managed to block all traffic on my internal network. I created a ruleset that dropped all packets as a default action. I turned it on for the interface for the switch and immediately lost connection to the router. The only way to fix it was to reset the device to factory settings and start over. Doh!<br />
<b><br /></b>
<b>Resetting the Router</b><br />
There are several ways to reset the router. I tried simply holding in the reset button while the device was powered on. This did not seem to do anything. In order to get the reset to work, I had to push in the reset button, then plug in the power until the reset sequence finished.<br />
<br />
One other thing. After I changed the IP address of the switch to 0.1, I had to plug the cable from my PC into port eth1 on the switch. It took me a few minutes to figure out why I could not connect to the switch while plugged in to port eth0 after it was configured to connect to the internet on port eth0. Maybe this will help someone who reads this blog.<br />
<b><br /></b>
<b>Configuring the Router to Block Traffic</b><br />
Here are the steps I followed to configure the router.<br />
<br />
After logging in to the device, I clicked on the <b>Firewall/NAT</b> button and then the <b>Firewall Policies</b> tab.<br />
<br />
I clicked on the "Add Ruleset" button and created a new ruleset named "Blocking". This ruleset will contain all of the rules for each device I want to block on my network. The default action is set to Accept all traffic. This way, all traffic is allowed by default. The firewall will only block traffic for specific rules. The mistake I made was to set the Default Action to Drop. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8c4sR8WR5sSjh2zZlNS7w5nsi0vnRU4OlgmWQ4qCiWJew3y39qxbctJPX1Gpn-m1OWbR36nF6iKxXOMNkrMOv8b-OePi-QIZjZROL2xCiWJ28H84zMA4fzpvRACcIt9A_I5J00K3JYo4v/s1600/EdgeRouter4.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="206" data-original-width="279" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8c4sR8WR5sSjh2zZlNS7w5nsi0vnRU4OlgmWQ4qCiWJew3y39qxbctJPX1Gpn-m1OWbR36nF6iKxXOMNkrMOv8b-OePi-QIZjZROL2xCiWJ28H84zMA4fzpvRACcIt9A_I5J00K3JYo4v/s1600/EdgeRouter4.JPG" /></a></div>
<br />
<br />
After saving the new ruleset, I clicked on the Actions dropdown for the new Blocking ruleset and chose the Interfaces option. I set the Interface to eth0 and the Direction to out. The ruleset was now finished after saving it.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Xd9yYUdfPqEJcecuZHfzOSqTnZli5UbQosqX7wTAc201GKD_FG9THelDuzHmkC91d1Pd5v2W7MrSfDswkvY6jKlI1HoMS4aUNsbUoX0OOMfitlqSDtCl2CulVPJKgJ3hNxIejz9so4U3/s1600/EdgeRouter5.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="110" data-original-width="431" height="81" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Xd9yYUdfPqEJcecuZHfzOSqTnZli5UbQosqX7wTAc201GKD_FG9THelDuzHmkC91d1Pd5v2W7MrSfDswkvY6jKlI1HoMS4aUNsbUoX0OOMfitlqSDtCl2CulVPJKgJ3hNxIejz9so4U3/s320/EdgeRouter5.JPG" width="320" /></a></div>
<br />
<br />
The next step was to create a default rule. I clicked on the Actions dropdown and chose "Edit Ruleset". Next, I clicked on the "Add New Rule" button. On the Basic tab, I entered a description that was for the device I wanted to block. The Enable box was checked by default. Drop was selected as the Action. (Reject would have also worked.) The "All protocols" radio button was selected. I did not choose logging because I don't want an entry in the log for every blocked packet. Here is a screen shot of the settings.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_wdFWNrfo9i-nQZiBDP-6JMe4zCkPyk6hRxCP9CslHo3wXwTgviYPEs-1YJfx5XfmLSAOYYw1aXVpsVqqXBoNulfnLEuxF9QGRNXBHlan1BzV956EWqCHelI0VaLLquV6oedOdtRUFV6Q/s1600/EdgeRouter6.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="389" data-original-width="309" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_wdFWNrfo9i-nQZiBDP-6JMe4zCkPyk6hRxCP9CslHo3wXwTgviYPEs-1YJfx5XfmLSAOYYw1aXVpsVqqXBoNulfnLEuxF9QGRNXBHlan1BzV956EWqCHelI0VaLLquV6oedOdtRUFV6Q/s320/EdgeRouter6.JPG" width="254" /></a></div>
<br />
That is it for the Basic tab. Nothing needs to be set on the Advanced tab. <br />
<br />
The MAC Address of the device to block is entered on the Source tab. I could also use the IP address to identify the device but that is easy for a kid to change. In theory, the MAC address can also be spoofed to get around the rules. If I find out that they are doing that, I will have to drop all packets by default and make rules to allow traffic by specific MAC address.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY3kQBBVMWnCS_c-pkUy_XAM8VjMRf_XNjR-_Ne3xxwjvd49Bn6a8fNFBvFOP7jq_8ecxQAN22O8Zf4s7Uu03harmD5GtCi4EM23E6EHEWjS1Ee-ihV88th6NZOOlADJaucBhQEdChwRGy/s1600/EdgeRouter7.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="238" data-original-width="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY3kQBBVMWnCS_c-pkUy_XAM8VjMRf_XNjR-_Ne3xxwjvd49Bn6a8fNFBvFOP7jq_8ecxQAN22O8Zf4s7Uu03harmD5GtCi4EM23E6EHEWjS1Ee-ihV88th6NZOOlADJaucBhQEdChwRGy/s1600/EdgeRouter7.JPG" /></a></div>
<div>
<br /></div>
<div>
Finally, the time to block the device is entered on the Time tab. In this case, I wanted to block traffic from this device from midnight to 4am every day. I could have blocked traffic for certain days and could even make multiple rules for the same device to have different times during the week and on weekends.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIwXBv4q7TxpsvfnQT-_Vi2OJzbpUBLjiCfrybPTDuHHB8cRKNHWcC2V3JIlayHWzmcEI1EKVrMXeD_4XdKzZ5xrRUiiB98-bJGEAGxDYhRf4_ZgKp99xJuGCi-tVVVnBeFIRYMyl73TGs/s1600/EdgeRouter8.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="347" data-original-width="422" height="263" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIwXBv4q7TxpsvfnQT-_Vi2OJzbpUBLjiCfrybPTDuHHB8cRKNHWcC2V3JIlayHWzmcEI1EKVrMXeD_4XdKzZ5xrRUiiB98-bJGEAGxDYhRf4_ZgKp99xJuGCi-tVVVnBeFIRYMyl73TGs/s320/EdgeRouter8.JPG" width="320" /></a></div>
<div>
<br /></div>
That is it. Now that I have one rule made, I can use the Actions button to copy the rule and simply change the MAC address and time for each kid's device.Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com1tag:blogger.com,1999:blog-3283681064100685721.post-77834135458609247092017-12-23T13:07:00.001-06:002017-12-23T13:07:35.348-06:00Setting up an EdgeRouter, Part I<div>
<b>Introduction</b></div>
<div>
Ever since my kids got devices that could get on the internet, I have been looking for ways to manage and monitor their access. We do randomly check their devices for "bad stuff" and we talk about what they should not be doing on the internet. Those are good, basic steps that any good parent should take.</div>
<div>
<br /></div>
<div>
I always point my routers to <a href="https://www.opendns.com/" target="_blank">OpenDNS</a> as the DNS server to filter out objectionable content. I am sure that helps, but savvy kids could install VPN apps to get around this.</div>
<div>
<br /></div>
<div>
Finally, the wireless AP is setup to turn off the wireless radios at 10:00pm until 4:00am. This keeps the kids off of the internet on their phones overnight since they don't have data plans. Also, they are supposed to leave their phones downstairs for charging overnight so they can't play offline games. The downside is that all wireless devices are affected by this and not just the kid's phones.</div>
<div>
<br /></div>
<div>
What I need is a router that</div>
<ol>
<li>allows me to block internet access at specific times for specific devices</li>
<li>allows me to see what sites people are going to</li>
<li>allows me to block access to VPN by device. I sometimes need to login to work using VPN. I can't just block all VPN access.</li>
</ol>
<div>
Hopefully, the <a href="http://amzn.to/2zlJ8JA" target="_blank">EdgeRouter X</a> by <a href="https://www.ubnt.com/" target="_blank">Ubiquiti</a> will let me do everything I want.</div>
<div>
<br /></div>
<div>
I bought an EdgeRouter X on Amazon for about $50. There are more expensive models but this one seemed like it would do everything I wanted. Plus, we have Amazon Prime right now so shipping was free. Some people said that the router stopped working after a few days. Amazon offered buyer protection for <$2, so I paid for that as well. If I get a lemon, I hope they will give me my money back.</div>
<div>
<br /></div>
<div>
<b>Initial Thoughts</b></div>
<div>
If you read reviews of the EdgeRouter, some people complain that it is hard to setup. I did not find that to be true at all. I am in IT but I am not a network engineer and do not work with routers normally. So, configuring the EdgeRouter is by no means something I can do without help.</div>
<div>
<br /></div>
<div>
The manual that the router comes with is simply a quick start guide. It explains how to plug everything in and nothing more. You need the <a href="https://www.ubnt.com/download/edgemax/edgerouter-x/er-x/edgeos-user-guide" target="_blank">full user guide</a> to get anywhere. Fortunately, that can be downloaded from the Ubiquity website. I have not read much of it yet but, at 104 pages, it appears to be pretty comprehensive. Also, I have had good luck googling things. Some of the information Google finds is outdated but still helpful.</div>
<div>
<br /></div>
<div>
<b>Setting up to Connect to the Internet</b></div>
<div>
<b></b>The main thing I need the EdgeRouter to do is connect my home network to the internet through my cable modem. This was very easy to setup. </div>
<div>
<br /></div>
<div>
First, I followed the instructions in the quick start guide to power up the EdgeRouter. I plugged a network cable from my laptop into port ETH0. Then, I configured the Ethernet port on my laptop to have a fixed IP address of 192.168.1.1. I brought up the web configuration interface and logged in as the ubnt user.</div>
<div>
<br /></div>
<div>
There is a wizard to configure the device to connect to the internet. The user guide says that the wizard is named, "Basic Setup". However, my device did not have a wizard with that name. Fortunately, the "WAN+2LAN2" wizard is the same as the Basic Setup wizard. I used the WAN+2LAN2 wizard and followed the instructions in the user guide for the Basic Setup wizard.</div>
<div>
<br /></div>
<div>
For the internet port choices, I left the defaults.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjljlry3MvwGHDufOgxNsgf46AM-UcsL3mpLK6YHtYYl7GGlpeKDK0LakoRKnWOJpDeV1koOtjLLEJl_7Hnm2ZzPlpkZlywXBRikH6bWu2i103K9v54clozLU_ED5JUUYBjVP6lwJJZrUoB/s1600/EdgeRouter2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="247" data-original-width="601" height="131" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjljlry3MvwGHDufOgxNsgf46AM-UcsL3mpLK6YHtYYl7GGlpeKDK0LakoRKnWOJpDeV1koOtjLLEJl_7Hnm2ZzPlpkZlywXBRikH6bWu2i103K9v54clozLU_ED5JUUYBjVP6lwJJZrUoB/s320/EdgeRouter2.JPG" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
The wizard screen also has a section to setup the LAN. You need to expand the section at the bottom of the screen to see the choices. One thing that through me off a bit is the DHCP setup. The address box is for the default address of the switch for the LAN. This is the address that DHCP will give to the clients as the router address. At first, I thought that this box was for the lower IP address setting. I set the address as 192.168.0.1.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj80tqXB4N8dIBvqo-dK-d8l_kMMNKMzmr7plOD001emlToCoz5KtADimhh_gkfPSofUSzF9erJNsvhaz9gxTR2tggf2fj9zcus9iyQfX7P9GxVMWMOlGorR0d5XEewbFiKjhSnuZJlfBGV/s1600/EdgeRouter3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="182" data-original-width="516" height="112" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj80tqXB4N8dIBvqo-dK-d8l_kMMNKMzmr7plOD001emlToCoz5KtADimhh_gkfPSofUSzF9erJNsvhaz9gxTR2tggf2fj9zcus9iyQfX7P9GxVMWMOlGorR0d5XEewbFiKjhSnuZJlfBGV/s320/EdgeRouter3.JPG" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Also, by default, the software starts the DHCP IP range at .38 and ends it at .243. That is more than enough for a home network.</div>
<div>
<br /></div>
<div>
The last step is to click the Apply button and reboot the router.</div>
<div>
<br /></div>
<div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<b>Physically Connecting to the Cable Modem</b></div>
It took a bit of fiddling to get the router installed on my network. I connected the Ethernet cable from the cable modem to eth0 on the EdgeRouter and powered up the EdgeRouter. The cable modem's network light lit up to indicate that the EdgeRouter was connected. However, I could not get to the internet even though I could see that the EdgeRouter had a routable IP from my ISP and was downloading traffic. A simple reboot of the cable modem and the EdgeRouter fixed the problem.</div>
<div>
<br /></div>
<div>
<b>OpenDNS</b></div>
<div>
Setting up the EdgeRouter to use OpenDNS was a bit harder but still pretty easy. The user guide does not specify how to do this. Fortunately, I am not the only one who tried to do this. Google to the rescue.</div>
<div>
<br /></div>
<div>
Part of the configuration can be done with the gui tools in the EdgeOS. Part of the configuration must be done by entering unix commands into the Command Line Interface (CLI).</div>
<div>
<br /></div>
<div>
First, I clicked on the System button in the bottom-left corner of the screen. This brings up the System configuration screen. I entered the two OpenDNS server IP addresses in the system name server box. Those addresses are 208.67.222.222 and 208.67.220.220. I also added the local IP address of 127.0.0.1 and saved those changes.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3ni9yFY4MetPBISHiBuzlT15ROefGyY9pGaNltoFM2vLxtHoy3Si3YTEL2rh1LTv9qXEarTM9rmiVmq-3yd5CiE5Rl-VKRpPbyrGJ9Xv08NmAOL1V5y4kNJ3yIYmkK1XTYLFGP76knAiC/s1600/EdgeRouter1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="163" data-original-width="431" height="121" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3ni9yFY4MetPBISHiBuzlT15ROefGyY9pGaNltoFM2vLxtHoy3Si3YTEL2rh1LTv9qXEarTM9rmiVmq-3yd5CiE5Rl-VKRpPbyrGJ9Xv08NmAOL1V5y4kNJ3yIYmkK1XTYLFGP76knAiC/s320/EdgeRouter1.JPG" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Next, I opened up the CLI interface and logged in as an administrator. I entered the following commands in the interface.</div>
<div>
<blockquote class="tr_bq">
<span style="color: #38761d; font-family: "Courier New", Courier, monospace; font-size: x-small;"><b>configure<br />set service dns forwarding system<br />commit<br />save<br />exit<br />exit</b></span></blockquote>
</div>
<div>
<span style="color: #38761d; font-family: "Courier New", Courier, monospace; font-size: x-small;"><b><br /></b></span></div>
<div>
Finally, I had to go to the OpenDNS web site and refresh my network's IP address. It took about five minutes for the OpenDNS servers to propagate my changes but eventually OpenDNS was doing it's job.</div>
<div>
<br /></div>
<div>
That's it for now. I have my EdgeRouter connected to my cable modem. I can get to the internet and am using OpenDNS for the DNS servers. </div>
<div>
<br /></div>
<div>
Next, I want to configure the router to block specific devices from accessing the internet at specific times.</div>
<div>
<b><i><br /></i></b></div>
<div>
<br /></div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com1tag:blogger.com,1999:blog-3283681064100685721.post-19272113858588813512016-01-22T21:09:00.001-06:002016-01-22T21:09:06.794-06:00Uncanny MovieI just finished watching the movie <a href="http://amzn.to/1REmGTd" target="_blank">Uncanny</a> on Netflix. It's a science fiction movie about a guy working on artificial intelligence. He created an android and made it as lifelike as possible. He calls himself an illusionist. The android is incredibly lifelike and creepy.<br />
<br />
This movie appeals to me as someone who is into robotics, AI, making, and science in general. It's an intellectual thriller. I enjoyed watching it and would like to watch it again. The ending was a surprise but more because of how unlikely it seems when you think about how the android and the maker acted during the week.<br />
<br />
I am left with feeling confused and a bit creeped out at the same time.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsLjVgsYDO6cYZAjAYKw79reeqCQu7vUVMKHH-rxRiA3FsTzeoqBy5XK3YO0DzLQ-EnZSUpy9UNrwqtEAYSYygtUDkxFfaac4zbsUGXixuHomdZgKpXQMNgZYFzQSVsu4aveG-rpF1CQqQ/s1600/Screenshot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsLjVgsYDO6cYZAjAYKw79reeqCQu7vUVMKHH-rxRiA3FsTzeoqBy5XK3YO0DzLQ-EnZSUpy9UNrwqtEAYSYygtUDkxFfaac4zbsUGXixuHomdZgKpXQMNgZYFzQSVsu4aveG-rpF1CQqQ/s1600/Screenshot.png" /></a></div>
<br />
<br />
<br />Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-44476777183633621542016-01-01T16:02:00.000-06:002016-01-01T16:02:41.454-06:00Setting up Multiple WAP Routers on a Home NetworkI have a main WAP / router (<a href="http://www.amazon.com/NETGEAR-Wireless-Router-Gigabit-WNDR3700/dp/B002HWRJY4/ref=sr_1_1?s=pc&ie=UTF8&qid=1451684934&sr=1-1&keywords=Netgear+WNDR3700" target="_blank">Netgear WNDR3700v4</a>) in my house that connects to the cable modem (<a href="http://www.amazon.com/gp/product/B00AJHDZSI/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00AJHDZSI&linkCode=as2&tag=rynokenterprises-20&linkId=6LFMYRXQD7OR7M5T" target="_blank">Motorola Surfboard SB6141</a>) and the outside world. I also have a second WAP (<a href="http://www.amazon.com/gp/product/B004H8FSQM/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B004H8FSQM&linkCode=as2&tag=rynokenterprises-20&linkId=GKHBK6JDTKMQCLRC" target="_blank">Cisco RV220W</a>) and a wired-only router (<a href="http://www.amazon.com/gp/product/B000GVTX6U/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B000GVTX6U&linkCode=as2&tag=rynokenterprises-20&linkId=TU52JNKBL6AOGLLB" target="_blank">D-Link EBR-2310</a>) on my home network that extend the network. Only the main router provides DHCP functionality. The other devices connect to the main router through a LAN port. This works fine but the secondary devices do not connect to an NTP time server. They also will not look for firmware upgrades. Both of these functions go through the WAN port. Since the WAN port is not used, the device will not automatically update its time nor firmware.<br />
<br />
Today, I figured out how to fix that problem. I found some good information at <a href="http://forums.dlink.com/index.php?PHPSESSID=86qpu5se3q0nnasf1lb4qj5ab1&topic=53250.msg202549#msg202549" target="_blank">this web site</a>. Basically, the way to setup a secondary router on a home network is to give the WAN port a static IP address on the main network and put the LAN ports on a different network. The LAN ports can give out IP addresses using DHCP. The secondary router will use NAT to route traffic from the LAN ports to the WAN port. The router thinks the WAN port is connected to the internet and will use it to connect to the NTP time servers.<br />
<br />
It is a good idea to turn on the feature to return a ping on the WAN port on the secondary router. Also, turn on remote management so you can get to the router from the home network.<br />
<br />
My devices are configured like this.<br />
<br />
Netgear (main router)<br />
<br />
<ul>
<li>WAN IP: DHCP from ISP</li>
<li>LAN IP: 192.168.0.1</li>
<li>DHCP: On</li>
</ul>
<div>
Cisco</div>
<div>
<ul>
<li>WAN IP: 192.168.0.1</li>
<li>LAN IP: 192.168.1.1</li>
<li>Remote management: 192.168.1.1:443</li>
<li>DHCP: On</li>
</ul>
<div>
D-Link</div>
</div>
<div>
<ul>
<li>WAN IP: 192.168.0.11</li>
<li>LAN IP: 192.168.2.1</li>
<li>Remote management: 192.168.2.1:8080</li>
<li>DHCP: On</li>
</ul>
</div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdyTPQWCj4VImCi5Z9OJUrkmQ485zovUd2-6bEtRAzX6ahBm6i6Ls7hAEcPKeoDHCDQsRs0mZPwOIiwfOa4Vm2QzWoDyHoX65O9irDfl6znNoxdnUJOwpuSRL7v3YKv81VQ1YzX9XRSY07/s1600/20160101_140314.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdyTPQWCj4VImCi5Z9OJUrkmQ485zovUd2-6bEtRAzX6ahBm6i6Ls7hAEcPKeoDHCDQsRs0mZPwOIiwfOa4Vm2QzWoDyHoX65O9irDfl6znNoxdnUJOwpuSRL7v3YKv81VQ1YzX9XRSY07/s320/20160101_140314.jpg" width="320" /></a></div>
<br />Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-471142140894079032016-01-01T13:48:00.002-06:002016-01-01T13:48:24.365-06:00Electric Toothbrush StorageI have an electronic toothbrush. There is no good way to store it. The toothbrush is too big to fit in a normal toothbrush holder. Having the toothbrush standup on the sink is not good because the water builds up on the bottom and creates slime. <br />
<br />
I saw an <a href="http://www.familyhandyman.com/bathroom/diy-bathroom-storage/view-all" target="_blank">article</a> in a <a href="http://www.familyhandyman.com/" target="_blank">Family Handyman</a> magazine about how to store an electronic toothbrush on a wall using a strip of metal and a magnet. The article mentioned connecting a strip of metal to a wall, then using a <a href="https://www.blogger.com/href=%22http://www.amazon.com/gp/product/B015RQVEEW/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B015RQVEEW&linkCode=as2&tag=rynokenterprises-20&linkId=VLS4IFVEAICGGUTM" target="_blank">neodymium magnet</a> to attach to the metal. The toothbrush simply clings to the magnet because it has metal in it.<br />
<br />
I happen to have a bunch of neodymium magnets from computer hard drives in my stash of junk. Those magnets are very strong and are attached to pieces of metal that have built-in mounting holes. I attached one of those magnets to the wall in my bathroom using drywall screws.<br />
<br />
One added benefit is that the magnet appears to charge the battery in the toothbrush.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpY0e0zvbSTQm7II_l0lWytzyGoMET7IxVT3yauNmBOCiOx5vchp6GEV-fQ9_dsb2MZv1WMFfwrVDfgGPBlMZW44YKphkw-8T6P_eISgRtiizxiHTlZZ7EDOMvQT6jnQoxls-IgoSg-jGP/s1600/20151227_084837.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpY0e0zvbSTQm7II_l0lWytzyGoMET7IxVT3yauNmBOCiOx5vchp6GEV-fQ9_dsb2MZv1WMFfwrVDfgGPBlMZW44YKphkw-8T6P_eISgRtiizxiHTlZZ7EDOMvQT6jnQoxls-IgoSg-jGP/s320/20151227_084837.jpg" width="180" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp0L3Bf3aqsf0F6YK0R37xM1fWZCAqWdMqmdNGcJ8BUVZs9VaJEPDhxqPFdNSDpS6ktaAlux7zdl9vOvNP5G0xW2U4f33jbeHzQkVB114rNvzWkCcPYa_Et78azwrZIUlqWBox-f1zyO-m/s1600/20151227_084821.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp0L3Bf3aqsf0F6YK0R37xM1fWZCAqWdMqmdNGcJ8BUVZs9VaJEPDhxqPFdNSDpS6ktaAlux7zdl9vOvNP5G0xW2U4f33jbeHzQkVB114rNvzWkCcPYa_Et78azwrZIUlqWBox-f1zyO-m/s320/20151227_084821.jpg" width="180" /></a></div>
<br />Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-4711417541912395352015-12-18T19:24:00.001-06:002015-12-18T19:24:03.403-06:00Simple Basement Storage PlatformI was at the <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace</a> for the last time this year and possibly for the next few months. Tonight, I spent my time making some simple basement storage platforms in the woodshop. Altogether, I made four platforms. The materials needed was:<br />
<br />
<ul>
<li>Two (2) eight foot long 2x6 boards</li>
<li>Two (2) two foot by four foot, 1/8 inch thick sheets of hardboard</li>
<li>A handful of nails</li>
</ul>
<div>
The Makerspace has several great woodcutting tools that made the job go very quickly. In about an hour, I had four pretty nice looking platforms. The plan is to give them to a friend of ours from our weekly Bible Study group.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5X2ioJ4sv0U012tz6e2gkSds2fphPPAVggqfxNnXFUMqdIqXELdX6UYfUkuoK0qy9rZiLAcbFUIflUiLHsPalZG5jfU3Y1QVAQFVTHYBHYCZg_7BDXq8TJN-_nbV80nX_p0VCYbIGjQ1m/s1600/20151218_165410.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5X2ioJ4sv0U012tz6e2gkSds2fphPPAVggqfxNnXFUMqdIqXELdX6UYfUkuoK0qy9rZiLAcbFUIflUiLHsPalZG5jfU3Y1QVAQFVTHYBHYCZg_7BDXq8TJN-_nbV80nX_p0VCYbIGjQ1m/s320/20151218_165410.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRyGwM4qrovG1uEQz9n2s9kzKYmyq3nUXgsL385f2GtbdykbVqF8L37c5ogWvE9nXCpL9Bfladpb9HEXr1xNw2JiM_nHbfs62fID2Bn_n4CEvdBTugbKMO4Te487-zRekKsasyfwQpnBwF/s1600/20151218_165321.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRyGwM4qrovG1uEQz9n2s9kzKYmyq3nUXgsL385f2GtbdykbVqF8L37c5ogWvE9nXCpL9Bfladpb9HEXr1xNw2JiM_nHbfs62fID2Bn_n4CEvdBTugbKMO4Te487-zRekKsasyfwQpnBwF/s320/20151218_165321.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoBd1UExzh-K6dDSSpGUNgs9sp_8z7XLzHwLJqTsxyd87fWplY231twzElNBOHjaqOJryCKJuh4_p_0ciujuVRg9KPfL2VOlUDatdI-f9HX8XJIidlOAmqVwCeNQtl1cYqnKSk0o1XBMiy/s1600/20151218_165308.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoBd1UExzh-K6dDSSpGUNgs9sp_8z7XLzHwLJqTsxyd87fWplY231twzElNBOHjaqOJryCKJuh4_p_0ciujuVRg9KPfL2VOlUDatdI-f9HX8XJIidlOAmqVwCeNQtl1cYqnKSk0o1XBMiy/s320/20151218_165308.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Merry Christmas!</div>
<div>
<br /></div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-726494821822840022015-11-20T21:20:00.001-06:002015-11-20T21:20:12.795-06:00Injection Molding Machine SimulatorFor the last month or so, I have been spending my weekly <a href="http://www.milwaukeemakerspace.com/" target="_blank">Makerspace</a> time working on simulating an injection molding machine on a microprocessor. This is a project for work. I want to setup a test environment to work with <a href="http://www.epicor.com/products/mattec-mes.aspx" target="_blank">Mattec</a>, our <a href="https://en.wikipedia.org/wiki/Manufacturing_execution_system" target="_blank">MES</a> software used to control injection molding machines in our plastic parts plants. To make a proper test system, I would like to send signals from a simulated injection molding machine into the system. <br />
<br />
<b>Beaglebone Black Fail</b><br />
I first started working with a <a href="https://www.blogger.com/nofollow%22%20href=%22http://www.amazon.com/gp/product/B00LC1924G/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00LC1924G&linkCode=as2&tag=rynokenterprises-20&linkId=U7DN3EWGWLRCQ6F5" target="_blank">Beaglebone Black</a>. I was able to write a simple python program to turn LEDs on an off at random times. However, that program only worked once. After the first time, I could not get it to work. Not sure what went wrong. I may have fried the BBB somehow. It still boots, I can connect to it. I can execute BoneScript code. I just can't get any python code to work.<br />
<br />
At some point, (may have been before I tried the python code but also certainly after) I tried to upgrade the OS on the BBB to the latest version of Debian dates 2015-03-01. I followed the same <a href="http://beckermaker.blogspot.com/2014/03/flashed-debian-linux-onto-beaglebone.html" target="_blank">instructions from the last time </a>I did this. I did not get any errors creating the SD card. When I bootup the BBB in install mode, the lights start flashing. All three LEDs are supposed to light solid when the install is done. However, this never happens. I've tried several times with no success.<br />
<br />
<b>Raspberry Pi and Basic Simulation Definition</b><br />
So, I moved on to the <a href="http://www.amazon.com/Raspberry-Pi-Model-Project-Board/dp/B00T2U7R7I/ref=sr_1_4?s=pc&ie=UTF8&qid=1448075763&sr=1-4&keywords=raspberry+pi" target="_blank">Raspberry Pi</a>. I wrote a program to randomly turn LEDs on an off. If I ever actually get to use this on my test system, rather then turning on the LEDs, the Pi will send an electrical signal to an interface unit. There will be a signal to say that the fill process is complete, one to say a cycle is complete, and one to indicate that the last piece produced was scrap.<br />
<br />
<b>Classes</b><br />
A part of functionfunctionfunctionthe process, I learned how to use a Class to store data. I wish I would have learned about this earlier. I love using arrays in other languages. There is nothing really like an array in Python. However, a class is even better than an array. I made a class that represents a molding machine with sub-classes for the sensors on the machine. If I want to access the cycle time for the machine, I simply access the data at IMM10.Cycle.AvgTime. Very cool!<br />
<br />
<b>Down Event Probability Using a Poisson Distribution</b><br />
The machine class has a function that will calculate the probability that a machine will go down during a given cycle. It uses the <a href="https://en.wikipedia.org/wiki/Poisson_distribution" target="_blank">poisson distribution</a> function to determine this. Just input the average number of cycles per month and the average number of down events that machine per month. The poisson distribution function uses these numbers to determine the probability. Excellent!<br />
<br />
<b>General Python Program Functionality</b><br />
Multiple machines can be defined with different fill rates, cycle times, scrap probabilities, and down probabilities. The program continuously simulates cycles for each machine. It will send a signal when the fill part ends, then another signal when the complete cycle ends. Next, it decides if the machine functionfunctionproduced scrap during that cycle. If so, it sends that signal. Finally, it determines if the machine when down at the end of the cycle. If so, it sets a timer and waits for the down event to end before resetting the fill and cycle timers. <br />
<br />
<b>Determining Times Randomly Using a Normal Distribution and scipy</b><br />
The time for the fill and cycle are randomly determined based on the average times for that machine. The probability calculation is not a simply random number generator. It gets a random time that is within one standard deviation of the average, assuming that the probability has a normal distribution. This is better than a purely random number between the minimum and maximum range. The probability could be outside of that range but should be normally close to the average. In a future release, I'd like to add in some kind of randomality to generate outliers.<br />
<br />
In order to generate this kind of random number, I had to install a Python library called scipy (<a href="http://www.scipy.org/">www.scipy.org</a>). That library has a function called "percent point function" that will compute the inverse of the cumulative distribution function of a standard normal distribution. <br /><br />I'm not exactly how the function works, but if I send it a random number between 0 and 1, and tell it to use a mean of 40 and 3 standard deviations, its sends back numbers that appear to be distributed around 40.<br /><br />Here is one helpful link that explains more about using scipy in this way:<br />
<div style="border: 0px; color: #383838; font-family: gotham, helvetica, arial, sans-serif; font-size: 14px; line-height: 22px; margin: 0px; padding: 0px;">
<a data-mce-href="http://stackoverflow.com/questions/20626994/how-to-calculate-the-inverse-of-the-normal-cumulative-distribution-function-in-p" href="http://stackoverflow.com/questions/20626994/how-to-calculate-the-inverse-of-the-normal-cumulative-distribution-function-in-p" shape="rect" style="border: 0px; color: #047ac6; cursor: pointer; line-height: 1.57143em; margin: 0px; padding: 0px;" target="_blank">http://stackoverflow.com/questions/20626994/how-to-calculate-the-inverse-of-the-normal-cumulative-distribution-function-in-p</a></div>
<div>
<br /></div>
<div>
scipy can be installed on the Raspberry Pi simply by typing </div>
<blockquote class="tr_bq">
<span style="background-color: black; font-family: gotham, helvetica, arial, sans-serif; font-size: 14px; line-height: 22px;"><span style="color: lime;">sudo apt-get install python-scipy</span></span></blockquote>
<div>
<b>Future Enhancements</b></div>
<div>
For now, when a machine goes down, the duration of the down event is a purely random number between 5 seconds and 4 hours. In reality, most down time events last less than five minutes, but some can last for days or weeks. I'd like to have a formula that will mostly pick down event durations that are short but could pick longer ones. I can't figure that out just yet.</div>
<br />
Another future enhancement would be read in machine and sensor definitions from a text file or some other source. It would be cool if the source data could be managed with a web page. Then, I could control the parameters of the device remotely.<br />
<br />
Also, the Raspberry Pi outputs about 3 volts. If I need to generate more volts or a higher current, I might have to make a circuit board with transistors. <br />
<br />
This brings us up to date. I'll add more about generating random downtime durations later.Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-47902951578388544162015-10-09T20:29:00.002-05:002015-10-09T20:29:45.067-05:00FBI Exit Problem Fixed<div class="tr_bq">
<span style="font-family: Verdana, sans-serif;">I finished the first prototype for the <a href="http://www.instructables.com/id/MMS-Photo-inator-Xsi/" target="_blank">MMS Photo-inator Xsi</a> a few months back. It will take a picture when someone presses the button. Then, it displays the picture on the screen for a few seconds. Next, it flashes the lights on the green and red buttons and waits for the person to press one. If the person presses the red button, the program deletes the picture and resets. If the person presses the green button, the program keeps the picture and resets.</span></div>
<div class="tr_bq">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-DXSolOpQrlA/VaA9Fwlp50I/AAAAAAAADJI/IYBV3DlwsSU/s1600/upload_-1" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-DXSolOpQrlA/VaA9Fwlp50I/AAAAAAAADJI/IYBV3DlwsSU/s320/upload_-1" width="320" /></a></div>
<div class="tr_bq">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">One thing that I need the Photo-inator to do is stop displaying the picture if the person presses either the red or green button. I have not been able to figure that out, <b>until now</b>. </span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">I tried sending a keystroke to the session but that did not work. I also tried killing the process but that did not work. I tried other software and solutions but could not find one. I spent the last few months trying to figure this out. It has been extremely frustrating. Here is how I finally resolved the problem.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 1.57143em;">I heard</span><span style="line-height: 1.57143em;"> that the <a href="http://tjjr.fi/sw/python-uinput/" target="_blank">uinput</a> module for python will allow me to send keystrokes to a session. I downloaded the source code from here: </span><a data-mce-href="https://pypi.python.org/pypi/python-uinput" href="https://pypi.python.org/pypi/python-uinput" shape="rect" style="border: 0px; cursor: pointer; line-height: 1.57143em; margin: 0px; padding: 0px;" target="_blank">https://pypi.python.org/pypi/python-uinput</a></span><br />
<div style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif;">Before I could install the source code, I had to install a supporting program by typing</span></div>
<blockquote class="tr_bq" style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="color: #38761d; font-family: Courier New, Courier, monospace; font-size: x-small;"><b>sudo apt-get install libudev.so</b></span></blockquote>
<div style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif;"><br clear="none" /></span><span style="font-family: Verdana, sans-serif;"><span style="line-height: 22px;">Next, I installed the source code by running</span></span></div>
<blockquote class="tr_bq">
<span style="color: #38761d; font-family: Courier New, Courier, monospace; font-size: x-small;"><b><span style="line-height: 22px;">sudo python setup.py build</span><span style="line-height: 22px;">sudo python setup.py install</span></b></span></blockquote>
<div style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif; line-height: 22px;">I could not get fbi to work in the python program. Tried it from the terminal and it will not work either. I keep getting an error message that says, "ioctl VT_GETSTATE: Inappropriate ioctl for device (not a linux console?)"</span></div>
<div style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif; line-height: 22px;"><br /></span></div>
<div style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 22px;">Used Ctrl-Alt-F1 to switch to tty1 . Executing fbi on tty1 works perfectly.</span></span></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif; line-height: 1.57143em;"><span style="line-height: 22px;"><br /></span></span><span style="font-family: Verdana, sans-serif;"><span style="line-height: 22px;">If I have the python program execute this: "fbi -a -T 1 -t 1 BBB.jpeg", fbi will display the image. The -T 1 tells fbi to display the program on tty1. I need to specify this on my PC but it apparently did that by default when I ran the program on the Raspberry Pi. </span></span></div>
<div style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 22px;"><br /></span></span></div>
<div style="border: 0px; line-height: 1.57143em; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 22px;">Next, I wrote a small python program to display a picture with fbi, wait a few seconds, then send a q to the uinput subsystem on Linux to simulate a user pressing the letter q. This worked perfectly.</span></span></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif; line-height: 1.57143em;"><span style="line-height: 22px;"><br /></span></span><span style="font-family: Verdana, sans-serif;"><span style="line-height: 22px;">The test code looked like this:</span></span></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 22px;"><br /></span></span></div>
<blockquote style="border: 0px; padding: 0px;">
<span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">#!/usr/bin/python</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">import subprocess</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">import psutil</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">import time</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">import uinput</span></span></blockquote>
<blockquote style="border: 0px; padding: 0px;">
<span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">subprocess.call("fbi -a -T 1 -1 /home/ken/Pictures/BBB.jpeg", shell=True)</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">time.sleep(3)</span></span></blockquote>
<blockquote style="border: 0px; padding: 0px;">
<span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">#Uinput tests</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">events = (</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"> uinput.KEY_Q,</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"> uinput.KEY_H,</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"> uinput.KEY_L,</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"> uinput.KEY_O,</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"> )</span></span></blockquote>
<blockquote style="border: 0px; padding: 0px;">
<span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">device = uinput.Device(events)</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">time.sleep(1)</span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></span><span style="line-height: 22px;"><span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: x-small;">device.emit_click(uinput.KEY_Q)</span></span></blockquote>
<div>
<span style="font-family: Verdana, sans-serif;">Finally, I modified the photo-inator program to use the uinput code. I need to fire up the whole system to test it out. I'll do that some other day.</span></div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-86596910034974045262015-08-07T21:26:00.001-05:002015-08-07T21:26:47.338-05:00<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
I want to display a picture on the screen for at most 30 seconds. If the user presses a button, the picture should no longer be displayed and the program should move on to the next step.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
There are several options to do this.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<ol>
<li><span style="line-height: 1.428571em;">Display a picture in a gui user interface like xwindows</span></li>
<li><span style="line-height: 1.428571em;">Display the picture on a smaller monitor but use an LED screen as the user interface.</span></li>
<li><span style="line-height: 1.428571em;">Display a picture as part of another document from the command prompt</span></li>
<li><span style="line-height: 1.428571em;">Display a picture from the command prompt</span></li>
</ol>
</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
I played around with some of the options. Here are my notes from working on this. They are not well organized.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span data-mce-style="text-decoration: underline;" style="line-height: 1.428571em; text-decoration: underline;"><strong style="line-height: 1.428571em;">Display a picture as part of another document from the command prompt</strong></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
PDF</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Need to make a PDF file.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Display a PDF file.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Close the PDF file on demand.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
The Python Imaging Library or PIL might work. It will display an image but it looks like it uses the computer's default image display program. Might only work in windows.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span data-mce-style="text-decoration: underline;" style="line-height: 1.428571em; text-decoration: underline;"><strong style="line-height: 1.428571em;">Display a picture from the command prompt.</strong></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">Some people said you could use fbi in another tty session. fbi does have an option -T to display the image in a different tty. That does work but it enters the commands at the current prompt on that session.</span></div>
</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
I can use fbi -t 5 -1 -a -T 2 <image.jpg> to display an image on the second tty and then exit.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Starting the fbi process does not make fbi the "session leader". The shell is the session leader. fbi is <span style="line-height: 1.428571em;">the process group leader for a process group containing only itself. See <a data-mce-href="https://blog.nelhage.com/2011/02/changing-ctty/" href="https://blog.nelhage.com/2011/02/changing-ctty/" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">this page</a> for more details.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br clear="none" /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">I started the fbi process on tty1. Then, went to tty2 and killed the process in tty1. That worked.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br clear="none" /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">I started the fbi process on tty1. Then, killed it from a ssh session on my laptop. That worked. So, if I can just find the session number of the fbi session, I should be able to kill it.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br clear="none" /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">Tried running this command to kill the fbi session:</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br clear="none" /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<pre style="border: 0px; font-family: Monaco, Courier, monospace; line-height: 1.428571em; padding: 0px;" xml:space="preserve"><code style="border: 0px; font-family: Monaco, Courier, monospace; line-height: 1.428571em; margin: 0px; padding: 0px;">ps axf | grep <process name> | grep -v grep | awk '{print "kill -9 " $1}' | sh</code></pre>
</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br clear="none" /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">It locked up the tty sessions. I could still access the pi using ssh but not with the keyboard. Had to cycle power on the pi.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br clear="none" /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">After rebooting, did the same thing several more times. It worked every time. Not sure what this means.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br clear="none" /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">The psutil code has a function that will get a list of all the processes and put them in a dictionary. I can use that function to find the process running fbi. However, fbi just seems to mess up the process when it is kicked off from python.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br clear="none" /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Tried eog. It only works with x windows. Same with evince.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
It looks like PDF files can only be viewed in x windows.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Maybe the tty idea will work without killing the process. The idea would be to display the image in tty2 but switch back to tty1 when the user presses a button.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Googling this topic makes it look too complicated.</div>
</div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-32288403175535244152015-07-10T19:27:00.001-05:002015-07-10T19:27:24.731-05:00MMS Photo-inator Xsi Initial Prototype WorkedThe next phase of the <a href="http://www.instructables.com/id/MMS-Photo-inator-Xsi/" target="_blank">MMS Photo-inator</a> project was to complete the prototype. I spent the afternoon and evening of July 3 working on the prototype.<br />
<div>
<br /></div>
<div>
<a href="http://4.bp.blogspot.com/-AVXjsVmHE9I/VaBBw7zSbRI/AAAAAAAADNk/KB9qcbkXnHg/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="150" src="http://4.bp.blogspot.com/-AVXjsVmHE9I/VaBBw7zSbRI/AAAAAAAADNk/KB9qcbkXnHg/s200/upload_-1" width="200" /></a>First, I had to desolder a few more <a href="http://www.amazon.com/gp/product/B00K0XO8DC/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00K0XO8DC&linkCode=as2&tag=rynokenterprises-20&linkId=QRLYFXPP4GL7GAUQ" target="_blank">2N6045 NPN transistors</a> from the board I found on the <a href="http://wiki.milwaukeemakerspace.org/miscellaneous/hackrack" target="_blank">hack rack</a> at the <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace</a>. I needed two more transistors but I removed four just to have some spares. I broke one of the feet off by wiggling it too much. Putting the electrical plug under the board gave me the leverage I needed to pull the transistors off the board after the solder was removed.<br />
<br />
<a href="http://4.bp.blogspot.com/-8q92XWShbL0/VaBBxwd5uFI/AAAAAAAADNs/v2A7CeLflUA/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="150" src="http://4.bp.blogspot.com/-8q92XWShbL0/VaBBxwd5uFI/AAAAAAAADNs/v2A7CeLflUA/s200/upload_-1" width="200" /></a>The trick to removing soldered components from a circuit board is to, first, use <a href="http://www.amazon.com/gp/product/B0058EDGQ8/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B0058EDGQ8&linkCode=as2&tag=rynokenterprises-20&linkId=4AAY26UZWG5T2LHD" target="_blank">flux</a> to better transfer the heat to the board. The second tip is to use <a href="http://www.amazon.com/gp/product/B004NEUII8/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B004NEUII8&linkCode=as2&tag=rynokenterprises-20&linkId=OW4ZNQRLQ3BRGC5H" target="_blank">copper desoldering braid</a> to remove solder from the pins. After removing the solder, the transistors come off pretty easily with a little force.</div>
<div>
<br /></div>
<div>
The next step was to add some small strips of wood to the board that the buttons were mounted to so it would stand up on its own. I found some extra strips of wood at the Makerspace and attached them to the plywood.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<a href="http://4.bp.blogspot.com/-gqg9TirPS-0/VaA9I87gYxI/AAAAAAAADJg/4F7AJtNhOpA/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="150" src="http://4.bp.blogspot.com/-gqg9TirPS-0/VaA9I87gYxI/AAAAAAAADJg/4F7AJtNhOpA/s200/upload_-1" width="200" /></a>Now that the board is ready, I needed to wire the connections. Since I want to be able to assemble and disassemble the prototype easily, I decided to use <a href="http://www.amazon.com/gp/product/B008DS266M/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B008DS266M&linkCode=as2&tag=rynokenterprises-20&linkId=JIIRY3I35UNI6ZTU" target="_blank">terminal strips</a>. I attached three terminal strips to the board. One would be used for the 12v power coming from the power supply to each light. One strip would be used mainly to complete the 12v circuit to the collector on the transistors. I also used one connection on that strip to connect the negative wire on the PSU to common ground. The final strip would be used to connect the switches to the <a href="http://www.amazon.com/gp/product/B00T2U7R7I/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00T2U7R7I&linkCode=as2&tag=rynokenterprises-20&linkId=SPH4EZHDZR6UDM6X" target="_blank">Raspberry Pi</a> -- three sets of connectors for power in, and three sets for power out when a button was pushed. I used either u-shaped or blade connectors on the ends of the wires to make it easier to connect the wires to the strips, switches, and lights. <br />
<a href="http://1.bp.blogspot.com/-cWGRV-ffW-o/VaBTmvZqagI/AAAAAAAADPs/Y08M-A8AFUY/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="150" src="http://1.bp.blogspot.com/-cWGRV-ffW-o/VaBTmvZqagI/AAAAAAAADPs/Y08M-A8AFUY/s200/upload_-1" width="200" /></a><br />
After all the wiring on the prototype was done, I made ten connector wires to connect the prototype board to the breadboard for the Pi. There are four terminal blocks on the breadboard to accept the connector wires. One block is for the wires that send 3.3v from the Pi to the buttons. One block is for the wires that receive the 3.3v back from the buttons. A third block connects the lights to the transistors, completing the circuit. The final block connects the ground wire from the PSU to the ground on the Pi. Finally, I had to wire up all of the connections from the Pi GPIO pins to the various parts on the breadboard. Here is the schematic. It is also on <a href="http://www.digikey.com/schemeit" target="_blank">SchemeIt</a> at this link: <a href="http://www.digikey.com/schemeit/#1reo">http://www.digikey.com/schemeit/#1reo</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_ALlOLTbRwJFISzZlAHeULUXrPvDLSvqTjWOkL9ZZflcsrou3_-tIzTCs8KM-UshLQ2Us6Vwvr4YVQnf0z_6zLfZj9BmibW9H_8yqV26l4AvTD50Tn82iJWXQSTlTLoUnb4OYMFyq-2nc/s1600/MMS-Photo-inator.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="195" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_ALlOLTbRwJFISzZlAHeULUXrPvDLSvqTjWOkL9ZZflcsrou3_-tIzTCs8KM-UshLQ2Us6Vwvr4YVQnf0z_6zLfZj9BmibW9H_8yqV26l4AvTD50Tn82iJWXQSTlTLoUnb4OYMFyq-2nc/s400/MMS-Photo-inator.png" width="400" /></a></div>
The final prototype worked exactly as I hoped. The lights lit up and were bright. The Pi recognized that the buttons were being pushed. And, best of all, the Pi did not get fried.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-DXSolOpQrlA/VaA9Fwlp50I/AAAAAAAADJI/IYBV3DlwsSU/s1600/upload_-1" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-DXSolOpQrlA/VaA9Fwlp50I/AAAAAAAADJI/IYBV3DlwsSU/s320/upload_-1" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Next, I need to work on the Python code and get all of the features working.<br />
</div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-54176344588026040912015-06-27T11:01:00.000-05:002015-06-27T11:13:44.862-05:00Building an NPN Transistor Switch Circuit<b>Introduction</b><br />
The next step in the <a href="http://www.instructables.com/id/MMS-Photo-inator-Xsi/" target="_blank">MMS Photo-inator project</a> is to design a circuit to switch the light bulbs in the buttons on an off using transistors. The <a href="http://www.amazon.com/gp/product/B00T2U7R7I/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00T2U7R7I&linkCode=as2&tag=rynokenterprises-20&linkId=SPH4EZHDZR6UDM6X" target="_blank">Raspberry Pi 2</a> can't provide enough power to make the lights bright enough but it can control electronic switches that allow a higher powered power source to turn the lights on.<br />
<br />
Using transistors turned out to be very difficult to me. The concept of a transistor is pretty simple but actually getting a circuit working is not. I burned out several transistors trying different things. I have also read various sources to learn more about transistors but it does not seem to help. Last weekend, <a href="http://wiki.milwaukeemakerspace.org/members/roycepipkins" target="_blank">Royce</a> from the <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace</a> helped me build a circuit that worked. I'll try to document what I learned for my own edification.<br />
<br />
<b>Learn About Transistors (good luck)</b><br />
Here are some links to learn more about how to use NPN transistors as a switch:<br />
<br />
<ul>
<li><a href="https://learn.sparkfun.com/tutorials/transistors">https://learn.sparkfun.com/tutorials/transistors</a></li>
<li><a href="http://www.dummies.com/how-to/content/electronics-components-use-a-transistor-as-a-switc.html">http://www.dummies.com/how-to/content/electronics-components-use-a-transistor-as-a-switc.html</a></li>
<li><a href="https://www.techhouse.org/~dmorris/projects/tutorials/transistor.switches.pdf">https://www.techhouse.org/~dmorris/projects/tutorials/transistor.switches.pdf</a></li>
</ul>
<br />
<b>Transistorized Switching Circuit</b><br />
The objective is to turn three individual light bulbs on and off from my <a href="http://www.amazon.com/gp/product/B00T2U7R7I/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00T2U7R7I&linkCode=as2&tag=rynokenterprises-20&linkId=SPH4EZHDZR6UDM6X" target="_blank">Raspberry Pi</a> using transistors. The basic circuit is shown below. Note that everything, 12v PSU, RPi, and lights share the same ground. This is important.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfQtAxhHk6U5iRIaPN58eF872jfLZ9q5iLR0uoWcYNiPO7mrjR14uz0rIYZkOzxR5gvPCf_TH8nFKq4gRk0Ja4LgX2zZa0pOTvU8c458ELzDer-v4YUdEbxxErCbfrWBexRIm0bT18z5zR/s1600/MMS-Photo-inator.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="205" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfQtAxhHk6U5iRIaPN58eF872jfLZ9q5iLR0uoWcYNiPO7mrjR14uz0rIYZkOzxR5gvPCf_TH8nFKq4gRk0Ja4LgX2zZa0pOTvU8c458ELzDer-v4YUdEbxxErCbfrWBexRIm0bT18z5zR/s320/MMS-Photo-inator.png" width="320" /></a></div>
<br />
Transistors will be used as electronic switches to allow current from the 12v, 1.8A power supply to flow through the light bulbs. The Pi will send a 3.3v signal to the base pin on the transistor. This is the signal that tells the transistor to turn on the light bulb. <br />
<br />
According to <a href="http://raspberrypi.stackexchange.com/questions/9298/what-is-the-maximum-current-the-gpio-pins-can-output" target="_blank">this site</a>, the Raspberry Pi can safely put out a maximum of 16 mA per GPIO pin and a total of 50 mA on all GPIO pins. So, I have to be careful and limit the current from the Raspberry Pi to the base of the transistor to 16mA per transistor.<br />
<br />
<b>Transistor Specifications</b><br />
The first thing to do was to determine the characteristics of the transistor my project needed. <a href="https://art511.wordpress.com/works-in-progress/how-to-use-a-transistor-as-a-switch/" target="_blank">This site</a> was helpful to determine what transistor to use. <br />
<br />
The transistor has to handle the output from the power supply I will use -- 12v and 1.8A (max) -- to power the lights. Even though the lights only draw 0.25A, the PSU can put out 1.8A. I think it is possible for the transistor to draw the full current in some circumstances so I need a transistor that can handle the maximum current from the PSU. The parameter for current is called Ic(max) on the datasheets. The parameter for voltage is called V<span style="font-size: xx-small;">CEO</span> (max). When I look at the datasheet for a transistor, it has to have characteristics that fall within these two specifications.<br />
<br />
Finally, the amount of current that the base needs must be <= 16mA. This parameter is called I<span style="font-size: xx-small;">B</span>. To determine the I<span style="font-size: xx-small;">B</span> parameter, you have to find the formula on the datasheet. It is usually something like I<span style="font-size: xx-small;">C</span> = X * I<span style="font-size: xx-small;">B</span>. Basically, divide the current for the load by X to find the current to send to the base. In my case, the load current is 1.8A maximum. If, for example, a particular transistor has a formula of I<span style="font-size: xx-small;">C</span> = 100I<span style="font-size: xx-small;">B</span>, I<span style="font-size: xx-small;">B</span> would be equal to 1.8A / 100 or 18mA.<br />
<br />
<b>Finding a Transistor</b><br />
<a href="http://4.bp.blogspot.com/-MfK49hiyiqk/VY4VPfwI16I/AAAAAAAADH4/foIVxQZblZ8/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="150" src="http://4.bp.blogspot.com/-MfK49hiyiqk/VY4VPfwI16I/AAAAAAAADH4/foIVxQZblZ8/s200/upload_-1" width="200" /></a>Next, I had to find a transistor that meets the specifications. The <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace</a> has several NPN transistors in bulk. I looked up the specifications for each one on the <a href="http://www.datasheets360.com/">http://www.datasheets360.com/</a> website. Unfortunately, none of the NPN transistors on-hand matched the requirements. It seemed like I was going to have to buy a <a href="https://en.wikipedia.org/wiki/MOSFET" target="_blank">MOSFET</a> transistor like <a href="https://www.sparkfun.com/products/10213" target="_blank">this one</a> on <a href="https://www.sparkfun.com/" target="_blank">SparkFun</a>. On a hunch, I looked through the <a href="http://wiki.milwaukeemakerspace.org/miscellaneous/hackrack" target="_blank">hack rack</a> at the 'space for any parts that may have transistors and found a circuit board that had sixteen <a href="http://www.amazon.com/gp/product/B00K0XO8DC/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00K0XO8DC&linkCode=as2&tag=rynokenterprises-20&linkId=QRLYFXPP4GL7GAUQ" target="_blank">2N6045 NPN transistors</a>. According to the <a href="http://www.datasheets360.com/part/detail/2n6045/1824701097836161449/?se=ggka&setag=d360&cid=paidsearch&gclid=CJjYoMPyrsYCFYdFaQodi0kCRQ" target="_blank">datasheet</a>, these transistors have an I<span style="font-size: xx-small;">C </span>(max) of 10A, and a V<span style="font-size: xx-small;">CEO</span> (max) of 100V. Both of these are sufficient for this project. The I<span style="font-size: xx-small;">B</span> formula for this transistor is I<span style="font-size: xx-small;">C</span>/100 or 18mA in my case. This is just a bit higher than the Pi would like but, the load should not draw that many amperes. The nominal current that the lights will draw is 0.25A. This means that the base current needs to be 2.5mA under <b>normal</b> load--well within the Pi's capacity. Finding the circuit board was an unexpected blessing. Thanks, Big Guy.<br />
<br />
I was able to remove a couple of transistors from the circuit board using a soldering iron.<br />
<br />
<b>Resistor for the Base</b><br />
Its important to prevent the transistor from pulling too much current from the Pi and damaging it. The Pi can be protected from this by placing a resistor between the Pi and the base pin. Determining the size resistor that is needed was a bit complicated.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMK5p7MxvEjlqrWnlU_TtrdASoVeCyXRh_FWSZgax8BNWbc9GUCRCAyzPuJiM5b6q5tgt4cXqDrQNbd6VwtVZVnmrQx4LXOtrqyXL6-re8_PF590AwD0z7PylAEDh9OmCJWtvujLwqfF9a/s1600/Transistor-Switch-Test.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMK5p7MxvEjlqrWnlU_TtrdASoVeCyXRh_FWSZgax8BNWbc9GUCRCAyzPuJiM5b6q5tgt4cXqDrQNbd6VwtVZVnmrQx4LXOtrqyXL6-re8_PF590AwD0z7PylAEDh9OmCJWtvujLwqfF9a/s320/Transistor-Switch-Test.png" width="320" /></a>First, we made a circuit with one resistor and one 12v lamp. A <a href="http://www.amazon.com/Precision-Variable-Adjustable-Digital-Regulated/dp/B00LBOICL8/ref=sr_1_3?ie=UTF8&qid=1435420445&sr=8-3&keywords=regulated+power+supply" target="_blank">regulated power supply</a> was used to determine the minimum current that would turn on the 2N6045 transistor. To find the exact current level that the circuit was pulling, I unplugged the positive cable from the PSU, connected the red cable from the <a href="http://www.amazon.com/gp/product/B000EVYGZA/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B000EVYGZA&linkCode=as2&tag=rynokenterprises-20&linkId=AYWDOR3HYPHG22NX" target="_blank">multimeter</a> to the positive out on the PSU, then, connected the black lead on the multimeter to the circuit. The minimum current required to activate the transistor turned out to be 8mA. Finally, using a multimeter to measure the volts from the base to the emitter while the light bulb was on, showed that the PSU was supplying about 1.4v at this current level.<br />
<br />
This means that the voltage from the pin on the Pi needs to be lowered from 3.3v to 1.4v at 10mA (rounded up from 8 just to be safe). The resistor has to remove 3.3-1.4 or 1.9 volts. Using <a href="https://en.wikipedia.org/wiki/Ohm's_law" target="_blank">Ohm's law</a> to calculate the resistance works like this:<br />
<br />
R = V/I or<br />
R = 1.9/0.01A or<br />
R = 190 ohms.<br />
<br />
Putting a 190 ohm resistor between the Pi GPIO pins and the base pins of the transistors should keep the Pi safe from pushing out too much current, while providing enough volts to activate the transistor.<br />
<br />
I put a 180 ohm resistor (the 'space had a 180 or 220 ohm but no 190) in the circuit and connected the Pi's 3.3v output pin to the base. The light turned on! <br />
<br />
That was a lot of work and very frustrating at times. I would have never made it this far without <a href="http://wiki.milwaukeemakerspace.org/members/roycepipkins" target="_blank">Royce</a>. That is what is so great about the <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace</a>. There is usually someone around who can help you through the rough spots.<br />
<br />
Next, I need to remove some more resistors from the board and build a prototype of the complete MMS Photo-inator project.Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-10564243203026170972015-05-29T22:46:00.002-05:002015-05-29T22:49:48.067-05:00MMS Photo-inator Xsi -- 22-25 May session<div style="background-color: white; color: #222222; line-height: 18.4799995422363px;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">While at the <a href="http://www.milwaukeemakerspace.com/" style="color: #7c93a1; text-decoration: none;" target="_blank">Milwaukee Makerspace</a> for my weekly Maker-time, I continued working on my idea to use a <a href="http://amzn.to/1HYnkU8" style="color: #7c93a1; text-decoration: none;" target="_blank">Raspberry Pi 2 Model B</a> to make a device that will take pictures by controlling an SLR camera. This time, I found some software to display an image, made a prototype with hardware, and wrote most of the python code.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; line-height: 1.428571em; margin: 0px; padding: 0px;">
Installed <a href="http://www.avahi.org/" target="_blank">Avahi</a> on the pi so I can connect to the Pi over a network. This allows me to do coding on my Linux laptop and FTP the files to the Pi. If something happens to the Pi, I won't lose the code. The instructions to install Avahi are <a data-mce-href="http://elinux.org/RPi_Advanced_Setup#Setting_up_for_remote_access_.2F_headless_operation" href="http://elinux.org/RPi_Advanced_Setup#Setting_up_for_remote_access_.2F_headless_operation" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">here</a>. Changed the name of the device to photoinator in both the /etc/hostname and /etc/hosts files.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<span style="font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em;">I kicked around ideas for a human to interact with the photo-inator. One of my fellow Makers suggested doing everything in web pages. That would probably make everything easy including printing the picture but it wouldn't make much use of the <a href="http://www.adafruit.com/products/2310" target="_blank">Perma-Proto Pi Hat</a> from Adafruit. I'd like to have the user interact with the photo-inate by pressing buttons and seeing flashing lights.</span><br />
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Also, I would like to display a preview of the picture and let the user decide if it is good enough to keep or not. How do I get the Pi to display a jpg file without using xwindows?</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">First, I tried an application called feh to display images. This web page has the instructions for installing feh: </span><a data-mce-href="http://feh.finalrewind.org/" href="http://feh.finalrewind.org/" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">http://feh.finalrewind.org/</a></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
After messing around with feh, I realized that it only works from within xwindows. That does not help -- especially since <a href="http://www.gphoto.org/" target="_blank">gphoto2</a> only runs from the command line and will not work in a terminal session running in xwindows.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
The application that I needed is called <a data-mce-href="http://manpages.ubuntu.com/manpages/dapper/man1/fbi.1.html" href="http://manpages.ubuntu.com/manpages/dapper/man1/fbi.1.html" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">fbi</a>. I installed the app using sudo apt-get install fbi. After that, it just worked. I ran the program in the directory that has the photos in it. The way to run fbi is fbi image.jpg -a -t 10 -1. The -a will auto re-size the image to fit the screen. -t 10 tells fbi to display the image for 10 seconds. -1 means that fbi should exit after the timeout.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Next, I wrote a quick shell program to take a picture with gphoto2 then display it with fbi. I pass the filename to save the picture to as a parameter. The shell file looks like this:</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<blockquote class="tr_bq" style="border: 0px; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="background-color: black;"><span style="color: lime;"><span style="font-family: Courier New, Courier, monospace;">gphoto2 --capture-image-and-download --filename=$1.jpg</span><span style="font-family: Courier New, Courier, monospace;">fbi $1.jpg -a -t 10 -1</span></span></span></blockquote>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
The $1 lets me pass in a file name on the command line.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<a href="http://1.bp.blogspot.com/-BuCuQPpkpLc/VWkZGmYFOWI/AAAAAAAADGE/XVXzCBxWmuk/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="http://1.bp.blogspot.com/-BuCuQPpkpLc/VWkZGmYFOWI/AAAAAAAADGE/XVXzCBxWmuk/s200/upload_-1" width="150" /></a><span style="line-height: 1.428571em;">Next, I used a python program that I found on <a href="http://www.instructables.com/id/Raspberry-Pi-photo-booth-controller/?ALLSTEPS" target="_blank">this Instructable</a> and modified it a bit to control a button and an LED on the <a href="http://www.adafruit.com/products/1989" target="_blank">Adafruit T-cobbler Plus proto board</a>. It worked. I was able to press a button to start the process. The program flashed an LED, took a picture, and displayed it on the screen for 10 seconds. </span><span style="line-height: 1.428571em;"> Nice.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">I spent a good part of the day on Sunday (after church of course) writing a much more robust Python program with subroutines and global variables and all of that nerdy goodness. </span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">Finally, I spent Memorial Day back at the </span><a href="http://www.milwaukeemakerspace.com/" style="line-height: 1.428571em;" target="_blank">Makerspace</a><span style="line-height: 1.428571em;"> to build the prototype and debug the code. The prototype has three buttons and four LEDs. One button is to start the picture-taking process. Another will let the human choose to Keep the picture they just saw. The third button will tell the Pi to reset everything and start over. One of the LEDs will light when the picture-inator is ready to take a picture. The second LED will blink increasingly fast to warn the user that the picture is about to be taken. The final two LEDs blink alternately next to the Keep and Reset buttons to encourate the human to push one. This all works fine. For the final version, I would like to use small light bulbs instead of LEDs to increase the brightness. I probably need a stronger power source than the PI to light them. I will also need a more complicated circuit that includes a transistor. I'll design and build that in the next session.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">Another idea I had was to add a toggle switch to designate the mode that the picture-inator is in -- one shot or continuous. That should be pretty easy to do but I did not get to it this time.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">One of the things I struggled with on the coding side was the GPIO.add_event_detect function. I originally wanted the program to call a subroutine when a button was pressed. However, I could not get that to work. The subroutine might get called the first time the button was pressed but not after that. Sometimes, pressing the button never did anything. I ended up punting and doing several things to make this work.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">First, the main loop uses GPIO.event_detected to see if any of the buttons were pressed. Anytime a button is pressed or a state changes, the program turns off event detection for all buttons. Then, it does whatever the function is meant to do, and turns on even detection for any buttons that need to have it. Doing all of this should allow the program to always catch button presses and never have false-positives or multiple button presses.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">One other problem is that I don't know how to interrupt the picture being displayed. So, if the person pushes the Keep button while the picture is being displayed, nothing will happen. I don't think I can fix that. I spent a lot of time researching a way to call an external program in a separate thread but I'm not sure it is possible.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">The bug I am currently working on has to do with debug mode. When the program is running in debug mode everything works. However, when I run the program with debug mode turned off, it turns on the ready LED but will not do anything when any button is pressed. I have not been able to figure out why.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">Another bug is if the camera is off, gphoto2 returns an error. The program cannot handle the error. Need to figure that out.</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Here is a picture of the prototype at this point.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-HJNrxzl1x5o/VWkZBUFSo4I/AAAAAAAADFc/T9cXcYqSqDM/s1600/upload_-1" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/-HJNrxzl1x5o/VWkZBUFSo4I/AAAAAAAADFc/T9cXcYqSqDM/s320/upload_-1" width="320" /></a></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-81003698164832493992015-05-29T21:33:00.001-05:002015-05-29T21:34:06.594-05:00MMS Photo-inator Xsi -- 15 May 2015 Session<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">Even though I am posting this near the end of May, I am describing my efforts from 15 May 2015.</span><br />
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">
While at the <a href="http://www.milwaukeemakerspace.com/" style="color: #7c93a1; text-decoration: none;" target="_blank">Milwaukee Makerspace</a> for my weekly Maker-time, I continued working on my idea to use a <a href="http://amzn.to/1HYnkU8" style="color: #7c93a1; text-decoration: none;" target="_blank">Raspberry Pi 2 Model B</a> to make a device that will take pictures by controlling an SLR camera. </div>
<br />
<b><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Another New Camera</span></b><br />
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">After posting my lackluster progress on the <a href="https://groups.google.com/forum/#!forum/milwaukeemakerspace" target="_blank">Makerspace Google Group</a>, a Makerspace member named Matt </span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">offered to let me use his Canon EOS Rebel Xsi DSLR camera. Awesome! It was waiting for me in my locker when I arrived at the 'space. </span><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">I tried using <a href="http://www.gphoto.org/" target="_blank">gphoto2</a> with the Canon. gphoto2 detected the camera but I still had some issues. I could not take pictures or basically do anything.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<a href="http://3.bp.blogspot.com/-rljK6s0JTKw/VWkhNMTzwdI/AAAAAAAADHA/1Qbf9l6fCHs/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="150" src="http://3.bp.blogspot.com/-rljK6s0JTKw/VWkhNMTzwdI/AAAAAAAADHA/1Qbf9l6fCHs/s200/upload_-1" width="200" /></a><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Did some searching on the internet. One site said that the version of gphoto2 that gets installed with apt-get is not the correct version. apt-get downloads version 2.4.14. You need the latest version of both libgphoto and gphoto2.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">First, I used sudo apt-get purge gphoto2 to remove the gphoto app.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Next, I did apt-get upgrade and update just because.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Next, I installed a bunch of libraries recommended by this website: <a data-mce-href="https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=70049" href="https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=70049" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=70049</a></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Next, I downloaded the latest versions of libgphoto2 and gphoto2 using wget. For example, I typed in wget <a data-mce-href="http://sourceforge.net/projects/gphoto/files/libgphoto/2.5.7/libgphoto2-2.5.7.tar.bz2" href="http://sourceforge.net/projects/gphoto/files/libgphoto/2.5.7/libgphoto2-2.5.7.tar.bz2" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">http://sourceforge.net/projects/gphoto/files/libgphoto/2.5.7/libgphoto2-2.5.7.tar.bz2</a></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">In order to unpack the files, I typed tar xjvf libgphoto2-2.5.7.tar.bz2. A web page that talks about this is here: <a data-mce-href="http://askubuntu.com/questions/25961/how-do-i-install-a-tar-gz-or-tar-bz2-file" href="http://askubuntu.com/questions/25961/how-do-i-install-a-tar-gz-or-tar-bz2-file" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">http://askubuntu.com/questions/25961/how-do-i-install-a-tar-gz-or-tar-bz2-file</a></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">After unpacking, I cded to the folder. The INSTALL file has instructions about what to do next.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Step 1: ran ./configure --prefix=/usr/local. The second time I simply ran ./configure</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Step 2: ran make</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Step 3: ran sudo make install</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Get some error that the install failed. It could not remove anything in /usr/local. I rebooted and got messages about stuff not working. </span><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">Looks like the OS on the SD card got corrupted. The pi will no longer boot. Yar!</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">I had to start completely over. Downloaded a program to format the SD card. Then downloaded the NOOBs files and copied them to the SD card. The full version of NOOBs would not copy to the card. I had to copy the lite version to the card. That version downloads the install files over the internet when the Pi boots up. That worked.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Did all the setup stuff again. Downloaded libgphoto again and went through the complete install. This time, it worked.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Rebooted.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Downloaded the gphoto2 tar file from sourforge using the same wget command. Used tar to unpack it. Then, ran ./configure. It failed saying "Cannot autodetect popt.h" </span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">This page (<a href="http://www.yannock.be/computer/compiling-gphoto2-on-the-raspberry-pi" target="_blank">http://www.yannock.be/computer/compiling-gphoto2-on-the-raspberry-pi</a>) lists other packages that need to be installed with gphoto2. Installed all the packages it suggested:</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br />
<ol>
<li><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">libexif-dev</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">libpopt-dev</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">libfuse-dev</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">mono-devel</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">monodoc-base</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">libmono-2.0.1</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">mono-gmcs</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">python-pyrex</span></li>
</ol>
</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small; line-height: 1.428571em;">After installing all of this, I had to re-run ./configure. This time it worked. Ran make and make install. It all worked.</span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Ran gphoto2. It worked. </span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br clear="none" /></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">The gphoto2 auto-detect sees the camera. Was able to take a picture with gphoto2 and save it to the computer. You have to specify a filename or it always uses the same one.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">That's enough for this week.</span></div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-778511391386559962015-05-29T21:14:00.002-05:002015-05-29T21:16:44.113-05:00MMS Photo-inator Xsi -- 8 May 2015 Session<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">Even though I am posting this near the end of May, I am describing my efforts from 8 May 2015.</span><br />
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">
While at the <a href="http://www.milwaukeemakerspace.com/" style="color: #7c93a1; text-decoration: none;" target="_blank">Milwaukee Makerspace</a> for my weekly Maker-time, I continued working on my idea to use a <a href="http://amzn.to/1HYnkU8" style="color: #7c93a1; text-decoration: none;" target="_blank">Raspberry Pi 2 Model B</a> to make a device that will take pictures by controlling an SLR camera. </div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">
<b>New Camera</b></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px;">
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<a href="http://4.bp.blogspot.com/-bPG8Qyl8hZc/VWkcvJ15VQI/AAAAAAAADGo/Buff6SbqvAk/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="150" src="http://4.bp.blogspot.com/-bPG8Qyl8hZc/VWkcvJ15VQI/AAAAAAAADGo/Buff6SbqvAk/s200/upload_-1" width="200" /></a>I found a Canon PowerShot A540 camera sitting in a drawer in the 3D printer area at the 'space. I hooked that up to the PI to see if I would fare any better with gphoto2.</div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Executed <a href="http://www.gphoto.org/" target="_blank">gphoto2</a> -auto-detect. gphoto2 will only detect the camera if the power is on. It says that capture is not supported by the driver. This could be a problem if I want to save power by turning the camera off when the photo-inator is not in use. The power button is a momentary switch. So, it has to be pushed to turn the camera on or off. This is not the ideal situation.</div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
The batteries are low. Need to find a 3.15v DC power source with a male plug if I want this camera to stay on indefinitely.</div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
I did not have much luck playing with this camera compared to the Canon A470. Ed from the Makerspace told me about software called <a href="http://chdk.wikia.com/" target="_blank">CHDK</a>. CHDK is software that runs on a Canon camera. It gives you a new user interface and more options. This might be an option.</div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;"><br /></span></div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span style="line-height: 1.428571em;">The software for the Canon A540 can be found here: </span><a data-mce-href="http://chdk.wikia.com/wiki/A540" href="http://chdk.wikia.com/wiki/A540" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">http://chdk.wikia.com/wiki/A540</a></div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
<div style="border: 0px; color: black; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Not much progress this week.</div>
</div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-64538493735556385732015-05-29T20:59:00.002-05:002015-05-29T21:01:01.203-05:00MMS Photo-inator Xsi -- 1 May 2015 SessionEven though I am posting this near the end of May, I am describing my efforts from 1 May 2015.<br />
<div>
<br /></div>
<div>
While at the <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace</a> for my weekly Maker-time, I started working on my idea to use a <a href="http://amzn.to/1HYnkU8" target="_blank">Raspberry Pi 2 Model B</a> to make a device that will take pictures by controlling an SLR camera. I think I will call it the MMS Photo-inator Xsi.<br />
<div>
<br /></div>
<div>
<b>Setting up the Pi</b></div>
<div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<a href="http://2.bp.blogspot.com/-EvShlPQFHAk/VWkZADbnXrI/AAAAAAAADFU/Qr9-bm4uoAc/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="http://2.bp.blogspot.com/-EvShlPQFHAk/VWkZADbnXrI/AAAAAAAADFU/Qr9-bm4uoAc/s200/upload_-1" width="150" /></a>The Pi came with a micro SD card that was already formatted with Raspbian and ready to go. So I did not have to mess around with that.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
First of all, as always, I ran sudo apt-get upgrade and sudo apt-get update to make sure everything was up-to-date.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Changed the password for the pi user to wrenchiron.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
The keyboard was setup for British English. Used raspi-config to change it to US E<br />
<br />
nglish.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<b>Camera-controlling Software</b></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
The software that will control the camera is called <a href="http://www.gphoto.org/" target="_blank">gphoto2</a>. Installed gphoto2 by typing "<span style="line-height: 1.428571em;">sudo apt-get install gphoto2</span>". <b><note> It turns out that this was not the correct way to install gphoto2. I document the correct way to install it in a future post. </note></b></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Typing gphoto2 --list-ports reveals two USB ports, usb:001,003</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<a href="http://1.bp.blogspot.com/-Abd9bta7afI/VWkZIvkw1hI/AAAAAAAADGU/nqluV4IhpW4/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="http://1.bp.blogspot.com/-Abd9bta7afI/VWkZIvkw1hI/AAAAAAAADGU/nqluV4IhpW4/s200/upload_-1" width="150" /></a>Connected a USB cable from the pi to my Canon PowerShot A470. gphoto2 could not find it. I tried 3/4 USB ports. My keyboard was plugged into the fourth USB port.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<a href="http://4.bp.blogspot.com/-UvL34ny_SVg/VWkZJWDbQsI/AAAAAAAADGc/lb7vKS2-TaQ/s1600/upload_-1" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="http://4.bp.blogspot.com/-UvL34ny_SVg/VWkZJWDbQsI/AAAAAAAADGc/lb7vKS2-TaQ/s200/upload_-1" width="150" /></a>I had to turn the control knob on the back of the camera to "playback" mode. Then, gphoto2 could see it on the USB port.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Did gphoto2 --list-cameras. It does not list the Canon PowerShot A470. There is a 460 and a 480 but not a 470.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
The gphoto2 --auto-detect lists the camera as "Canon PowerShot A740". That camera is in the list.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Some of the commands I tried returned errors. For example, </div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<ul>
<li><span style="line-height: 1.428571em;">list-config: PTP I/O error</span></li>
<li><span style="line-height: 1.428571em;">capture-image: said "your camera does not support generic capture"</span></li>
</ul>
</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
I think I need to find a different camera.</div>
</div>
</div>
</div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-15710232527787217332015-05-15T23:18:00.000-05:002015-05-29T20:10:38.373-05:00Raspberry Pi Based Photo Booth -- IntroductionThe <a href="http://www.milwaukeemakerspace.com/">Milwaukee Makerspace</a> got some new Raspberry Pi 2 computers to use in a build night. We are supposed to make something cool with the Pi and the Adafruit Perma Proto Pi hat. I'm going to try making a photo booth for new members at the Makerspace.<br />
<br />
The main idea for this came from this website: <a data-mce-href="http://www.instructables.com/id/Raspberry-Pi-photo-booth-controller/?ALLSTEPS" href="http://www.instructables.com/id/Raspberry-Pi-photo-booth-controller/?ALLSTEPS" shape="rect" style="border: 0px; color: #047ac6; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 19.9999942779541px; margin: 0px; padding: 0px;" target="_blank">http://www.instructables.com/id/Raspberry-Pi-photo-booth-controller/?ALLSTEPS</a><br />
<br />
The main software for this will be gphoto2. Here are the steps for how the solution will work.<br />
<ol style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; list-style-position: outside; margin: 0.2857em 0px 0.714285em 2em; padding: 0px;">
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Press start button.</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Turn on camera. </li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;"><span style="line-height: 1.428571em;">Display image from the camera on the screen.</span></li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">If timeout, power down.</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Push a button to take the picture.</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Display picture and wait for response.<ol style="border: 0px; line-height: 1.428571em; list-style-position: outside; margin: 0px 0px 0px 2em; padding: 0px;">
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Delete</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Continue</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Timeout</li>
</ol>
</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">If delete or timeout, delete picture.</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">If continue, <ol style="border: 0px; line-height: 1.428571em; list-style-position: outside; margin: 0px 0px 0px 2em; padding: 0px;">
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Print picture</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Send picture to Makerspace web site</li>
</ol>
</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Return to step #3</li>
</ol>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Components needed</div>
<ul style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; list-style-position: outside; margin: 0.2857em 0px 0.714285em 2em; padding: 0px;">
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Raspberry Pi with power supply</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Camera with usb interface</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Start button</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">LED display</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;"><span style="line-height: 1.428571em;">Monitor</span></li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Printer</li>
<li style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">Internet connection</li>
</ul>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span data-mce-style="text-decoration: underline;" style="line-height: 1.428571em; text-decoration: underline;">Alternatives</span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Have one big button that starts the process. Turn on the camera. Display a countdown. Take a picture and use it.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br /></div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-87210400647760657622015-04-25T14:36:00.001-05:002015-04-25T14:36:03.133-05:00Problem finding the InternetOne feature of the <a href="http://wiki.milwaukeemakerspace.org/projects/home_environmental_sensor_array2" target="_blank">HESA</a> program is that it checks to see if it can connect to the internet before trying to make an update. It does this because it will throw an error and kick out of the program if it can't write to the database because the internet is down.<br />
<br />
There is a built-in <a href="http://www.python.org/" target="_blank">python</a> function to check for internet access. The code looks like this.<br />
<a href="https://docs.python.org/2/library/urllib2.html">urllib2.urlopen</a>(reference, timeout=1)<br />
<br />
The URL I use as a reference is 74.125.228.100. That IP address is supposed to be one of google's mail servers. I figured it would be available forever. However, about a week ago, it stopped responding to the python command and pings.<br />
<br />
I did a quick search on the internet about the best IP address to use to test if the internet is up. <a href="http://etherealmind.com/what-is-the-best-ip-address-to-ping-to-test-my-internet-connection/" target="_blank">This site</a> recommended using 8.8.8.8. That is Google's DNS server. Another good idea is to use <a href="http://opendns.com/" target="_blank">Open DNS's</a> DNS server IP address.<br />
<br />
I made simple test program that uses the urlopen function. I sent both the 74.125 and 8.8 addresses to the function. It could not find the internet with either address.<br />
<br />
Then, I used the function to look for http://google.com. The function found that address. So, the python function does not work with IP addresses.<br />
<br />
I changed the code to always look for google.com. Now, it is seeing the internet. Problem solved.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnyWdEKtVfRA7h6KlymbZd8bmlIwvdqRwOwQ0JCIa8Ly9gZp_HnSv_8fIHl52ywlIfMaAJX9L8_CjqDwfqj_Lb_-1E8ts37BMj6z5BXRtWGN5aOAwGz9a3YnK-uTk4DYrShRdrBefRVxOb/s1600/url.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnyWdEKtVfRA7h6KlymbZd8bmlIwvdqRwOwQ0JCIa8Ly9gZp_HnSv_8fIHl52ywlIfMaAJX9L8_CjqDwfqj_Lb_-1E8ts37BMj6z5BXRtWGN5aOAwGz9a3YnK-uTk4DYrShRdrBefRVxOb/s1600/url.jpeg" height="127" width="320" /></a></div>
<br />Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-54109490228504336012015-01-23T22:59:00.000-06:002015-01-23T22:59:04.481-06:00Moteino to Raspberry Pi over Serial v3<div class="tr_bq">
I was able to get my <a href="http://lowpowerlab.com/moteino/" target="_blank">Moteino</a> host talking to my <a href="http://www.amazon.com/gp/product/B00G1PNG54/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00G1PNG54&linkCode=as2&tag=rynokenterprises-20&linkId=XJLYNEHWLCJJLAGQ" target="_blank">Raspberry Pi</a> over the Pi's serial port. Last time, it was working but the information coming over did not make sense. The problem was in my sprintf statement in the <a href="http://www.amazon.com/gp/product/B00BT0NDB8/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00BT0NDB8&linkCode=as2&tag=rynokenterprises-20&linkId=BBSZBLO3W3VT63PU" target="_blank">Arduino</a> sketch. I had a %d parameter in the command. Text was getting converted to numbers. I replaced the %d with a %s and now the sketch sends the correct data to the Pi.</div>
<br />
<a href="http://3.bp.blogspot.com/-SgK0-KdmII4/VLntWDmwetI/AAAAAAAADCo/Lmgfz2lWKgo/s1600/20150116_194820" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://3.bp.blogspot.com/-SgK0-KdmII4/VLntWDmwetI/AAAAAAAADCo/Lmgfz2lWKgo/s1600/20150116_194820" height="150" width="200" /></a>The other problem I was having is that the host was not getting all of the data from the node. The node was sending three measuring points to the host in with about 100ms between each send. The host was getting the first and third MPs but not the second. The easy fix was to put a 500ms pause in between each send. That gave the host enough time to process each piece of data. However, that might not be a good solution. What if two nodes send data to the same host within a half-second of the other? I need to find a better solution.<br />
<br />
After some experimentation, it looks like the problem was the time it took for the Moteino to blink the LED. After each receipt, I was blinking the LED three times with a 100ms pause between each on-off cycle. That was apparently too much time. The middle transmission was getting lost. I turn the blinking down to one per transmission and the host now receives all transmissions. <br />
<br />
Also, the node was sending all three transmissions with three LED blinks with a 100ms pause. I set the blinks to one per transmission and the host could once again not keep up. <br />
<br />
I changed the node to blink once per transmission and pause for 150ms. This limited transmissions to one every 1/4 of a second. The host was able to read those.<br />
<br />
After all of this, I set the node to only transmit one piece of data every five seconds. That way the HESA will have time to process each reading.<br />
<br />
<b>More time experimenting</b><br />
The HESA takes 10 seconds to look for water. Plus, it needs a few seconds to get the temperature and humidity readings from the DHT22. Finally, it has to update the web page every hour. That takes a few seconds.<br />
<br />
I set my test program on the Pi to sleep for ten seconds if there is nothing in the serial's input buffer. I also set the node to send some data every few seconds. When I do that, the host misses 2/3 transmissions each cycle. That is not good. Here is the code I am using:<br />
<blockquote class="tr_bq">
<span style="background-color: black; color: lime; font-family: Courier New, Courier, monospace; font-size: x-small;">import serial<br />import time<br />port = serial.Serial("/dev/ttyAMA0", baudrate=115200, timeout=3.0)<br />while True:<br /> rcv = ''<br />while port.inWaiting() > 0 :<br /> rcv = port.readline(255).strip();<br />if (rcv != "") :<br /> print ("Incoming transmission: " + rcv);<br />else :<br /> print ("Sleeping");<br /> time.sleep(10);</span></blockquote>
<br />
I tried something different. I set the timeout to 0 and read the port every ten seconds. Here is the code in this case:<br />
<div>
<blockquote class="tr_bq">
<span style="background-color: black; color: lime;"><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">import serial</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">import time</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">port = serial.Serial("/dev/ttyAMA0", baudrate=115200, timeout=0.0)</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">while True:</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> rcv = ''</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> rcv = port.read(9999)</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">if len(rcv) > 0 :</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> print ("Incoming transmission: " = rcv);</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">else :</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> print ("Sleeping");</span><span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> time.sleep(10);</span></span></blockquote>
<span style="background-color: white;">Now, the program reads all of the data in the buffer, but it reads it as one big string. Since I am sending the data in three transmissions with EOL, the data looks like this:</span><br />
<span style="background-color: white;"><br /></span>
<span style="background-color: white;"><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">Incoming transmission: 002|101~3369.00</span></span><br />
<span style="background-color: white;"><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">002|102~68.00</span></span><br />
<span style="background-color: white;"><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">002|103~35.00</span></span><br />
<span style="background-color: white;"><br /></span>
<span style="background-color: white;">I will change the node program to do one transmission with all data in one long string. That is for another day.</span><br />
<br /></div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-9198335572453502272015-01-16T23:15:00.000-06:002015-01-16T23:15:12.694-06:00Connect to Raspberry Pi Over Serial Connection<span style="font-family: Verdana, sans-serif; font-size: x-small;">Tonight at my weekly me time at the <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace,</a> I am going to attempt to get my <a href="http://lowpowerlab.com/moteino/" target="_blank">Moteino</a> connected to my <a href="http://www.amazon.com/gp/product/B00L87YMGM/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00L87YMGM&linkCode=as2&tag=rynokenterprises-20&linkId=ZYAJFXFS3VVPHPM2" target="_blank">Raspberry Pi</a> using the serial connection on the Raspberry Pi. Also, to be a bit different, I am going to try to take notes on the blog as I go. This will either help me take better notes or make this blog entry completely unintelligible to any reader who does not think like me.</span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;">There are instructions to work with the Raspberry Pi's serial port at this web page: <a data-mce-href="http://elinux.org/RPi_Serial_Connection" href="http://elinux.org/RPi_Serial_Connection" shape="rect" style="border: 0px; color: #047ac6; line-height: 19.9999942779541px; margin: 0px; padding: 0px;" target="_blank">http://elinux.org/RPi_Serial_Connection</a>. I scrolled down to the section titled "<span class="mw-headline" id="Connection_to_a_microcontroller_or_other_peripheral" style="line-height: 1.3;">Connection to a microcontroller or other peripheral</span><span style="line-height: 1.3;">". There are several things to do to stop the Linux kernel from using the serial port. This is a prerequisite. It looks like there is a <a href="https://github.com/lurch/rpi-serial-console" target="_blank">script</a> someone made to do all of these things automatically. I am going to try to do the steps myself.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;">I edited the /boot/cmdline.txt file. Also, commented out a line in /etc/inittab that opens a login prompt ("getty") on the serial port.</span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;">Rebooted. Logged in with no problems. There are two checks on the web page that you can run to verify that you did it right. Both checks passed. </span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;">The next step is to try interacting with the serial port using Python code. I installed the PySerial package by typing </span><br />
<blockquote class="tr_bq">
<span style="background-color: black; font-size: 14px; line-height: 1.3em;"><span style="color: lime; font-family: Courier New, Courier, monospace;">sudo apt-get install python-serial </span></span></blockquote>
<span style="background-color: #f9f9f9; line-height: 1.3em;"><span style="font-family: Verdana, sans-serif; font-size: x-small;">at the prompt. While the install was running, I noticed a message saying that there were some packages that were no longer used that could be uninstalled. I ran </span></span><br />
<blockquote class="tr_bq">
<span style="background-color: black; line-height: 1.3em;"><span style="color: lime; font-family: Courier New, Courier, monospace; font-size: x-small;">sudo apt-get autoremove</span></span></blockquote>
<span style="background-color: #f9f9f9; line-height: 1.3em;"><span style="font-family: Verdana, sans-serif; font-size: x-small;">to get rid of those packages.</span></span><br />
<span style="background-color: #f9f9f9; line-height: 1.3em;"><span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><a href="http://elinux.org/Serial_port_programming" target="_blank">This page</a> has a very small python program to test the serial connection. I used nano to create it. </span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">The first test I did was to connect the Raspberry Pi's serial pins to the serial pins on the Moteino -- </span></span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"> <span style="line-height: 20.7999992370605px;">Tx to Rx, Rx to Tx, and Gnd to Gnd. Then, I connected the Moteino to my Linux laptop using the FTDI adapter. I loaded the Arduino IDE on the laptop, uploaded the HESA_Host sketch, plugged in the USB to the Moteino, and ran the python program. Nothing happened. I don't know if the problem was that the Moteino does not know what to do when there are two serial connections or if my sketch is bad.</span></span><br />
<br />
<a href="http://3.bp.blogspot.com/-ea_oux30j0c/VLntVAf40HI/AAAAAAAADCg/MM32Jy_eE98/s1600/20150116_194448" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://3.bp.blogspot.com/-ea_oux30j0c/VLntVAf40HI/AAAAAAAADCg/MM32Jy_eE98/s1600/20150116_194448" height="150" width="200" /></a><span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">The next test I did was to bypass the Moteino and connect the serial wires from the Raspberry Pi directly to the FTDI adapter. That test worked. The terminal screen on the Arduino displayed the output from the Pi and the Pi received the text I typed in on the terminal screen. Cool!</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">Tried again with the FTDI connected to the Moteino and the Moteino connected to the Pi. Made some small modifications to the sketch and tried uploading it to the Moteino. The sketch would not upload. </span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">Unplugged the TxRx wires from the Pi. Now, the sketch will upload.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<a href="http://3.bp.blogspot.com/-ICSvB3ltRwE/VLntQgXGCiI/AAAAAAAADCE/CB0faeOvim0/s1600/20150116_205909" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://3.bp.blogspot.com/-ICSvB3ltRwE/VLntQgXGCiI/AAAAAAAADCE/CB0faeOvim0/s1600/20150116_205909" height="150" width="200" /></a><span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">For the next test, I changed the python code so it will send the letter "t" to the serial port every second, read the results on the serial port, and print the results, if any to the screen. I also connected a wire from one of the 5v outputs on the Pi to the VIn pin on the Moteino. I ran the python code and it worked perfectly. The Moteino faithfully sent its temperature back to the Pi everytime it received a T.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">Time to try the whole solution. I setup my node with the DHT11 temperature sensor. Then, I started the python program and waited a few seconds. Next, I powered up the Moteino host. It transmitted its messages from the setup part of the sketch. Finally, I powered up the Moteino node. It started transmitting its data every few seconds. Everything worked. The host received the transmissions and sent them to the Raspberry Pi. The python program displayed the transmissions on the screen.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-qJ1kGY_12OQ/VLntSlP3nFI/AAAAAAAADCI/IHf4T7BZ1E0/s1600/20150116_205900" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-qJ1kGY_12OQ/VLntSlP3nFI/AAAAAAAADCI/IHf4T7BZ1E0/s1600/20150116_205900" height="150" width="200" /></a></div>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">One problem is that it looks like the python program started displaying the ascii text as hex characters, ex. 0\xe0\x00. That seems to have started after it received a "]" character.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">Tried changing the baudrate on both devices to 9600. That did not help.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">Tried adding a \n to the end of each transmission to the serial port. That did not help.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">Tried putting a 1ms delay after every transmission. That did not help.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">The weird thing is that if I send a T to the Moteino, the sketch returns the temperature text with no problems. Anything else looks like hex.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">Figured it out. I had some code in the sketch turn off the Moteino in between transmissions to save power. This was the cause of the garbled code. Turning off the power save feature fixed the problem. I don't really need the power save feature since the host Moteino will get power from the Pi.</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">The new problem is that the data being sent to the PI does not appear to be the data the node is sending. The data should be something like "002|102~87", but it is some other combination of number. I'll have to look into that later. </span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">Also, need to figure out how to know when a batch of data is from one node. Maybe I could put some text around each end of the package. For example, ">>>002|102~67<<<".</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;"><br /></span></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><span style="background-color: #f9f9f9; line-height: 20.7999992370605px;">I'll have to figure that out some other time. That's enough for one night.</span></span>Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-32473415812014993402015-01-03T18:07:00.001-06:002015-01-03T18:07:27.021-06:00Moteino Node Talking to HostAfter about two weeks off for the holidays, I spent time at the <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace</a> working on the <a href="http://www.moteino.com/" target="_blank">Moteinos</a> for my <a href="http://wiki.milwaukeemakerspace.org/projects/home_environmental_sensor_array2" target="_blank">Home Environmental Sensor Array</a>.<br />
<br />
<b><u>3D Print of a Battery Holder</u></b><br />
<a href="http://2.bp.blogspot.com/-cHUoHrzysdc/VIyqKTIdb1I/AAAAAAAAC_Y/S85jN7O4oS8/s1600/20141213_150157" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://2.bp.blogspot.com/-cHUoHrzysdc/VIyqKTIdb1I/AAAAAAAAC_Y/S85jN7O4oS8/s1600/20141213_150157" height="200" width="150" /></a>As part of the node solution for the HESA, I want to have a complete stand-alone package that includes a holder for the battery. Also, I want to have 6v battery for the power supply since the Moteino needs at least a 3.2v input.<br />
<br />
I have a <a href="http://www.amazon.com/gp/product/B001TQE34S/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B001TQE34S&linkCode=as2&tag=rynokenterprises-20&linkId=42ASMRP6VIPXE5DI" target="_blank">6v Lithium battery from Energizer</a>. I made a case for it but it is not ideal and not reproducible. I found a <a href="http://www.thingiverse.com/thing:242922" target="_blank">Thing</a> on <a href="http://www.thingiverse.com/" target="_blank">Thingiverse</a> to 3D print a holder for a Panasonic Lithium battery.<br />
<br />
<a href="http://thingiverse-production.s3.amazonaws.com/renders/ee/62/45/09/24/NP-BX1-1_preview_featured.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://thingiverse-production.s3.amazonaws.com/renders/ee/62/45/09/24/NP-BX1-1_preview_featured.jpg" height="150" width="200" /></a>I printed the holder on the <a href="http://wiki.milwaukeemakerspace.org/equipment/cubeprotrio?&#checked_out_members" target="_blank">Cube Pro Trio 3D printer</a> at the Makerspace. The printer is very easy to use. I was hoping it would be more reliable than the other printers we have but my first print failed. I printed the holder in draft mode and it finished but the corners pealed up a bit. Also, I found out that the Panasonic battery is longer than the Energizer and the terminals are in different spots. So, I won't be able to use the holder and will have to find a different solution. <br />
<br />
On the plus side, I learned how to use the <a href="http://www.amazon.com/gp/product/B00LLH18H0/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00LLH18H0&linkCode=as2&tag=rynokenterprises-20&linkId=VVRGCCO2CLY7YRZ4" target="_blank">CubePro Trio</a> printer. This is a professional-grade 3D printer that should make high quality prints.<br />
<br />
<b><u>ACK Testing</u></b><br />
The <a href="http://beckermaker.blogspot.com/2014/12/power-monitoring-with-moteino-attempt-2.html" target="_blank">last time</a> I played around with the Moteino, the node was sending data to the host but the node was never getting an ACK back from the host. I tested combinations of all three Moteinos with the same results. I posted something on the Moteino forum and the response was that it should work. I finally got back to testing the ACK feature and was able to get it working -- sort-of.<br />
<br />
I think the original problem is that I did not have the antennas attached to the Moteinos. I soldered antennas onto all three Moteinos, and they now send and receive ACKs properly.<br />
<br />
However, this gets more and more unreliable as the distance between the node and host increases. When the distance is less than 20 feet, the ACKs are almost always received. At 50 feet, ACKs are received about 50% of the time. If I go over 100 yards away, almost no ACKs are received.<br />
<div>
<br /></div>
<div>
I posted a message on the Moteino forum to see what the problem is. However, I also decided that I don't care about ACKs for the HESA. For now, I can continue without this feature.</div>
<div>
<br /></div>
<div>
<b><u>HESA Node</u></b></div>
<div>
<a href="http://4.bp.blogspot.com/-VP-exWPpDlY/VIyqZN8jh9I/AAAAAAAAC_4/6gqA9MnNQYE/s1600/20141205_163905" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-VP-exWPpDlY/VIyqZN8jh9I/AAAAAAAAC_4/6gqA9MnNQYE/s1600/20141205_163905" height="200" width="150" /></a>Finally, I created a sketch for a node on the HESA network. The sketch will read and transmit the following information to the host:</div>
<div>
<ul>
<li>Notification that it is on-line on bootup</li>
<li>Battery voltage</li>
<li>Temperature from the RF69 chip or from a DHT sensor if installed.</li>
<li>Humidity from DHT sensor if installed</li>
</ul>
<div>
The code is flexible enough to request ACKs or not when sending data. The device will also sleep between sends. This should make the battery last longer.</div>
</div>
<div style="background-color: white; border: 0px; color: #222222; line-height: 19.9999942779541px; margin: 0px; padding: 0px;">
<span style="font-family: inherit;"><br /></span><span style="line-height: 1.428571em;"><span style="font-family: inherit;">The next step is to connect the host to a Raspberry Pi and have the Pi read the serial inputs. Then, I need design a circuit board and complete solution for the node. Finally, I need to make the HESA python program on the RPi send node data to the SQL database.</span></span><span style="font-family: inherit;"><br clear="none" /></span><span style="font-family: inherit;"><br /></span></div>
<div style="background-color: white; border: 0px; color: #222222; line-height: 19.9999942779541px; margin: 0px; padding: 0px;">
<span style="font-family: inherit;">RPI serial console: <a data-mce-href="http://elinux.org/RPi_Serial_Connection" href="http://elinux.org/RPi_Serial_Connection" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px; text-decoration: none;" target="_blank">http://elinux.org/RPi_Serial_Connection</a></span></div>
<div>
<br /></div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-60289592214822165992014-12-20T16:43:00.001-06:002014-12-20T16:43:46.977-06:00Power Monitoring with the Moteino -- Attempt #2<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
This weekend at the <a href="http://www.milwaukeemakerspace.com/" target="_blank">Milwaukee Makerspace</a>, I continued trying to get my <a href="https://lowpowerlab.com/moteino/" target="_blank">Moteinos</a> to communicate to each other. I want to get a node to send its power level to the host. I performed a number of tests and eventually accomplished the goal.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span data-mce-style="text-decoration: underline;" style="line-height: 1.428571em; text-decoration: underline;"><strong style="line-height: 1.428571em;">Basic TxRx Test</strong></span></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<a href="http://4.bp.blogspot.com/-yHWR3OedGp0/VIyqSnw-nMI/AAAAAAAAC_w/CEAknQnHZzg/s1600/20141205_195929" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-yHWR3OedGp0/VIyqSnw-nMI/AAAAAAAAC_w/CEAknQnHZzg/s1600/20141205_195929" height="150" width="200" /></a>First, I numbered the Moteinos 1, 2, and 3. Each Moteino was setup at a frequency of 915mhz. The high power setting for the RFM69HW was set on all Moteinos. For the first test, I opened the serial terminal window in the Arduino IDE on each Moteino so I could see the messages it was sending. For the other tests, the terminal was only on the Receiver.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
The test involved uploading the <a href="https://github.com/LowPowerLab/RFM69/blob/master/Examples/TxRxBlinky/TxRxBlinky.ino" target="_blank">TxRxBlinky</a> sketch on each Moteino -- one as the Receiver, and one as the Sender. I hooked a button up to the Sender. Once both Moteinos were powered up, I pushed the button on the Sender. This caused the LED on the Receiver to change state -- on to off or off to on. The Receiver also sends some text to the serial monitor.</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<div style="text-align: center;">
<br /></div>
</div>
<div style="border: 0px; font-family: Helvetica, Arial, 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<table border="1" cellpadding="2" cellspacing="0" center="" data-mce-style="border-collapse: collapse; table-layout: fixed;" style="border-collapse: collapse; font-size: 1em; line-height: 1.428571em; table-layout: fixed; width: 75%px;"><tbody style="line-height: 1.428571em;">
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top"><strong style="line-height: 1.428571em;">SENDER</strong></td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top"><strong style="line-height: 1.428571em;">RECEIVER</strong></td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top"><strong style="line-height: 1.428571em;">RESULTS</strong></td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
</tbody></table>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<div style="text-align: center;">
<br clear="none" /></div>
</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
All tests passed. All Moteinos can both send and receive. Also, they all operate with either the USB as a power source or the <a href="http://www.amazon.com/gp/product/B0001Y6J14/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B0001Y6J14&linkCode=as2&tag=rynokenterprises-20&linkId=ICK6ASYCDYZ3V3B3" target="_blank">Lithium 6v battery</a> as the power source.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<span data-mce-style="text-decoration: underline;" style="line-height: 1.428571em; text-decoration: underline;"><strong style="line-height: 1.428571em;">Gateway / Node Test</strong></span></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
For the next test, I used the <a href="https://github.com/LowPowerLab/RFM69/blob/master/Examples/Gateway/Gateway.ino" target="_blank">Gateway</a> / <a href="https://github.com/LowPowerLab/RFM69/blob/master/Examples/Node/Node.ino" target="_blank">Node</a> sketches from LowPowerLab. The Gateway sketch was loaded on the Receiver Moteino and the Node sketch was loaded on the Sender Moteino. All Moteinos were set at 915mhz frequency. The high power setting was set on all Moteinos.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Before testing a pair of Moteinos, I loaded the Node sketch on one Moteino and watched what happened with the serial monitor. The Moteino outputted exactly what it was supposed to.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
Next, I uploaded the Gateway sketch to a Moteino and started testing.</div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; line-height: 1.428571em; margin: 0px; padding: 0px;">
<table border="1" cellpadding="2" cellspacing="0" data-mce-style="border-collapse: collapse; table-layout: fixed;" style="border-collapse: collapse; color: black; font-size: 14px; line-height: 19.9999942779541px; table-layout: fixed; width: 75%px;"><tbody style="line-height: 1.428571em;">
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top"><b>Test</b></td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top"><b>Gateway</b></td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top"><b>Node</b></td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top"><b>Results</b></td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">4</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">5</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M1</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
<tr style="line-height: 1.428571em;"><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">6</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M2</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">M3</td><td colspan="1" data-mce-style="padding: 10.0px; margin: 0.0px; border: 1.0px solid #d9d9d9;" rowspan="1" style="border: 1px solid rgb(217, 217, 217); line-height: 1.428571em; margin: 0px; padding: 10px;" valign="top">Passed</td></tr>
</tbody></table>
<div style="border: 0px; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
All tests passed.</div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<span data-mce-style="text-decoration: underline;" style="line-height: 1.428571em; text-decoration: underline;"><strong style="line-height: 1.428571em;">Custom Node Test</strong></span></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
Now that I know all of Moteinos can talk to each other, I tested a custom node program. It is set to transmit at 915mhz. The high power setting for the RFM69HW is set. <br />
<br />
The custom program is a modified version of the Node sketch from LowPowerLab. The sketch reads the voltage from the Moteino and transmits it to the host. (More information about the code to read the voltage is in <a href="http://beckermaker.blogspot.com/2014/11/power-monitoring-with-moteino-attempt-1.html" target="_blank">this post</a>.)</div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
I had the same problem with the sketch that I had last week. If the Node program tries to read the voltage using the readVCC function, then tries to use the radio.sendWithRetry function, the Moteino appears to reboot--it is re-running the setup function. If I comment out the line that calls readVCC, the rest of the code processes normally. However, the send line prints the message indicating it failed. </div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
After a lot of testing, I realized that the failure message I am getting is always there -- even with the code that comes with the Moteino. I ran my Node program and the Host displayed the voltage from the Node. The code works even though the failure message prints. I don't know if there is something wrong with the code or if I don't understand how the read.send function is supposed to work.</div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
I don't know why the Moteino was rebooting. I did fix that problem by starting over with the original Node program and adding my code bit by bit. The problem did not re-occur. Maybe I had some invisible characters in the code.</div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
Finally, I tested the voltage that is read by the node. I connected a variable power supply to the power input on the Node. This let me vary the input voltage. I started at 6 volts and slowly turned the voltage down. Sending any voltage over 3.2 registers as 3349 millivolts. Once the voltage was turned down to 3.2 volts, the device read 3205 or 3196 millivolts. When the input got down to 3.1 volts, the node stopped transmitting. So, I will be able to use this code to monitor my battery's voltage.<br />
<br />
One of the next steps is to understand how the node and host communicate. <br />
<br />
<ul>
<li><span style="line-height: 1.428571em;">Can the node sleep until the host calls it? </span></li>
<li><span style="line-height: 1.428571em;">If the node sends data to the host, will it get lost? Is there a way to know for sure?</span></li>
<li><span style="line-height: 1.428571em;">How do we make the device truly low-power?</span></li>
<li><span style="line-height: 1.428571em;">What does the Ack do?</span></li>
</ul>
<span style="line-height: 1.428571em;">Another step is to connect the host to a Raspberry Pi and have the Pi read the serial inputs.</span></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
<br clear="none" /></div>
<div style="border: 0px; margin: 0px; padding: 0px;">
RPI serial console: <a data-mce-href="http://elinux.org/RPi_Serial_Connection" href="http://elinux.org/RPi_Serial_Connection" shape="rect" style="border: 0px; color: #047ac6; line-height: 1.428571em; margin: 0px; padding: 0px;" target="_blank">http://elinux.org/RPi_Serial_Connection</a><br />
<br />
+Moteino<br />
#Moteino</div>
<div>
<br /></div>
</div>
</div>
Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-45616560948108164492014-12-14T14:36:00.000-06:002014-12-14T14:36:27.374-06:00Possible Smoked Moteino<a href="http://4.bp.blogspot.com/-eTkZZFSSLbk/VHAFDG41l4I/AAAAAAAAC8M/Ba-FMUA31Cs/s1600/20141121_185213" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-eTkZZFSSLbk/VHAFDG41l4I/AAAAAAAAC8M/Ba-FMUA31Cs/s1600/20141121_185213" height="200" width="150" /></a>As I mentioned in my last post, I inadvertently plugged power into the GND pin on one of my brand new <a href="http://lowpowerlab.com/moteino/" target="_blank">Moteinos</a>. There was a small puff of smoke and I quickly unplugged the power. However, I had a bad feeling that I just ruined my $20 device.<br />
<br />
I tested the <a href="https://lowpowerlab.com/shop/index.php?_route_=moteino-r4" target="_blank">Moteino</a> to see if anything still worked. First, I plugged in the <a href="https://lowpowerlab.com/shop/index.php?_route_=FTDI-Adapter&search=ftdi" target="_blank">FTDI adapter</a> and used a <a href="http://www.amazon.com/gp/product/B001MSU1HG/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B001MSU1HG&linkCode=as2&tag=rynokenterprises-20&linkId=BVTPJJ2CIAZXR4FL" target="_blank">USB cable</a> to connect the Moteino to my PC. The <a href="http://www.amazon.com/gp/product/B00BT0NDB8/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00BT0NDB8&linkCode=as2&tag=rynokenterprises-20&linkId=4NLVPFKN3AH6V65I" target="_blank">Arduino</a> IDE software saw the board. I uploaded the "Fade" example sketch to the Moteino. It worked.<br />
<br />
Next, I loaded the TxRxBlinky example sketch for the Moteino. I was able to use the Moteino as a Sender device. I assume that means that the transceiver is also working.<br />
<br />
<a href="https://farm4.staticflickr.com/3818/10585364014_a1c2871470.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="115" src="https://farm4.staticflickr.com/3818/10585364014_a1c2871470.jpg" width="200" /></a>Finally, I used a <a href="http://www.amazon.com/gp/product/B000JQ4O2U/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B000JQ4O2U&linkCode=as2&tag=rynokenterprises-20&linkId=OSCCAN6A3BHHGVQ4" target="_blank">multimeter</a> to check the voltages. The <a href="http://www.amazon.com/gp/product/B0001Y6J14/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B0001Y6J14&linkCode=as2&tag=rynokenterprises-20&linkId=OQYIL6COGHCZWTQU" target="_blank">Lithium battery</a> I had hooked up was sending 6.27 volts to the Moteino VIN pin. The 3.3 pin on the Moteino was putting out 3.31 volts. This means that the regulator in the Moteino is also working.<br />
<br />
I think everything is working. I'm going to try using this Moteino as the main receiver on my <a href="http://wiki.milwaukeemakerspace.org/projects/home_environmental_sensor_array2" target="_blank">Home Environmental Sensor Array</a>.<br />
<br />
<span style="font-size: xx-small;">+Moteino</span><br />
<span style="font-size: xx-small;">+Microcontroller</span><br />
<span style="font-size: xx-small;">+Arduino</span><br />
<span style="font-size: xx-small;">#Moteino, #Microcontroller, #Arduino</span>Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0tag:blogger.com,1999:blog-3283681064100685721.post-78764724078344473712014-12-13T16:42:00.000-06:002014-12-13T16:42:08.431-06:00Testing MoteinosThis blog post is covering my last two weeks of activity on the <a href="http://lowpowerlab.com/moteino/" target="_blank">Moteino</a>s for my <a href="http://wiki.milwaukeemakerspace.org/projects/home_environmental_sensor_array2" target="_blank">Home Environmental Sensor Array</a>. Topics include<br />
<br />
<ol>
<li>Power supply experiments</li>
<li>Attaching a power supply to a Moteino node</li>
<li>Testing multiple Moteinos</li>
</ol>
<br />
<b>Power Supply Experiments</b><br />
<a href="http://4.bp.blogspot.com/-6Ohg2PDRKpQ/VHAE_r3i96I/AAAAAAAAC7s/I3IUxsNBaQc/s1600/20141121_185849" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-6Ohg2PDRKpQ/VHAE_r3i96I/AAAAAAAAC7s/I3IUxsNBaQc/s1600/20141121_185849" height="150" width="200" /></a>I spent a good deal of time trying different ways to power the <a href="http://lowpowerlab.com/moteino/" target="_blank">Moteino</a>. I was hoping that I could use a <a href="http://www.amazon.com/gp/product/B0042A9UXC/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B0042A9UXC&linkCode=as2&tag=rynokenterprises-20&linkId=H242VJRQJE5YLDU3" target="_blank">3v Lithium battery</a> as a power source. That way, I could have an easily replaceable and cheap power source. However, the coin cell battery I used did not appear to provide enough power to run the Moteino.<br />
<br />
Next, I tried a 3.6v Lithium battery that I found in the battery box at the <a href="http://www.milwaukeemakerspace.org/" target="_blank">Makerspace</a>. It put out about 3.6 volts on its own. After connecting it to the Moteino, I used a <a href="http://www.amazon.com/gp/product/B000EVYGZA/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B000EVYGZA&linkCode=as2&tag=rynokenterprises-20&linkId=B6IYAYQ7IVO2PN42" target="_blank">multimeter</a> to see how many volts were going into the Moteino. It registered at about 1.4 volts. Not sure what is happening but this battery does not provide enough power for the Moteino either.<br />
<br />
Finally, I tried using a <a href="http://www.amazon.com/gp/product/B002XJVU0A/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B002XJVU0A&linkCode=as2&tag=rynokenterprises-20&linkId=PK6DALMESFFRQCAH" target="_blank">6v lantern battery</a> as a power input. That worked better. When I tested the voltage with a multimeter, it registered 6.23 volts. After I connected the battery to the Moteino, I tested the voltage by putting the test leads on the GND and VIN pins on the Moteino. It registered 6.17 volts. Since the Moteino has a built-in power regulator that limits the voltage to 3.3 volts, this is more than enough power.<br />
<br />
In order to power nodes, the Moteino needs a power source that delivers between 5-9 volts. The two options are a <a href="http://www.amazon.com/gp/product/B0001Y6J14/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B0001Y6J14&linkCode=as2&tag=rynokenterprises-20&linkId=BCGEYQRKUDS3TTIW" target="_blank">6v Lithium battery</a> or a <a href="http://www.amazon.com/gp/product/B002UGVWA4/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B002UGVWA4&linkCode=as2&tag=rynokenterprises-20&linkId=VQ5ZPVFLGZZVELL5" target="_blank">9v NiCd battery</a>. I would prefer the smaller battery because it will waste less energy when the Moteino converts the voltage to 3.3 volts.<br />
<br />
<b>Attaching a Power Supply to a Moteino Node</b><br />
Now that I know how much power I need to supply, the next task is to figure out how to attach power to a Moteino that will operate as a stand-alone node.<br />
<br />
<a href="http://2.bp.blogspot.com/-1yVGnOKyd6c/VIy06S_rZWI/AAAAAAAADAI/ijWmQ35ryBQ/s1600/20141213_155010" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://2.bp.blogspot.com/-1yVGnOKyd6c/VIy06S_rZWI/AAAAAAAADAI/ijWmQ35ryBQ/s1600/20141213_155010" height="200" width="150" /></a>I bought a <a href="http://www.amazon.com/gp/product/B0001Y6J14/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B0001Y6J14&linkCode=as2&tag=rynokenterprises-20&linkId=BCGEYQRKUDS3TTIW" target="_blank">6v Lithium battery</a> as an external power source. It is just a bit bigger than a 9v battery. Also, the power ports are recessed. This makes it difficult to attach wiring to the battery. <br />
<br />
My first idea for a reliable power storage solution for the 6v battery was to re-use an existing 9v battery container. I found an old clock radio on the <a href="http://wiki.milwaukeemakerspace.org/miscellaneous/hackrack" target="_blank">hack rack</a> at the <a href="http://www.milwaukeemakerspace.org/" target="_blank">Milwaukee Makerspace</a>. The radio had a space for a 9v battery built-in to one part of the plastic case. I cut out the 9v battery compartment from the case.<br />
<br />
<a href="http://2.bp.blogspot.com/-cHUoHrzysdc/VIyqKTIdb1I/AAAAAAAAC_Y/S85jN7O4oS8/s1600/20141213_150157" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-cHUoHrzysdc/VIyqKTIdb1I/AAAAAAAAC_Y/S85jN7O4oS8/s1600/20141213_150157" height="200" width="150" /></a>I settled on the idea of using screw heads to connect to the recessed battery terminals. First, I cut a small piece of balsa wood to fit into the bottom of the compartment. The wood is just a bit smaller than the compartment. The wood is just big enough to not move around. Also, when the battery is inserted into the compartment, it will keep the wood from moving. <br />
<br />
Next, I put two screws through the wood and cut off the extra length of each screw with the <a href="http://wiki.milwaukeemakerspace.org/equipment/bandsawvertical" target="_blank">metal bandsaw</a>. Finally, I attached wires to each screw. In hindsight, I should have put the aluminum strips on the top of the wood. That would have helped the conductivity of the wires to the screws.<br />
<br />
<a href="http://4.bp.blogspot.com/-MGdQbeFYpDM/VIyqL2fYy8I/AAAAAAAAC_g/L-c2b8mB9OU/s1600/20141213_150146" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-MGdQbeFYpDM/VIyqL2fYy8I/AAAAAAAAC_g/L-c2b8mB9OU/s1600/20141213_150146" height="150" width="200" /></a>Putting the battery into the compartment so it has good contact with the screws is a bit tricky since I can't really see what is going on. However, once the battery is in properly, it delivers 6v. I can connect the wire leads either to a prototype board or to input pins on a circuit board. Although this does work, it is not an ideal solution. Ideally, I would like a solution that works as easily as traditional battery connectors. Either I could rig up a cap like 9v batteries have or I need a more cozy container that is a better fit for the lithium battery and makes a good connection every time a battery is inserted. Maybe I could 3D print a container.<br />
<br />
Also, I was testing the battery with one of my Moteinos and I inadvertently attached the positive wire to the GND pin on the Moteino. The Moteino started smoking. I immediately pulled out the wire but I don't know what damage was done. When I connect the Moteino to my computer with the FTDI cable, it powers up. The Arduino IDE client sees the device. I uploaded a sketch to the Moteino that made an LED blink. I still need to test the RF device. If that works, the Moteino may not have been damaged at all. That would be a blessing.<br />
<br />
<b>Testing Multiple Moteinos</b><br />
I purchased two more Moteinos -- one for my first node, and one for backup or the second node. The <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<a href="http://4.bp.blogspot.com/-yHWR3OedGp0/VIyqSnw-nMI/AAAAAAAAC_w/CEAknQnHZzg/s1600/20141205_195929" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-yHWR3OedGp0/VIyqSnw-nMI/AAAAAAAAC_w/CEAknQnHZzg/s1600/20141205_195929" height="150" width="200" /></a>Moteino site has a <a href="http://lowpowerlab.com/moteino/#programming" target="_blank">section on programming the Moteino</a>. One of the Arduino sketches allows you to test a receiver / sender pair of Moteinos. When you press a button connected to the sender Moteino, it sends a signal to the receiver that toggles an LED -- if it is off, it turns on, and vice-versa.<br />
<br />
I was able to successfully test this with two of the Moteinos. Now, I know a bit more about using the Moteinos. Next, I need to figure out how to connect the receiver Moteino to my Raspberry Pi. Another next step is to write a sketch to read something on the node and send it to the receiver Moteino.Ken Beckerhttp://www.blogger.com/profile/00834923475826429615noreply@blogger.com0