Refrigerator Monitor
Monitor refrigerator temperature, humidity, and power using a Notecard and a BME280 sensor.
You Will Need
- AC to USB adapter (power brick)
- USB A to micro USB cable
- LiPo battery with JST cable
- Notecarrier-A
- Notecard
- SparkFun Atmospheric Sensor Breakout - BME280 (Qwiic)
- Qwiic Cable
Hardware Setup
- Assemble Notecard and Notecarrier as described here.
- Keep the Notecard connected to the computer with the in-browser terminal active until you have completed Notecard Setup.
- Plug one end of the Qwiic cable into one of the Notecarrier Qwiic ports and the other end into one of the Qwiic ports on the BME280 breakout board.
- Connect the Notecarrier to your PC via the micro USB cable.
- (OPTIONAL) The BME280 breakout has an LED to indicate that its powered on. This draws a significant amount of current, especially compared to the sensor itself. To maximize battery life, you can disconnect this LED by cutting the JP1 jumper trace (see the schematic) on the back of the board with a hobby knife.
Cloud Setup
Sign up for a free account on Notehub.io and create a new project.
Notecard Setup
In these steps, you will use the in-browser terminal to configure your Notecard to report environmental data and power outage events to your Notehub project.
Firmware
The Notecard should use firmware version 3.5.1 or higher. The simplest way to update firmware is to do an over-the-air update.
Configure Notehub Project and Connection Mode
Set the ProductUID for the Notecard by pasting the command below into the in-browser terminal. Make sure to replace com.your-company:your-product-name
with the ProductUID from your Notehub project, which can be found below your project's name in the dashboard at https://notehub.io. Also, replace the placeholder serial number ("sn:" "fridge-location"
) with the location of your fridge (e.g. "kitchen").
{ "req": "hub.set", "mode": "periodic", "outbound": 3, "product": "com.your-company:your-product-name", "sn": "fridge-location", "body":{"app":"nf17"} }
This app uses periodic
mode to minimize power use so that the solution can remain online for longer when mains power fails. "outbound": 3
is the max wait time, in minutes, to sync outbound data from the Notecard. For more details, see our Essential Requests documentation for hub.set
.
Configure Periodic Environmental Measurements
Paste this command into the in-browser terminal:
{ "req": "card.aux", "mode":"track" }
Turning on track mode will augment the environmental data with pressure and humidity readings in addition to temperature.
Next, paste this command into the in-browser terminal:
{ "req": "card.temp", "minutes": 3 }
This will cause the Notecard to push a note to the _temp.qo
Notefile with environmental data every 3 minutes. You can modify this interval to suit your application's needs. Note that this matches the 3 minute settings we specified for outbound
in the hub.set
request above.
Configure Power Outage Alerts
Paste this command into the in-browser terminal:
{ "req": "card.voltage", "mode": "lipo", "usb": true, "alert": true, "sync": true }
This instructs the Notecard to assume LiPo battery characteristics, monitor USB power and send an alert immediately when a power outage occurs and when power is restored. For more details, see the Notecard API reference and the Enable USB Power Alerting
example.
Notecard CLI
If you want to issue all of the above requests in one shot, you can do so with the Notecard CLI and the config.json configuration script. You will need to change the ProductUID in the hub.set
command to match your ProductUID. Once you've done that, you can configure the Notecard with:
notecard -setup config.json
System Test
Ideally, to test this application, you'd put your Notecarrier, Notecard, and sensor into a refrigerator. However, if you're just prototyping this at home, it's unlikely you're going to have access to mains power inside your fridge. So, feel free to follow these steps anywhere near an outlet where you can connect to power. You'll verify that you're receiving temperature and humidity data on Notehub, and you'll also test the backup battery functionality.
Setup
- Insert the power brick into a suitable electrical outlet and provide power to the Notecarrier via the micro USB cable.
- Plug the JST connector from the LiPo battery into the port labeled LIPO on the Notecarrier.
- Wait for the Notecard to connect to the cloud. When connected, there will be a new session event in Notehub. (look for recent
_session.qo
events.) - Wait for the battery to fully charge.
Viewing Environmental Data
Open your project on Notehub and navigate to the Events page using the menu on the left hand side. You should see periodic _temp.qo
notes like this:
{"count":13,"humidity":32.806084,"pressure":100820.59,"temperature":21.802795,"voltage":5.1367188}
Simulating a Power Outage
- Remove the power brick from the electrical outlet to simulate a power outage. The Notecard is now being powered by the battery.
- After a short time, you will see a
_health.qo
event in Notehub with the body
{"text":"USB power OFF {usb-disabled}"}
This event indicates that the Notecard is no longer powered from the power brick.
- Reinsert the power brick into a suitable electrical outlet to simulate power being restored.
- After a short time, you will see a
_health.qo
event in Notehub with the body
{"text":"USB power ON {usb-enabled}"}
This event indicates that the Notecard is again powered by the power brick.
Blues Community
We’d love to hear about you and your project on the Blues Community Forum!