Introduction
I got to put a lot of time into the project this weekend, and I got some cool stuff done. I ... well, here are two pictures for you, and then the details.
|
Things glowing in the dark |
|
Lit by a desk lamp - I have to learn to take better pictures. |
Hardware fully assembled
I put all the hardware pieces together. In the picture above, you will see the Arduino stack at the top. You've seen this before.
The breadboard has two new peripherals. First, at bottom center is a 16-by-2 liquid crystal display that I found while looking for jumper wires in the
Sunfounder Project Super Starter Kit. This LCD can run with either a 4-bit or an 8-bit interface, plus 2 more digital pins for the RS and Enable signals.
Second, the little red guy on the right is the Hall Effect sensor. When installed, this will be on the other end of a ten-foot long cable, mounted to the lintel.
You will notice a potentiometer on the left side of the breadboard. That's to control the contrast of the display. This is absolutely necessary with an LCD display. In the final enclosure, I'll use a trim pot that can be adjusted with a jeweler's screwdriver, through a hole in the enclosure.
Arduino software (almost) complete
The Arduino program is almost fully fleshed out. It searches for a Wifi router / access point, connects to it, and displays the SSID (the router's name) and its own IP address. Internally it has a list of access points, and cycles through them until it makes a connection.
In case of power failure, the Arduino program restarts, and with any luck the ESP8266 will have saved the connection information from before the power failure. If not, it will take several minutes for the router(s) to reboot, so the ESP8266 will count down 10 minutes on the display and then try again.
Once it has a connection, it starts a TCP server and opens a socket on an out-of-the-way port, to listen for clients. Every ten minutes it pings the router to make sure the Wifi connection is still good.
That's where things stand right now.
When a client opens a connection to the server, well, that code is still in skeleton form. Before I can finish it, I have to write a client program in Python or C (or Corona!) to exercise the connection. That's one of the next steps.
The display
This was a bit of serendipity. I'd forgotten that Sunfounder kit came with an LCD. This is the standard 16x2 display based on the common ST7066/HD44780 parallel interface. This is a white-on-blue one with not very good contrast, so I'll buy a white-on-black or red-on-black one for the final product. I'd really like an old-fashioned, dot-matrix alphanumeric, 16x2 red LED display, but I haven't seen any of those for a while.
The display uses 4 digital pins for data, and one each for RS and Enable, so it fits within my pin budget.
Incorporating it into the code was a cinch, thanks to the Arduino
LiquidCrystal library.
Detour: Who (or what) is "Eorlingas"?
For those of you who already looked it up on the Web, congratulations. For those of you who didn't even have to look it up ('cause you already knew!), I offer you my deepest regards.
For years, every new computer, callphone and game system in our family has borne the name of a fictional horse. When high-speed Internet finally made it to our neighborhood (yes, children, some of us first got our Internet through the phone line - at 2400 bits per second!), we needed a good name for our router, and we chose Rohirrim, the formal name for the Riders of Rohan, from The Lord of the Rings. Since that time, we have worn out or obsoleted four routers, and we're on our fifth one. It's the Fifth Detachment of the Rohirrim, or FifthRohirrim.
The architecture of our house is such that the back rooms don't always receive a good signal from the router. I want the router to be hard-wired into our Xbox and our TV, so I can't move it. So, I installed a Wifi repeater in the back of the house. (By sheer coincidence, although I'd love to claim clever planning, this repeater is located about six feet above the garage door opener.) The repeater can't be named after a horse, since it's part of the infrastructure, not a computing device.
"Rohirrim" is an ancient Gondor word. The Rohirrim didn't use that word to identify themselves. In the ancient language of Rohan, they were descended from a king named Eorl, hence they were the Sons of Eorl — the Eorlingas.
I will claim clever planning for that one.
Back on the main road: the Hall effect sensor
I decided to try the
ACS712 dev board first, because it has built-in trim pots for Vref and gain. I only had to connect it to 5V, ground, and an analog input on the Arduino. I wasn't happy with its performance at first. The voltage level drifted all around. I finally got it to settle down, but I can't have it drifting like that in real life.
When I finally got it settled down, I used a refrigerator magnet to manipulate it. I got the Vref and gain pots adjusted so that it pegged at 0.0 V without the magnet, and at 5.0 V with the magnet touching the chip.
Some voltage level in the circuit is floating. I don't understand the circuit well enough to fix it yet. Maybe I need to put a load (you know, a resistor) between the two current input pins.
Other than that, the sensor just works without complaint or fuss. Clearly, I have more homework to do before I can use it in real life, but this weekend's results were promising.
It needs a case, an enclosure
I've been thinking about this for a while. I'm going to have to put the Arduino in a case.
All of the Arduino Uno R3 enclosures I've found so far are for just the Arduino Uno R3 board. Once you add a shield to your Arduino, it outgrows the enclosure.
A generic project box might be okay, but it can't be metal, because of the Wifi.
I thought of 3D printing one. I don't know SolidWorks, which I think is what everyone uses, so I'd have to learn SolidWorks. I looked for ready-made 3D printable designs, and the first one I found was, I'm really sorry to say this,
ugly.
Okay, I just looked again, and there are some
better-looking ones out there. None of them solve my height issue, but if I can get their source and manipulate it in SolidWorks or something, then I can take care of that myself.
I also need to include openings for: the LCD, the contrast adjustment for the LCD, and any LEDs I want to make visible.
I think that making the enclosure, and fitting everything in it, is going to be more work than the hardware and software parts of the project. Maybe I'll just use a cardboard box, an X-Acto knife, and clear packing tape. I'm only half-kidding.
The sensor needs an enclosure too
I can't just nail the Hall effect sensor to the beam in the garage. It will be exposed to a rather harsh environment. I may need to 3D print a case for it as well.
Alternatively, I could encapsulate it in potting compound. That would be just as good - but I'd have to find a way to include mounting holes. And whatever I do has to be nonmetallic, or at least nonmagnetic or nonferrous. Hmm. That will take more thinking.
What's next
I've made good progress so far. Here's what I still need to do
- Write a TCP client in Python or C, to exercise the server.
- Port that TCP client to an Android app, using Corona SDK.
- Finish the Arduino code:
- Hall effect sensor
- Debug the TCP client-handling code
- Finish the Android app as well.
- Get a real LCD display.
- Design and fabricate enclosures for the Arduino stack and the sensor.
- Assemble the whole thing.
Other items that come to mind:
- Try the breadboard design in the garage before I commit to a final design.
- Run Wireshark while the server is running, to see who tries to call my Arduino.
- Configure my router to allow passthrough only on the designated port, or from designated clients.
- Exercise the challenge-and-response algorithm.
- Document the whole thing.
To read the other postings about this project,
click here and scroll to the end.