Browse our open source example apps to accelerate your wireless IoT project.

Blues Developers
What’s New
Resources
Blog
Technical articles for developers
Newsletter
The monthly Blues developer newsletter
Terminal
Connect to a Notecard in your browser
Developer Certification
Get certified on wireless connectivity with Blues
Webinars
Listing of Blues technical webinars
Blues.comNotehub.io
Shop
Docs
Button IconHelp
Notehub StatusVisit our Forum
Button IconSign In
Sign In
Sign In
What’s New
Resources
Blog
Technical articles for developers
Newsletter
The monthly Blues developer newsletter
Terminal
Connect to a Notecard in your browser
Developer Certification
Get certified on wireless connectivity with Blues
Webinars
Listing of Blues technical webinars
Blues.comNotehub.io
Shop
Docs
homechevron_rightExample Appschevron_rightAcceleratorschevron_rightTemperature and Smoke Detector

Temperature and Smoke Detector

  • Arduino Firmware
  • LoRa
  • Soldering Required
  • Swan
  • Wiring Required

Temperature monitoring and smoke detection across a number of rooms at a facility.

You Will Need

  • Notecard Lora
  • LoRaWAN Gateway
  • Notecarrier F
  • Swan
  • 2 USB A to micro USB cables
  • MQ2 Gas and Smoke Sensor
  • 3.3-to-5v voltage converter
  • SparkFun Atmospheric Sensor Breakout - BME280
  • Soldering Iron
  • 2 USB A to micro USB cables
  • male-to-female jumper wires
  • female-to-female jumper wires
  • 0.1" Header Pins

Notehub Setup

Sign up for a free account on notehub.io and create a new project.

LoRa Gateway Setup

Before you can use the Notecard LoRa you need to have a LoRaWAN gateway that is provisioned to The Things Network. To make this easy you can use the Blues Indoor LoRaWAN Gateway . To get this set up follow the setup instructions

Swan Setup

First connect your Blues Swan and Notecard to your Notecarrier F.

  1. Follow the steps in the Notecard Quickstart to connect your Notecard LoRa to your Notecarrier F. Your antenna will only have one cable, and the Notecard LoRa only has one connection.

  2. Plug your Swan into the Feather headers on the Notecarrier F.

  3. Attach the Swan to your computer with a Micro USB to USB-A cable, using the Micro USB port on the Swan.

Notecard LoRa in Notecarrier F with antenna

MQ2 Sensor Connection

This solution makes use of the an MQ2 sensor module, which detects smoke, as well as various gasses. Using the jumper wires, connect the MQ2 sensor to the Notecarrier F board and the v5 converter as follows:

  1. Solder a set of header pins onto the 5v converter.
  2. Connetor a jumper to GND pad on the 5v converter and the other end to a GND pin on the Notecarrier F.
  3. Connect a jumper to GND on the sensor and the other end to a GND pin on the Notecarrier F.
  4. Connect a jumper to Vi on the converter and the other end to F_3V3 on the Notecarrier F.
  5. Connect a jumper to Vo on the converter and the other end to the VCC pin on the MQ2 sensor.
  6. Connect a jumper to A0 on the sensor and the other end to the F_A0 pin on the Notecarrier F.
  7. The 4th pin on the sensor is left unconnected.

Temperature Sensor Connection

This solution makes use of the BME280 sensor board, which measures temperature and humidity. Connect the BME280 sensor to the Swan board using the Qwiic cable:

  1. Insert one end of the Qwiic cable into the port labelled Qwiic on the Swan board
  2. Insert the other end of the Qwiic cable into either of the Qwiic sockets on the BME280 sensor board.

Notecarrier connected to BME280 breakout board with Qwiic cable Note I have the Adafruit version of the sensor rather then the Sparkfun one. They are the same except the LED cannot be disabled on the Adafruit version

With the Swan board powered on, you will see a red LED light up on the BME280 board, indicating that it is receiving power. To improve battery life, you may wish to cut the LED jumper to disable the LED. For more details, see the "LED Jumper" section in the Sparkfun Qwiic Atmospheric Sensor (BME280) Hookup Guide .

Firmware

The firmware provided uses the Arduino Framework, follow the instructions in the git repo to flash your Swan.

Temperature Monitoring and Smoke Alerting Behavior

The firmware periodically monitors temperature and gas concentrations, and posts events with this information. Regular monitoring events are not synced immediately to Notehub, and will be delivered as often as the Notecard is configured to sync with Notehub via the hub.set request. You can configure this value with the MQ2_SYNC_PERIOD defined in the file ./firmware/main.cpp

