Give away medical masks when you place an order. learn more

Integrating Microchip's PIC24FJ192 MCU in a Multi-Node Wireless Weather Station


 

The embedded world in which we live is collectively developed from thousands of varying MCUs and CPUs. In support of the free flow of data and information, many are interconnected and often wireless. This data exchange offers a more convenient and potentially safer lifestyle. The Hotenda Weather Center illustrates how various MCUs can be connected for wireless communication to a handheld Smartphone. The Weather Center is a solar powered, multi-node project with a variety of MCUs and sensors wirelessly networked together. These networked nodes provide a snapshot of both the weather conditions and the solar panel array’s power output, which supplies the main weather center’s power bus.

The PIC24FJ192GA110 MCU implementation

The PIC24FJ192GA110 MCU was used as a weather node to return wireless readings of temperature, humidity, and Lux (luminous flux density) from each of the respective sensors. The node also monitors its own voltage through the use of a high resistance potential divider and voltage follower. These analog signals are read on a sixteen point average via the on-chip ADC. The human-machine interface uses change notification (CN) interrupts via hermetically sealed tactile pushbutton switches and an LCD screen to update the local user with current sensor data.

Operating on an average current draw of as little as 9.25 mA, the node was designed with low power and wireless connectivity in mind. Running at 57,600 Baud, the system uses the PIC’s UART2 port as a means of serial communication with an XBee Pro unit (XBP24-BWIT-004-ND) in pass-through mode. This allows plug-and-play connectivity as if the PIC’s UART port were physically connected on a hard line.

The majority of the time, the PIC MCU is actually sleeping in a low-power state. The system wakes and updates with one of two events; either user interaction through a button press or a system request from the gateway will force a system wake and update. If a button press event occurs, a change notification interrupt is triggered and the corresponding handler sets a flag used to change program flow and update weather data on the LCD screen. The LCD screen driver receives data via the parallel master port. This allows the user to select which reading is displayed. If the gateway asserts a request through a pin on the XBee Pro unit, the system wakes, reads in the input and transmits the appropriate data before returning to sleep. The program flow can be found below in Figure 1.

A V-Infinity 500 mA DC-DC converter (102-1709-ND) was used to efficiently match the supply voltage from the solar charged lead-acid battery to that of the PIC and the other node’s peripherals. This regulator allows for a 32 volt input and provides a low ripple output with up to 96 percent efficiency.

Figure 1: Program flow.


Peripherals, sensors, and hardware

The parallel master port was used to update a Newhaven Display (NHD-0208AZ-RN-YBW-3V-ND). This display was chosen due to its small footprint, compatible supply voltage, and availability.

For Lux sensing, a Microsemi Lux sensor (LX1971IDU-ND) was used due to its temperature stability and approximate human eye spectral response. This means the relationship between the sensor’s input (Lux) and output (voltage) results in a square root transfer function. This allows for a piece-wise conversion by use of a branch statement to determine if the output lies on the curved portion or the linear portion of the transfer function. Once the correct portion of the curve is found, the output is calculated. For daylight conditions, the majority of the output is linear. Therefore, a quick linear scaling is computed for most ambient light measurements.

For the humidity measurements, a Honeywell HIH-5031 humidity sensor (480-3284-1-ND) was employed. This sensor was chosen since it has a relative humidity operational range of 0 to 100 percent with a low hysteresis of +/- 3 percent. For better accuracy, variations in temperature and voltage can be compensated by taking temperature and supply voltage measurements into account. Both of these measurements are available and used for computing a more accurate humidity reading.

The temperature was measured using a Microchip (TC1047AVNBCT-ND) temperature sensor. This sensor operates off of a low, 35-µA supply current and exhibits a linear response, resulting in low processor computational load. As stated above, the temperature sensor is also used to compensate for changes in temperature when calculating the relative humidity.

The circuit for the PIC24FJ192GA110 weather node can be seen in Figures 2 and 3 below.


Figure 2: Sensors and switches circuit.



Figure 3: Power input and peripherals circuit.

Design challenges

While a high resistance potential divider reduced the amount of supply current bleed out (such as the one seen in Figure 3), it also caused an impedance mismatch going into the PIC’s ADC, resulting in inaccurate readings. The datasheet for the PIC recommends no more than 2.5 KΩ for the maximum input impedance from any voltage source to the ADC. The divider created an approximate output impedance of 388 KΩ. This impedance mismatch was accounted for by buffering the output of the divider with a Microchip high precision op amp (MCP6031T-E/OTTR-ND). This particular op amp was a good choice for this application due to its low cost and low quiescent current draw 0.9 µA. This proved to be a small contributor to the overall system’s power consumption.

Since the MCU would be sleeping most of the time, a two-speed startup, along with a pin change (RD1) interrupt triggered from the XBee, was needed to ensure immediate UART transmission to the XBee module upon request from the gateway. In two-speed startup mode, the MCU wakes from sleep-mode using the fast RC (FRC) oscillator, at 8 MHz +/-2 percent, with a typical startup time of 15 µs. This allows for a quick, low-power wake from sleep starting with the 8 MHz internal FRC oscillator and ultimately switching to the external crystal oscillator at 32 MHz once the PLL locks. The PLL itself can typically take up to 2 ms to lock.

A NEMA certified enclosure (377-1459-ND) and C&K sealed IP67 rated tactile pushbutton switches (CKN10004-ND) were used to prepare the unit for inclement weather. The C&K switches are single-pole, single-throw, normally open tactile switches. For the pin change notification interrupts, the pins are pulled high and de-bounced to ground through the use of shunt capacitors. This ensures that by avoiding the mechanical chatter inherent in tactile switches, a switch actuation will be read only one time. The hermetically sealed enclosure (lid removed) and board layout can be seen in Figure 5 below.

Figure 4: Hermetically sealed enclosure.

The Hotenda Weather Center showcases the ease of wirelessly connecting various components collectively as subsystems (or MCU nodes) in support of accomplishing a bigger task. Each subsystem handles a small supporting role in detecting changes in weather characteristics. This process translates well into many other applications where it would be important to have subsystems wirelessly communicating on a mesh network such as the 2.4 GHz ZigBee network employed by the Hotenda Weather Center.

All software and flow chart information can be found at www.eewiki.net.

For design assistance, please contact Hotenda’s Design Support Services at design@digikey.com.
Supplier