06/20/2014 at 23:38 •
The schematic for the sender is fairly simply, because the part count is low to reduce cost.
Noteworthy aspects include:
* The digital input is a general trigger to send data. That particular pin can also wake the ATtiny from a deep sleep (very low power mode). An optional pushbutton (SW1) is useful to manually send the data when debugging.
* Notice how the pins are reused for connecting to the transmitter, USB serial cable, and ISP6 Atmel programmer.
* The sender asserts high/low during transmission, but switches the TX pin to an input when idle. R3 gently pulls down the TX line to keep the transmitter board turned off. However, the USB serial cable connector (not shown) uses a 10 kilohm resistor to bring the signal back to serial idle standards (high). A simple trick to be compatible with both cases.
* The reverse battery protection diode (D1) has an ultra-low dropout. It is less than 0.1 V at LoFi's voltage and current draw: http://www.nxp.com/documents/data_sheet/PMEG1030EH_EJ.pdf
06/21/2014 at 01:35 •
In order to support multiple senders on the same frequency (433 MHz), they must cooperate with each other by keeping their transmitters turned off except when they need to send a message. Therefore, most of the time, all of the transmitters are turned off.
When all of the transmitters are turned off, this is what the listener hears:
Have you ever tuned your radio to a frequency that doesn't have a station broadcasting on it? What do you hear? Silence? Nope. Static!
The listener is hearing static most of the time. How is it supposed to differentiate between noise and signal? Certainly a checksum in the data helps, but if the receive port starts reading a couple of bits too early (because the static looked like the start of a byte), then the entire message will be lost because the listener bit stream is out of phase with the sender bit stream.
Some people send a series of letter 'U' characters (repeating bit pattern) and hope that the listener syncs up. However, a better choice is to fully enable the transmitter for at least 10 bits (1 start + 8 data + 1 stop). This provides the following benefits:
- The listener can differentiate a long high period from static, since static often has low bits
- The first low bit after the long high signal is a serial start bit, thus synchronizing the bit streams
- The listener doesn't need to throw away any bytes (like 'U')
* Most importantly, the receiver hardware turns down the auto-gain (volume), just like you would turn down the volume when you hit a loud station. Thus, the static is quieted.
The above oscilloscope trace comes directly from the receiver hardware -- not the microcontroller. Look how clean the data signal is. This demonstrates that the $1 eBay 433 MHz transmitter/receiver is actually quite capable.
An interesting phenomenon of the receiver hardware auto-gain is that static is not heard by the listener for some time even after the transmitter has turned off again (see below). But, eventually it creeps back as the receiver turns up the volume again to hear fainter messages.
Fortunately, you don't have to worry about any of this, as LoFi is preprogrammed to handle it. You just need to find fascinating things in your house to wire up!
06/21/2014 at 22:59 •
LoFi uses Hamming error-correcting codes to detect and correct transmission errors. I've chosen a version that is not the most data efficient, but is a reasonable compromise because:
- The cost of the microcontroller increases with the amount of program space
- The power usage of the microcontroller increases with its speed. So, I chosen to run the ATtiny at only 1 MHz
- The computational requirements increase as the checksum code is applied to larger number of bits
I was surprised on how poorly the textbook code performed on an Atmel AVR processor. I wrote a new implementation that reduced it to 55 bytes of program space and a faster run time.
The resulting library is available in the links section.
There is more information about Hamming codes and this implementation, if you are interested:
06/23/2014 at 22:06 •
When all of the transmitters are quiet, the receiver is listening to static on AM 433 MHz (see earlier log post). To avoid interpreting static as valid serial data, LoFi requires a message to start with 10 high bits followed by the letter ‘L’.
Is there a more unlikely-to-randomly-occur value to start a message?
I told LoFi to report all starting bytes 'acceptably' received from dead air for an hour. It produced 4224 samples or about one every second. There were quiet periods and noisy periods. Here is the frequency histogram:
One byte per second is not bad, but it should be less often. Oh! There is a bug in the test program where it records additional bytes after the first.
Before I rerun the tests, let's take a closer look at the distinct values. The lack of bytes with the most-significant bit smells fishy. 0x55 (0b01010101) is the most popular value by far, either because:
- The receiver is oscillating (probably)
- Unrelated transmitters use that as a sync byte and LoFi is picking up that traffic (maybe)
- Or aliens are trying to contact Hack-A-Day readers (plausible)
Another possibility is electrical noise from nearby equipment. I disconnected LoFi from the Atmel STK500 programming board and sampled again for an hour.
This time, only 36 errant bytes appeared in an hour. Excellent! They all are 0x55, so 'L' (0x4C) is a perfectly fine start for each message. Excellent!
This leads me to two conclusions:
- Always check your test code
- Disconnect from potential sources of electrical noise, such as your programming board
06/26/2014 at 03:04 •
Summary: Delivery Tester indicates LoFi works well through walls and across the house
I built a simple test harness in C# .NET that visually displays the success or failure of receiving messages using LoFi on the 433 MHz band. The transmitter is running at 3 volts and is located approximately 75 feet away and down a floor. Each message is 21 bytes in length: 6 byte header, 8 byte message (five analog pins, a digital pin, voltage reference, and internal temperature), and 7 intermingled bytes of Hamming error correction.
As you can see, most of the messages were delivered successfully (green squares). Those that aren't (blank spots) would be covered by retries or could be ignored if they are highly redundant status updates -- such as for water level or temperature monitoring. Hamming code fixed 11 bit errors. Six bit errors were not corrected and caused some of the bad messages.
The bad messages generally occur in bursts, usually due to RF interference such as electrical noise or another 433 MHz device. However, as you'll see in the video, the errors towards the end are caused by operator rough handling. So, the actual delivery percentage is much higher.
Live action video: http://youtu.be/lA8NtvYP6GI
06/29/2014 at 20:49 •
Power usage depends on the current of any sensors that you add, as well as how often you configure LoFi to check sensors and transmit. Transmitting consumes approximately 15 mA. Not transmitting, but constantly checking the sensors, consumes about 0.5 mA.
A more likely scenario for battery operation is where LoFi transmits sensor data periodically or is activated by a trigger switch, say every 10 minutes. In that case, LoFi sleeps most of the time. As you will see, this allows for extremely long battery life.
This weekend, I coded and tested the sleep mode. LoFi uses the ATtiny watchdog to wake every 1/4 of a second to check whether it is time for a periodic transmission. It also examines the receive pin to see if someone is trying to configure the device. The digital trigger input (which can be connected to vibration or door switches) does not require polling. Instead, it will wake the device immediately.
On the oscilloscope trace below, you can see LoFi wakes up briefly (narrow vertical spikes) before falling back to sleep. Each spike takes about 4.3 ms (oscillator start up + computations). Then, the transmit time occurs and LoFi takes about 200 ms to read the sensors and transmit the data.
If a transmission occurred every 10 minutes, here is the average current draw:
Only 18.5 microamps – thank you Atmel! Plug that into some common batteries:
So, theoretically, you could run LoFi from a coin cell for a year. If you add a diode, capacitor, and small solar panel, then the life of the coin cell could be extended, as it would act as a backup at night. Realistically, with a pair of AA cells, you could forget about it for many, many years.
Best of all, since LoFi includes the power supply voltage in the sensor data, you’ll know when it is time to change the batteries.
07/14/2014 at 01:22 •
An example usage of LoFi is to monitor when the garage door opens and closes, as well as when the garage's interior light has been left on.
LoFi is designed to perform such tasks with minimal added parts and no programming. However, Ralph Doncaster (Nerd Ralph) http://nerdralph.blogspot.com/ commented that LoFi should be able to run on a coin cell. So, this is a good opportunity to experiment with that as well.
Ralph pointed me to a study demonstrating that a bulk capacitor extends the life of a coin cell by supply current during peak demand of low-duty-cycle devices. I also added a Schottky diode to prevent the battery from being charged when the LoFi board is attached to a computer. I almost learned that lesson the hard way when a nasty smell spewed from one of my NiMh battery packs. An improved board has already been designed to include the coin coil and diode, as well as a capacitor connector.
A simple cadmium sulfide photoresistor cell detects the brightness of the garage, not only to determine if someone has left the light on, but also as a potential non-mechanical means of detecting a change in the door state. Primarily, the garage door position is detected by a tilt ball switch.
Given that LoFi should cost less than $5, it only makes sense to use an equally expensive case. LoFi fits well in a Tic Tac box. The container is mounted to the garage door with Velcro hook and loop fasteners.
I quickly discovered a problem with my steel garage door: it blocked the transmitter signal (L shaped house). The challenge was overcome by repositioning LoFi to the top of the garage door, such that the antenna stuck out above the top panel.
All in all, this experiment is a success. LoFi correctly detects a change in garage door state, as well as delivers periodic updates on the door position, light level, temperature, and battery voltage.
07/20/2014 at 03:13 •
In the previous logs, I've shown LoFi in the remote corner of the basement and in the garage. Now, LoFi ventures outside to the garden to measure temperature and light levels.
A 'My M&M' silver favor candy tin (intended for weddings or parties) is the perfect size container for LoFi, the AM transmitter, a solar panel, coin cell (underneath the PCB), and various sensors. A clear lid permits light but blocks bugs, dirt, and hopefully rain. The transmitter antenna wire sneaks out the side through a #54 drill hole.
A foam liner was added to the candy tin to avoid electrical shorts. Even though the container has a non-conductive coating to avoid contaminating the candy, I've been burned by scratched or worn areas in the past.
When there is adequate sunlight, the solar panel powers the device. This solar panel was chosen because it fits so well, and provides the maximum voltage with good current. At full sunlight, the panel likely exceeds the ATtiny 5.5 V operating limit, but will stay under the absolute maximum of 6 V and has some voltage dropped by a Schottky reverse-protection diode.
The ATtiny internal temperature sensor and voltage reference are 'no-cost' inputs. An added photocell provides brightness data, and was selected to be sensitive to conditions after the solar panel yielded to the backup battery.
With wireless, it is nice to get immediate readings rather than logging to a flash as I have had to do in past experiments: http://www.robotroom.com/Weather-Station.html
This was not my first choice of locations for LoFi, but I discovered that a spot of land was already claimed by a toad in a hole.
09/02/2014 at 05:01 •
I’m experimenting with some novel enclosures for various installations of LoFi around the house and yard. I need to make an impact for the stage 3 judging.
I ordered some more m&m’s candy tins, because they are an excellent size and have a clear top window. When you buy them, you can customize the candy pieces with logos and writing. So, I used the Hackaday Prize logo.
LOFI in an IPHONE CHARGER
I appreciate the industrial design talent at Apple. Here is LoFi inside of a standard Apple power adapter, which is approximately 1 inch cubed (25 mm). In the USB slot, a small panel holds a light sensor, an ice cube LED, and the antenna. Yes, it really works.
The main board holds the CR2032 coin cell and has a standard 0.1 inch header for the transmitter and accessories. There is enough room leftover in the center for additional sensors.
LoFi runs for over a year on a single coin cell. Although I usually use a plastic holder, metal holders are cheaper and use less space. I designed a LoFi board with pads on the back for the ground terminal of the cell, and then bent the metal holder tabs around to the front of the board to attach the positive terminal.
Unfortunately, I made a mistake. Upon inserting the coin cell, nothing happened! I checked my connections, looked for shorts, and even wrongly suspected the new ultra low dropout diode.
The problem turned out to be my failure to account for the height of the solder mask. You see, the solder mask goes on top of the copper layer, and thus is slightly higher. The back of the coin cell was resting on the solder mask and not making contact with the pads on the back of the board. Applying a thin layer of solder to the pads raised it up enough to make contact.
LOFI in a TUBE
I have a really interesting application where LoFi needs to fit inside of a 1-inch circular tube, rather than 1-inch square. The tube was machined from a green medical grade Delrin/acetal block.
As you can see, LoFi managed to squeeze inside. A blue lens is machined to fit on top.
To make LoFi fit in the smaller space, I needed to insert a longer header in the front of the transmitter and bend it back 180 degrees (see red arrow below). However, this would not be necessary in a production device, as you'd use a smaller connector. Anyway, bending the connector allows the socket to overlap the bottom of the board and close the gap (blue arrow). There is enough room in the tube to fit a helical antenna – with the accompanying reduction in range, of course.
LoFi can now fit into a standard prescription pill bottle. A vibration sensor (added after the photos were taken) detects when someone is opening the bottle. The light sensor with the blue filter detects a significant change in brightness compared to when it was within the orange bottle.
From this prototype, I determined that a pushbutton switch recessed in the side of the tube would be superior, as it would detect that the cap had been removed (rather than the bottle just shaken) and it would work in darkness.
09/14/2014 at 21:11 •
A requirement of TheHackadayPrize Semifinals is to post concept art for the productized look and feel of the project.
The initial release of LoFi is primarily aimed at the hacker and electronic enthusiast community. Therefore, the first official product would likely be a starter kit.
The starter kit would include all of the parts needed to set up an entire system. A reduced starter kit could drop the AC adapter and WiFi board, for customers that only want to connect to a PC. A deluxe starter kit could include a variety sensors and a precision calibration board.
Some people prefer to avoid handling the electronics or providing their own cases (even if only fished from the recycling bin). For those customers, an injection molded case prepopulated with light and tilt sensors would be preferable.
The produce would take three AAA batteries to provide a long lifespan. A less expensive edition might exclude the spare pins and programming port.
TINY TURN-KEY PRODUCT
As you can see in an earlier post, LoFi fits nicely in space spaces and can operate only a single coin cell. However, it can be tedious hand-wiring a small device. Therefore, it would be awesome for someone to manufacturer LoFi in a coin-cell sized case.
This would allow anyone to use LoFi in small spaces.