Temperature and Gas measurements are posted to the Notefile mq2.qo. An event has these properties:

{
  "app" : "nf31",       // the application name
  "gas": 6319,            // Gas/Smoke level (analog input value out of 65535)
  "humidity" : 60.21875,    // ambient humidity (in percent)
  "pressure" : 97019.08,  // ambient pressure (in pascals)
  "temperature" : 24.859375 // ambient temperature (in °C)
}

Each reading taken is checked against the configured thresholds. If any reading is higher than the corresponding threshold, the event is sent immediately to Notehub as an alert. Alerts are distinguished from regular monitoring events by the alert property.

{
  "alert" : 1,          // Signifies an alert
  "app" : "nf31",       // the application name
  "gas": 43277,            // Gas/Smoke level (analog input value out of 65535)
  "humidity" : 60.21875,    // ambient humidity (in percent)
  "pressure" : 97019.08,  // ambient pressure (in pascals)
  "temperature" : 24.859375 // ambient temperature (in °C)
}

The alert property has these values:

  • alert:1: Indicates an alert condition regarding temperature or presence of smoke or gas has been detected. The event is immediately synced to Notehub. You can use this to signal an alert externally, such as notifying a pager other messaging service.

  • alert:2: Signifies that the alert is still ongoing. Subsequent alerts after the initial alert have the alert property set to 2, indicating that the alert is ongoing because temperature or gas levels haven't returned to normal. These events are not immediately sent to notehub, and are provided for continuous monitoring.

  • alert:3: Signifies a stand-down alert and that temperature and gas levels have returned to normal. These events are sent immediately to notehub. This is typically used to send an external notification that normal temperature and gas levels have been reached.

When temperature and gas levels return to normal, alert:3 is the last event sent with the alert property present. Subsequent events do not have the alert property present until a new alert condition is detected.

Configuration

The file ./firmware/main.cpp contains a number of #defines that are used to configure how often temperature and gas levels are measured and the thresholds that trigger an alert:

NameDefaultUnitDescription
MQ2_SYNC_PERIOD60minutesThe period in minutes for the notecard to sync regular events.
MQ2_MONITOR_PERIOD60secondsThe period in seconds between each sensor reading.
ALERTS_ONLYfalsebooleanWhen true, disables reporting of regular monitoring events and only alerts are sent.
SYNC_ALL_NOTESfalsebooleanWhen true, forces immediate reporting of regular monitoring events. Useful for debugging.
ALERT_TEMPERATURE50.0CTrigger an alert when the temperature is at least this high. Set to 0 to disable temperature alerts.
ALERT_GAS_LEVEL400001-65535Trigger an alert when the measured gas level is at least this high. Set to 0 to disable gas level alerts.

Calibrating the Gas Sensor

The MQ2 sensor indicates the the gas level detected by way of the the voltage produced on the A0 analog output - a higher voltage means more gas or smoke was detected. The absolute value of this voltage is not calibrated. Additionally, some sensors feature a potentiometer to adjust the sensitivity, which further changes the range of voltages the sensor outputs.

In order to determine the range of values you should test the solution in clean air, and, if possible, in a smokey environment in order to determine a suitable value for ALERT_GAS_LEVEL.

Blues Community

We’d love to hear about you and your project on the Blues Community Forum !

Additional Resources

  • MQ2 Datasheet

On This Page

  • You Will Need
  • Notehub Setup
  • LoRa Gateway Setup
  • Swan Setup
    • MQ2 Sensor Connection
    • Temperature Sensor Connection
  • Firmware
  • Temperature Monitoring and Smoke Alerting Behavior
    • Configuration
    • Calibrating the Gas Sensor
  • Blues Community
  • Additional Resources

Resources

  • GitHub
  • Request More Info
© 2025 Blues Inc.
© 2025 Blues Inc.
TermsPrivacy
Notecard Disconnected
Having trouble connecting?

Try changing your USB cable as some cables do not support transferring data. If that does not solve your problem, contact us at support@blues.com and we will get you set up with another tool to communicate with the Notecard.

Advanced Usage

The help command gives more info.

Connect a Notecard
Use USB to connect and start issuing requests from the browser.
Try Notecard Simulator
Experiment with Notecard's latest firmware on a Simulator assigned to your free Notehub account.

Don't have an account? Sign up