Antoine de Chassey
Published

MKRFox1200 Weather Station

What if we built a small weather station lasting for about 6 months with 2x AA, talking to Internet and working anywhere with SIGFOX?

IntermediateFull instructions provided2 hours31,380
MKRFox1200 Weather Station

Things used in this project

Hardware components

Arduino MKR Fox 1200
Arduino MKR Fox 1200
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Male Jumper Wires
×4
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Resistor 10k ohm
Resistor 10k ohm
A 4.7k Ohm resistor could also be used.
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE
Sigfox
Sigfox
thethings.iO
A useful/simple platform to build a dashboard for our data

Story

Read more

Schematics

MKRFox1200 with DHT11

Schematics

Code

Cloud Code for sigfox_parser function

JavaScript
https://sigfox.thethings.io/#/
This code will manage the API calls and will let you access the recieved data in the dashboard widgets.
function main(params, callback) {
    var INT16_t_MAX = 32767;
    var UINT16_t_MAX = 65536;

    var moduleTemp = (params.custom.moduleTemp / INT16_t_MAX * 120).toFixed(2);
    var dhtTemp = (params.custom.dhtTemp / INT16_t_MAX * 120).toFixed(2); // the DHT temp
    var dhtHum = (params.custom.dhtHum / UINT16_t_MAX * 110).toFixed(2);

    var heatIndex = computeHeatIndex(dhtTemp, dhtHum, false).toFixed(2);;

    var result = [
        //Replace with your own payload parse
        {
            "key": "moduleTemp",
            "value": moduleTemp
        }, {
            "key": "dhtTemp",
            "value": dhtTemp
        }, {
            "key": "dhtHum",
            "value": dhtHum
        }, {
            "key": "heatIndex",
            "value": heatIndex
        }
    ]
    callback(null, result)
}

function computeHeatIndex(temperature, percentHumidity, isFahrenheit) {
    // Using both Rothfusz and Steadman's equations
    // http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
    var hi;

    if (!isFahrenheit)
        temperature = convertCtoF(temperature);

    hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094));

    if (hi > 79) {
        hi = -42.379 +
            2.04901523 * temperature +
            10.14333127 * percentHumidity +
            -0.22475541 * temperature * percentHumidity +
            -0.00683783 * pow(temperature, 2) +
            -0.05481717 * pow(percentHumidity, 2) +
            0.00122874 * pow(temperature, 2) * percentHumidity +
            0.00085282 * temperature * pow(percentHumidity, 2) +
            -0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2);

        if ((percentHumidity < 13) && (temperature >= 80.0) && (temperature <= 112.0))
            hi -= ((13.0 - percentHumidity) * 0.25) * sqrt((17.0 - abs(temperature - 95.0)) * 0.05882);

        else if ((percentHumidity > 85.0) && (temperature >= 80.0) && (temperature <= 87.0))
            hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2);
    }

    return isFahrenheit ? hi : convertFtoC(hi);
}

function convertFtoC(f) {
    return (f - 32) * 0.55555;
}

function convertCtoF(c) {
    return c * 1.8 + 32;
}

Arduino code

This code is to be flashed to the MKRFox1200. It will send DHT11 temperature and humidity data every 15 minutes over the Sigfox network.

Credits

Antoine de Chassey

Antoine de Chassey

0 projects • 27 followers
IoT maker @SIGFOX, hacking things
Thanks to Louis Moreau.

Comments