Designing a Smart Mailbox with Solar Energy Harvesting Function Based on MSP430 Microcontroller (Part 2)
By Michael Parks, PE Mouser Electronics
In the first and second parts, we introduced the basic structure and BOM list of this solution. Now we will introduce the specific implementation of the solution.
The Solar EH Development Board provides control circuitry so that when there is enough sunlight, the solar panel will power the MSP430 microcontroller. The Cymbet EnerChip batteries in the TI Solar Kit have very low self-discharge rates, which makes them ideal for EH applications. Once the light drops below the appropriate level, the Solar Panel Kit automatically begins to replace the EnerChip battery to provide power to the MSP430. This is a very convenient integrated feature that will provide enough energy for about 400 RF triggered communications before the battery is exhausted. By adjusting the time interval between communication pulses, you will get a lot of use out of this development board without sufficient sunlight. This feature is extremely important in many remote sensing applications.
Programming the MSP430 is fairly easy to get started with if you have experience with other microcontroller platforms. The MCU located indoors, the LaunchPad development kit (MSP-EXP430FR5969), comes with a CD containing source code and applications. However, you will need to make sure you install the latest version of TI's integrated development environment (IDE), Code Composer Studio (the latest version at the time of this writing is 6.0.1). If you have used a relatively simple IDE before, such as the official Arduino IDE, don't be intimidated by this more complex IDE. The tutorial that comes with the eZ430-RF2500 is well organized and contains everything you need to know to tweak the pre-installed firmware. If you want to upload new firmware, you will need to use the included USB debugging dongle. It is important to remember which MSP430 is the remote node (outside the solar panel) and which one contains the hub firmware (located indoors in the LaunchPad kit, controlling the servo motors that set up the physical sign).
Figure 4: Without hardware, there is no software. This schematic shows the MSP430 LaunchPad connected to the servo motor and the switch circuit that resets the physical flag after the mail has been retrieved from the outside.
We will be making minimal adjustments to the pre-installed default firmware in the remote node MSP430. Specifically, we are adjusting the code snippet that reads the battery voltage so that it can read the voltage on an external analog input pin, in our case, analog pin A0. Recalling the BOM list from earlier, the solar kit comes with its own solar panel, an MSP430 MCU (the "remote node"), and two wireless EZ430-RF2500T target boards. The smaller eZ430-RF2500T board sends and receives signals to notify the MSP430 inside the mailbox that the mailbox has been exposed to a light source.
Figure 5: The eZ430-RF USB debug interface and the EZ430-RF2500T wireless target board that includes the CC2500 low-power 2.4 GHz RF transceiver.
The pinout for the EZ430-RF2500T target board shows that A0 on the remote node MSP430 is connected directly to pin 3 on the eZ430-RF2500T target board. This is an external pin that we soldered to a male header for easy access. If you look at the firmware installed on the remote node MSP430 module, the image below shows that we are modifying this line of code:
Figure 6: Reusing the demo code installed on the RF2500-SEH MSP430 board, the above lines of code were adjusted using Code Composer Studio. The modified firmware was then uploaded to the EZ430-RF2500T via the USB dongle.
After saving the changes, we can upload the new node firmware to the remote MSP430 through the Hardware Programming Tool USB dongle, which is used to manage the solar harvesting panel (physically located at the panel outside the mailbox). Then, in simple terms, it connects the ambient light sensor (see Figure 3) and connects the MSP430 target board to the EH board (see Figure 4). Remove jumper JP8 and the solar panel starts charging the main board. Verify that the onboard LED on the MSP430 remote node starts blinking when you connect it to the solar panel (Cymbet). One thing to note is that if you power off the project and store the EH Cymbet main board, be sure to replace jumper J8 before storing the EH main board.
At this point, if you plan to use the device permanently, be careful to use a waterproof enclosure and use heat shrink tubing and a sealant (maybe something like sugru) to seal the enclosure to keep the external wiring tidy. When mounting this device to a mailbox, if you live in the northern hemisphere, remember that the solar panel is ideally facing south to maximize sun exposure throughout the year.
Indoor assembly part
The indoor portion of our email delivery notification system will require the use of a Windows computer. If you cannot get a computer for this remote project, you can use only the microcontroller for the entire EH project, but using a computer will allow you to add new features to the project, such as running Python scripts to send emails when the status changes.
The indoor part includes the aforementioned Windows computer, which will run the Processing sketch and will be responsible for interfacing two external devices with the computer:
1. Indoor MSP430 running the hub firmware and connected to the computer via a USB debugging hardware "dongle".
2. TI LaunchPad experimental development board, controlling the servo motor to raise the physical sign in the room.
We will use the open source tool Processing to develop our desktop application in a program called "sketch." We chose Processing because there are few development environments that make it easy to handle serial communications and create basic user interfaces (UIs) when you are in the prototyping stage.
To summarize the indoor hardware setup in more detail, the MSP430 module running the hub firmware is connected to the computer via a USB debugging hardware dongle. The debugger will appear as a COM port on the computer. Remember the specific COM port number, we will use this information in the subsequent Processing sketch.
The other piece of hardware connected to the computer is the TI LaunchPad. With it, we can interact with the servo motor to raise the physical sign to let the user know that the email has been delivered. We also added a button that the user can use to reset the system (and lower the sign via the servo motor) after they go away and get the email. As with all digital I/O, don't forget to add pull-up or pull-down resistors to prevent floating input ports, otherwise, it can make your application unreliable at best and your system completely unusable at worst.
The pseudocode for our Processing sketch is as follows:
1. Read serial packets from the COM port of the EZ430-RF2500T board while it is connected to the USB debugger.
2. Parse the data packets, ignore the hub data packets, and only listen to the remote node data packets.
3. Parse the remote node data packet to find the voltage reading in the ADC.
4. If the voltage reading is less than 4.5V, assume that mail is being delivered.
5. Send a serial packet to the LaunchPad to let it know the message has been delivered and raise the flag.
The LaunchPad that controls the servo will be programmed using the Energia IDE rather than the previous Code Composer Studio. This IDE looks very similar to the Processing IDE and it is easy to switch between the two and it is also easier to troubleshoot communication errors. The firmware will wait for a specific keyword to be received from the computer; in this case, the symbol will be a string with the value "MAIL". Once the keyword is received, the servo will be driven to rotate 90 degrees, raising the sign. We can use the servo library provided by the Energia website to simplify driving the servo by abstracting the code required to do the PWM duty cycle calculations; it reduces the servo interaction to a simple function call. In addition, we need a function to handle the reset button connected to one of the LaunchPad's digital I/O pins. In this example, this function will drive the servo to lower the sign and allow the system to listen to the "MAIL" sign from the serial port again.
in conclusion
There are a plethora of microcontroller platforms (and software tools) out there, and a great way to get started is with a Texas Instruments (TI) LaunchPad development board. The MSP430 has extremely low power requirements, making it an ideal choice for energy-harvesting applications where power efficiency is critical. Whether you are an experienced engineer or a hobbyist, learning different platforms is a valuable skill. Exposure to a variety of platforms gives engineers greater flexibility and the ability to consider all possible solutions to a particular problem. In this example, we use a TI MSP430 microcontroller as a potential solution for a remote email delivery notification system. How would you modify it to meet your needs? Or would you re-adapt the design to handle an entirely different application?
About the Author
Michael Parks, PE is the owner of Green Shoe Garage, a custom electronics design studio and technology consulting firm located in Southern Maryland, and a podcaster promoting public awareness of technology. Michael is a professional engineer and has a master's degree in systems engineering from Johns Hopkins University.
Mouser Electronics WeChat account spreads technical information. All articles published are exclusive original articles. Please indicate the following information when reprinting:
Source: Mouser Electronics Official Account
WeChat ID: mouserelectronics
We reserve the right to pursue legal liability for any unauthorized copying or non-compliant reproduction.