This article focuses on the practical aspects of making inexpensive WiFi radio based on an OpenWrt router running a Stellaris microcontroller.
Purpose and justification of the choice of components
The main goal was to make a device for providing background music to the kitchen, with the most simple and intuitive interface usable home. Secondary goals :
fix broken radio
Attach a faulty router and a Stellaris debug board ordered in a shopogolism fit
evaluate the convenience of working with a Stellaris microcontroller
The choice of the remaining components of the scheme is not complete.
Housing
Usually this section is put at the end. But in my opinion. The topic is quite important, especially if the device is to be operated in aggressive environments (I mean the kitchen). Jeff made a plywood case. A good solution for those who want a normal sound and can bend plywood. In my performance, such a corpus would look too collectively, so I chose my old puzatenky tape recorder with a CD to play. The wide base of the CD player allows you to place the most overall structural element of the router board, the speakers provide the basis of the audio path, and the handle for carrying the necessary mobility. In addition, there is a chance to use the controls of the radio. ')
Interface
One of the factors hindering the use of new technologies is the need to change the user interface. Therefore, it was decided to stop at the simplest option: a large screen for displaying the station number, 2 buttons next / previous station, 2 buttons for volume control and a start / stop button for playing. For practical use of the device, it turned out to be important to remember the last set sound level and the selected station.
Design
A 4-year-old manual from the MightyOhm website was chosen as the basis. It is described in sufficient detail and I see no reason to reproduce it here entirely. I will focus only on the differences. When constructing a radio according to this scheme, there is a dilemma of separation of control between Linux and the microcontroller. I stopped at the option when most of the control logic is located on the MK due to dislike and the lack of a lot of Linux administration experience as well as the desire to play around with the MK. In addition, I am confused by the problem of having to repeat the setup procedure when flashing the router. Therefore, from the side of openvrt I added only
script start playing with the update playlist from the Internet
Stellaris is not your Arduin, only UART ports that work freely on the 115200 have 6 of them, which allows you to use two of them as a USB-UART adapter for PCs during debugging. The first task performed by the MK software is the forwarding of information between the UART1 connected to the router and the UART0, which can be connected to the PC. The second is the analysis of the passing information and the sending of events to the state machine including information on the change of the buttons state. The third is the implementation of a finite state machine with the analysis of incoming messages and changing information on display devices
After the start, the MC waits for the signal to finish loading the router, updates the playlist from the Internet (I use DropBox to store the playlist), restores the sound level and the station, and sends a command to start playing.
The proposed scheme and code are working, but they were created in pieces within six months, as a result, turned out to be quite muddled and valuable only as a working demo.
Manufacturing
The donor, an unknown miracle of the Chinese industry of the beginning of the century. From the old radio tape recorder removed all the equipment except the speakers and the board with buttons. You can try to save the audio amplifier and power if you have time and inspiration. Gut. After a corresponding revision of the hull, it is stuffed with new equipment: Stuffing Router fee (1) I got the famous Asus WL-500gP V2 , got for the beer due to problems on the WAN port, which did not affect the work as a WiFi host. Theoretically, the router should be suitable for anyone with the ability to install OpenWrt and a USB port. USB sound card (5) I ordered one like the one shown in the picture and it works, moreover, Asus Xonar U3 was successfully tested, but it didn’t give the expected improvement in sound quality. I suspect in connection with low bitrate and quality of the audio path. Another tested Chinese USB sound card, in a transparent case without buttons, refused to work, despite the fact that everything was fine on the PC, the reason is unknown. Audio amplifier (4) I ordered it on EBay on the principle of "sho cheaper." I cannot recommend it because of strong high-frequency noise, although the resistors connected in series with the speakers helped to reduce them to an acceptable level while maintaining a sufficient volume level. Display Devices When building a radio according to this scheme, it is enough to use a pair of LEDs to indicate the status or navigate through the LEDs of the router, but so that the MK resources do not idle, I ordered this OLED screen (3) . The screen is wonderful - compact and contrasting, but too small, especially if it is supposed to be operated by people with poor eyesight. Therefore, a seven-segment indicator with a controller (6) showing the most important information in my opinion - the number of the selected station was added to the design. Motherboard MK (2) , memory (7) and connectors to peripheral devices I connected on a breadboard. The reason for the choice of external memory was a message about the bug with flash memory in early versions of stellaris, which significantly reduces the number of rewrite cycles. Without a memory chip, you can do or use the internal MK flash, but this will require software refinement. Nutrition (8) The router requires 5v 2a, the amplifier 12v <1a, I ordered two separate power supplies. I suspect that there is a more accurate solution and will meet with pleasure in the comments. Control devices (buttons) The design of my car stereo made it possible to use my motherboard with buttons after appropriate modification. Hope you get lucky also. Is done
New 3.3V 0.96 "128X64 OLED LCD LED Display Module Shield white Color SSD1306
$ 8.74
four
10W Mini HIFI 12V Digital power amplifier Stereo High power amplifier Board
$ 4.99
five
USB2.0 To 3.5mm Audio Microphone Speaker Port Adapter 7.1 Channel 3D Sound Track
$ 2.08
6
0.56 "LED 7 Segment 4 Digit Common cathode MAX7219 arduino Blue White Green
$ 3.68
MAX7219
$ 0.45
7
AT25040A
~ $ 1
eight
Switch Power Supply Driver Strip Strip Light AC 110 / 220V 5V 2A 10W
$ 8.16
12V 1A 12W DC Switch Power Supply Driver
$ 4.99
Stellaris
Stellaris pleased with the wide possibilities and good documentation, but left the impression that the product is damp. As with the iron, which is probably due to the fact that I used the board from the pre-order, and from the software. At the same time, the community is not too large compared to the same arduin, which means that taking a step away from the examples proposed by TI, you find yourself in a minefield of riddles and bugs armed only with documentation and sources. So for example, it turns out that using UART above 2 requires making changes to the library code. PB7 and PD1 pins were shorted on my board, although this is probably a consequence of my not very correct experiments. It was not possible to get custom buttons and other not critical but annoying little things to work.
What remains unrealized:
Tighten the control through the IR remote control, the benefit of the pins and computing power of the MC is enough.
To start through the relay on the MK the power management of the router that will allow to realize the "sleep" mode and, if necessary, to reset the router.
Adjust NTP and display exact time.
Implement a timer to automatically turn off the radio after 4-5 hours of play
Add a hard drive with a collection of music and the ability to use it in the absence of the Internet.
Add the ability to use multiple playlists and a button to switch between them.
Replace the volume and station buttons with rotary switches from old mice.
findings
All set primary and secondary goals achieved. The successful experience of operating the device for several months proves the correctness of the chosen solutions.