To test and operate the device, follow the steps below.
4.3.1 Testing Paper Feed
Flip Switch into the “ON” position to power unit.
Push the small black button located on the printer case to feed the paper out by one line. If it feeds out smoothly, skip step 3.
If the paper jams or does not feed out properly, follow the paper installation steps again. Repeat step 2.
4.3.2 Printing Current Weather Data
Push the large button below the printer case to request a print-out of the current weather. It can take several seconds to connect to the internet before printing.
Remove printed paper by tearing down from side to side.
Note: Status LED will constantly blink if the printer is low on, or out of paper.
|
4.4 Troubleshooting
Should any problems occur when operating the device, refer to these troubleshooting tips.
Problem
|
Troubleshooting Tips
|
Paper will not print, LED flashing
|
Flashing LED indicates the printer is low on, or out of paper
|
Paper will not print, LED not flashing
| |
Paper jammed
|
See Page 2 and reinstall paper roll
|
5.0 Theory of Operation
The basis of this project is communication with the internet through Wi-Fi to retrieve weather data, and print the data out on a receipt printer. The process is to connect to a wireless network, then connect to a website with easy to retrieve weather data, next to request the weather from Saskatoon, and finally display that to the user. To make use of this process, understanding of Wi-Fi, Application Program Interface, Hypertext Transfer Protocol, and receipt printer command sets were needed. Understanding of these topics was necessary to choose the components for my project.
5.1 Wireless Internet
When considering ways for receiving and transmitting data, Wi-Fi is quickly becoming a better choice due to it becoming cheaper and more accessible. If a device is in an area with wireless internet, there is no need for transmitting data long distances, physically connecting to the internet, or manually retrieving data. Data can be stored and retrieved from anywhere at any time. This is often referred to as the Internet of Things (IoT). “At its core, IoT is simple: it’s about connecting devices over the internet, letting them talk to us, applications, and each other. The popular, if silly, example is the smart fridge: what if your fridge could tell you it was out of milk, texting you if its internal cameras saw there was none left, or that the carton was past its use-by date?” [Nic15].
For this project, only 1-way communication is needed, as the device only retrieves data from a website. It does not communicate back any data.
5.2 Application Program Interface (API)
“An application-programming interface (API) is a set of programming instructions and standards for accessing a Web-based software application or Web tool. A software company releases its API to the public so that other software developers can design products that are powered by its service” [Dav07]. There are APIs available for things like Google Calendar, Twitter, Facebook, and of course weather. There are many standalone websites devoted entirely to being an API service. These sites make it easy to get data of interest without having to search through a huge amount of unwanted website data. This is the type of site preferred to get the current weather. From their service one can specify which things like city, forecast, and number of days desired.
Some weather API services include openweathermap.org, wunderground.com, developer.forecast.io, and worldweatheronline.com. I am currently using Open Weather Map, as it is a free, popular, and reliable service.
5.2.1 World Weather Online
I began this project using the service from World Weather Online, and built the prototype around it. I was drawn to the service because it was simple, well documented, and allowed for very good data selectivity, and the ability to receive data in comma separated values (CSV) format. By early March, the prototype would not return weather data successfully, and I found that the URL I was using was returning an error.
According to their official Facebook page, the site had been receiving DDoS (distributed denial-of-service) attacks to disrupt the service. For 2-3 weeks users were reporting errors with the service. After about a week, I was able to view the API URL from my computer again, but making the actual API call from the Wi-Fi module only worked sporadically. I decided that I would need to find a new service to use as World Weather Online was no longer reliable.
5.2.2 Open Weather Map
Open Weather Map is a very popular service that even tops the google search results for “weather API”. The service was not as flexible as World Weather Online, but the documentation was good, and I expected it would be one of the most reliable services available. The main downside to using this service was that CSV format was not available, so I had to change project to work with JSON data.
5.3 HTTP Requests
HTTP stands for Hypertext Transfer Protocol, and it is the language of websites and the transfer of information. Once connected to a web server, HTTP requests can be made to either get or post data to a server. There are several of these requests, but the most basic of these are GET and POST. A GET request is used to retrieve certain information from a server. A POST request is used to send data to a server. This project only needs to make use of the GET request, as it is only needed to retrieve weather data from a server. GET requests follow a certain syntax, and has several optional fields to narrow in on results [HTT].
For the needs of this project, it is only necessary to need the server and the URL containing the data of interest. Shortly after making the request, the server will respond with the data located at the URL. From there data can be parsed to isolate values such as temperature and wind speed.
Most available receipt printers on the market use to use a command set called ESC/POS, which stands for Epson Standard Code/ Point of Sale. The printer I chose makes use of this command set to format the information I display to the user. Some commands available include: justification, bold, double size, font type, and letter orientation [Kas16].
6.0 Component Selection
This section explains the rationale for why I selected the different components that make up my project. Components that best meet the requirements of the project were chosen after weighing their advantages and disadvantages. Each component selection is based on the Theories of Operation discussed above.
6.1 Microcontroller
In our classes, we studied Microchips PIC18F series of microcontrollers, so it makes sense to use a microcontroller from this family for my project. I used Microchip’s search function to narrow down the search based on my needs. I need a microcontroller with a 3.3 Volt operating voltage as communication with my chosen Wi-Fi module needs to be done with 3.3 Volts. Two onboard USART (Universal Synchronous Asynchronous Receiver Transmitter) modules are needed for this project, one for the printer and one for the Wi-Fi module.
The microcontroller that best fits the needs of this project is the PIC18LF25K22. It fits the specifications listed above, and has mid-range program memory and RAM (Random Access Memory). Information regarding this microcontroller was found from Microchips website.
6.2 Wi-Fi Module
A Wi-Fi module is needed to wirelessly connect to the internet and retrieve data. Some of the ideal properties of such a module would include: USART communication, simple to use, reasonable cost, and good documentation.
The ESP8266 is a very popular Wi-Fi module among electronic hobbyists, both for its low cost and simple command set. Because of its popularity, it has a lot of documentation and even a small community built around using it. I have prior experience with this device, and already had a basic understanding of using it.
ESP8266 Specifications:
3.3 Volt operating Voltage
USART communication
215 mA peak current draw
no external antenna needed
< $5
The XBee is another fairly popular device for connecting to the internet, so it has good documentation. The command set isn’t too complicated, but more so than the ESP8266. High cost and high power consumption are negatives.
XBee 56B Specifications:
3.3 Volt operating Voltage
USART communication
309 mA peak current draw
antenna optional
$35
This device has the lowest power consumption, and average cost compared to competitors, but the main downside is its complexity. It is a very powerful device with a large amount of functionality and features. As my project only requires basic Wi-Fi communication, this amount of functionality is more than is needed, and learning it would take a much longer time than the other two devices. That is reason enough for me to go with another option.
Microchip RN1723 Specifications:
3.3 Volt operating Voltage
USART communication
120 mA peak current draw
antenna optional
$16
In the end I decided to go with the ESP8266 module, as it best fits my requirements, and I already have some experience with it. The ESP8266 family contains over a dozen different types. I will be using the ESP-12E board. It is one of the most recent boards, is a surface mount device, and does not need an external antenna.
6.3 Thermal Receipt Printer
Finding an appropriate receipt printer for this project was a bit tricky. The ideal printer would be small, sleek, reasonably priced, come with USART communication, and with good documentation to make it easy to implement. Most printers on the market are actually meant for point-of-sale purposes, so they are too expensive ($100-$400), have an awkward shape that would make it difficult to mount in a case, and use a USB data connection rather than USART.
I was familiar with the CSN-A2 Thermal Receipt Printer before choosing this project, and it was part of my inspiration for doing it. This printer is popular in hobbyist projects online, which made it an attractive option for my needs. The specifications of this printer are listed below.
Specifications:
small size, rectangular shape
$50-$60
USART communication
5 Volt -12 Volt operation
paper sensor
sleep mode for power saving
maximum 1.5 Amp current draw
The CSN-A2 printer fits all of my requirements. After looking at other products, I could not find any instances where another printer had any benefits over the CSN-A2.
6.4 Power Supply
I need a power supply of 5 Volts as that is the minimum voltage required to power the printer. I can use a voltage regulator for the 3.3 Volt devices. A power supply with peak current output of 2 Amps would be suitable for my needs. A wall-mount power supply that fit these specifications was the WSU050-2000, with a cost of $13.04 per unit. I found this transformer using the search function of the online store Digikey.
6.4 3.3V Voltage Regulator
Since my power supply is required to be 5 Volts, I need a voltage regulator to step down the voltage from 5 to 3.3 to power the microcontroller, LCD, and Wi-Fi module. I need a surface mount voltage regulator capable of supplying enough current for the microcontroller, LCD, and Wi-Fi module. Using Digikey’s search, I found the LM1117IDTX-3.3/NOPB voltage regulator from Texas Instruments. This regulator can supply up to 800mA, much more than I expect to be using. It has a cost of $1.96.
6.5 LCD
I will be using an LCD to display some information to the user, such as whether or not the device is connected to the internet. In our labs we used the NHD-0216HZ-FSW-FBW-33V3C LCD, and I have learned how to use its command set. This LCD runs at 3.3 Volts, and has a display of 16x2 characters. There are many devices like this one, as this 16x2 design is very common. Because of that, I will use the one I am familiar with.
6.6 Momentary Push Button
When they user wants to get the current weather, all they need to do is push a button. The kind of push button I was looking for was a momentary normally-open push button switch. There are many types of switches, and the specifications are not very important, so I based my decision almost entirely on aesthetics. I wanted a sleek illuminated button, so I decided upon a metal unit with an illuminated LED circle around the push button. The manufacturer number for the button I purchased is ZJ44803. The LED is rated for up to 12 Volts, and the switch contacts are rated for 5 Amps and 250 Volts AC.
6.7 Notification LED
The notification LED was another component where the main consideration was aesthetics and simplicity. The only requirements are that it operates at 3.3 Volts and is made to be mounted in a case. I decided upon the 5586003007F panel indicator light from Dialight. It is a simple blue LED with diameter of 3 mm.
6.8 Power Switch
The power switch is not a crucial component, so I decided to go with a black simple rocker switch. From Digikey I found a simple two terminal circular rocker switch, RR511D1121 manufactured by E-Switch.
6.9 Case
The case must be large enough to house all components. The printer and PCB take up the majority of the space for my project, so considerations were mainly based around those. I wanted a simple rectangular shape for the case, and my main decision was whether to choose a clear case, or a solid colour case.
After searching through cases on Digikey, I ended up choosing a rectangular case made of translucent blue polycarbonate, so that the user will be able to see everything inside the case. The dimensions available that best fit my requirements are shown below, where A, B, and C are 6.73”, 4.67”, and 3.15” respectively. These dimensions belong to product BT-2727 by Bud Industries. The image below was taken from the BT-2727 product page on Digikey.
Figure 5 - BT-2727 Enclosure
|