Author Topic: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station  (Read 23474 times)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
When I started working on my own indoor/outdoor weather station I first thought I would use a PI for the internal gateway between the Moteino and the Internet.  Having worked a lot with the Spark Core (and my Photon just arrived) I thought I would use it instead.  I looked around and didn't see any mention of anyone doing this so I started working on it this past weekend.

The h/w connections were easy....the standard GND->GND and crossing TX and RX on the Moteino and the Spark Core.  Both devices are 3.3v so that makes it nice and easy to interconnect.  My outdoor unit consists of an anemometer, BME280 (temp/humidity/pressure), solar panel and LIPO battery.  With the lower current drain of the Moteino and the solar/battery setup, the unit should run without intervention indefinitely (or at least until some catastrophic h/w failure).  The outdoor Moteino is pushing 10 variables of data to the indoor Moteino which also has an indoor temp/humidity sensor.  Once I have my case I will connect the 16x2 LCD and display both indoor and outdoor weather data.

The indoor Moteino will connect via the Spark Core which will act as the gateway to the Internet.  From there I can use any number of available dashboards to display the data in any format I choose.   Currently I'm using POSTMAN to view the data through a browser.

« Last Edit: June 30, 2015, 11:26:00 AM by Felix »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Re: Moteino using Spark Core as gateway instead of PI
« Reply #1 on: June 15, 2015, 08:18:17 AM »
Interesting combination, thanks for sharing, more details/photos/code are welcome.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #2 on: June 15, 2015, 09:16:35 AM »
Felix.....it's an honor.  I am a huge fan of what you're doing with the Moteino products.  I had pretty much standardized on the Spark/Particle family but the first time I worked with your board I fell in love.  I now own 7 boards and will undoubtedly order more!

Attached is a picture of the breadboard with the Moteino and the Spark core.  The blue wires connect GND on both devices.  The yellow wires connect TX on the Moteino to RX on the Spark.  The orange wires connect RX on the Moteino to TX on the Spark.  I had to break out the orange wires so I could temporarily disconnect from the Moteino since I can't upload code while it's connected.  I don't have to disconnect when uploading code to the Spark since all connectivity is done over wireless to the cloud.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #3 on: June 15, 2015, 09:56:03 AM »
Here are a couple of pictures of the external unit.  One picture shows the anemometer from Adafruit.  It runs on 7-24v so I used an internal board that increases the voltage from 5v-7v.  One picture shows the back of the unit.  I installed two 2" vents (front/back) to let the whole unit breathe a little.  One of the cables is for the anemometer and the other is for the temp/humidity/pressure sensor.  I still need to build the heat shield which will house the temp sensor. 

Another picture shows the solar panel (Adafruit).  It's a 6v, 3.4W solar panel.  The final pic shows the internal guts of the unit.  There is a Moteino running the whole show.  I am using a INA 3221 which gives me voltage and current readings on the LIPO (4400mAh), the solar panel and the load (Moteino and accessories).  I installed a main power switch and a reset button.  There is a recharge board which keeps the LIPO charging when the sun is out.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #4 on: June 15, 2015, 10:02:22 AM »
The back....

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #5 on: June 15, 2015, 10:02:52 AM »
The solar panel...

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #6 on: June 15, 2015, 10:03:23 AM »
The internals....

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #7 on: June 15, 2015, 10:09:28 AM »
Spark code.  The "Spark.variable" code is used to push these variables up into the cloud so they can be monitored using any available dashboard service.  I'm sending three different types of packets from the Moteino to the Spark:  1) THP - temp, humidity, pressure, 2) - WND - windspeed in MPH, 3) ELC - electrical, voltage and current for the LIPO, Solar panel and the Moteino.  I'm using a C union on the sending side so I only send one data type and the Spark end figures it out by the first token in the string.  Not my most elegant coding but it seems to work OK.

Code: [Select]
// Global variables
char buf[64];                                           // buffer for incoming data
double temp=0,
       humidity=0,
       pressure=0,
       windspeed=0,
       lipoVoltage=0,
       lipoCurrent=0,
       solarVoltage=0,
       solarCurrent=0,
       loadVoltage=0,
       loadCurrent=0;


void setup()
{
    Serial1.begin(115200);
    Spark.variable("temp", &temp, DOUBLE);
    Spark.variable("humidity", &humidity, DOUBLE);
    Spark.variable("pressure", &pressure, DOUBLE);
    Spark.variable("windspeed", &windspeed, DOUBLE);
    Spark.variable("lipoVoltage", &lipoVoltage, DOUBLE);
    Spark.variable("lipoCurrent", &lipoCurrent, DOUBLE);
    Spark.variable("solarVoltage", &solarVoltage, DOUBLE);
    Spark.variable("solarCurrent", &solarCurrent, DOUBLE);
    Spark.variable("loadVoltage", &loadVoltage, DOUBLE);
    Spark.variable("loadCurrent", &loadCurrent, DOUBLE);
}


void loop()
{
    int x, avail;
    char *token;
    const char sep[2] = ",";

    if ((avail = Serial1.available()) >= 20)            // wait until we get a full buffer
    {
        for (x=0; x < avail; x++)
            buf[x] = Serial1.read();
        buf[x] = '\0';                                  // string must be null terminated
       
        token = strtok(buf, sep);                       // pick off first token = packet type
        if (token != NULL)
        {
            if (strncmp(token, "WND", 3) == 0)          // windspeed packet
            {
                token = strtok(NULL, sep);
                if (token != NULL)
                    windspeed = (float) atof(token);    // extract windspeed
                Serial1.print("wind");
            }
            else if (strncmp(token, "THP", 3) == 0)     // temperature, humidity, pressure packet
            {
                token = strtok(NULL, sep);
                if (token != NULL)
                    temp = (float) atof(token);         // extract temperature
                token = strtok(NULL, sep);
                if (token != NULL)               
                    humidity = (float) atof(token);     // extract humidity
                token = strtok(NULL, sep);
                if (token != NULL)               
                    pressure = (float) atof(token);     // extract pressure
            }
            else if (strncmp(token, "ELC", 3) == 0)     // electrical packet
            {
                token = strtok(NULL, sep);
                if (token != NULL)
                    lipoVoltage = (float) atof(token);  // extract lipoVoltage
                token = strtok(NULL, sep);
                if (token != NULL)               
                    lipoCurrent = (float) atof(token);  // extract lipoCurrent
                token = strtok(NULL, sep);
                if (token != NULL)               
                    solarVoltage = (float) atof(token); // extract solarVoltage
                token = strtok(NULL, sep);
                if (token != NULL)
                    solarCurrent = (float) atof(token); // extract solarCurrent
                token = strtok(NULL, sep);
                if (token != NULL)               
                    loadVoltage = (float) atof(token);  // extract loadVoltage
                token = strtok(NULL, sep);
                if (token != NULL)               
                    loadCurrent = (float) atof(token);  // extract loadCurrent
            }
        }
    }
}

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #8 on: June 15, 2015, 10:23:08 AM »
Here is the code running on the Moteino in the outdoor unit.  Every second it reports the windspeed to the internal unit.  Every 60 seconds it sends temp/humidity/pressure and the 6 electrical readings to the indoor unit.

I had to attach the INO file and the header file since it was longer than 5K.

Here is what the output looks like coming from the outdoor unit:

WND,0.00
WND,0.00
WND,0.00
WND,0.00
WND,0.00
WND,0.00
WND,0.00
WND,0.00
WND,0.00
WND,0.00
THP,90.91,55.89,29.73
ELC,4.12,116.80,4.81,157.60,4.55,40.00

TomWS

  • Hero Member
  • *****
  • Posts: 1924
Re: Moteino using Spark Core as gateway instead of PI
« Reply #9 on: June 15, 2015, 11:28:13 AM »
Are you using software serial port?  Your code is using Serial1 but your photos show a Moteino, not a Moteino Mega.

Tom

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Re: Moteino using Spark Core as gateway instead of PI
« Reply #10 on: June 15, 2015, 12:14:20 PM »
Nice detailed and labeled photos syrinxtech!
I see you're using adafruit's solar charger, how's that working? How did you determine the size of the cell you need, or did you just pick one you thought would give plenty of juice?
Maybe I'm missing something but I wonder why you are using the step-up? Do you need 5V/more for one of the sensors/boards/Spark?

EloyP

  • Jr. Member
  • **
  • Posts: 58
Re: Moteino using Spark Core as gateway instead of PI
« Reply #11 on: June 15, 2015, 02:35:28 PM »
Hi syrinxtech,

Thanks for sharing; very nice project!

I am curious about power usage and conservation on the outdoor unit... I took a quick look at WeatherStation2.ino and don't see any code to put the radio to sleep, or for the ATmega itself to go into deep sleep mode, and at the same time the unit is sending sensor data every 60 seconds. Would this not cause the outdoor unit to stop working if you have a couple of cloudy days? Or asked a different way, how long can the LiPo battery keep the outdoor unit running without being recharged?

Cheers!

Eloy Paris.-

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #12 on: June 15, 2015, 02:50:11 PM »
Tom, the code using Serial1 is for the Spark Core.  On the Core, Serial is the USB port while Serial1 is the TX/RX serial port.

Felix, that charger is working fantastic.  My brother-in-law and I spent several days over a period of about 3 weeks deciding on the best (at that moment in time) charger, LIPO, solar cell and microcontroller for the project.  As I mentioned earlier, my initial plan was to use a Arduino UNO for the outside unit and the inside unit.  Once I ordered my first Moteino that plan went out the window so all specifications on the charging combo (LIPO/charger/solar cell) were for the UNO.  We did extensive testing with the UNO and found that without sensors it was running around 120-130 mA while the Moteino was running around 30-40mA.  I spent a couple of days working with the various methods to put the Moteino to sleep and got it down to the uA levels.  Then, of course I changed my specs and decided that instead of sending all data from the outside unit to the inside unit every minute I would send the windspeed every second and the rest of the data (which grew to include the 6 electrical measurements once I found the INA3221 board) every minute.  That negated the ability to put anything to sleep since I was sending data constantly.

We have lots of days of data gathering and many Excel spreadsheets that show the various ways we have structured the box.  I'm attaching one of the samples we did this past weekend.  You can watch the graph and see exactly when the sun starts coming up and when it eventually goes over my house and the box is in the shade. 

The step-up is for the anemometer.  The one I picked from Adafruit requires 7-24 VDC and the solar cell only puts out 6V and the LIPO tops out at 3.7v.  We originally tuned this board to output 9V which worked fine for the anemometer but of course drew more current.  We found that tuning it to 7VDC was optimum for both the anemometer and the current draw.  Once we switched to the Moteino we found that we had basically built a box that will run forever (unless the sun doesn't come out for at least a week).  Take a look at the chart in the attached Excel file.

Eloyp, the windspeed is being sent every second and the the temp/pressure/humidity and 6 electrical measurements are sent every minutes.  Therefore I can't put anything to sleep.  I originally coded everything to sleep when all measurements were being sent once a minute (~54 seconds of sleep per minute).  Once I changed the requirements I had to take out the sleep code.  But, given the size of the solar panel, the capacity of the LIPO and the minimal current draw of the Moteino and attached sensors, I can't see a situation where it would ever run out of power unless the sun wasn't out for at least 5-7 days.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #13 on: June 15, 2015, 02:57:27 PM »
If you're into the power side of things, take a look at the chart in the attached Excel spreadsheet.  This one was measuring just the load voltage from a little after 8pm until later the next day.

You can clearly see the affects of the sun.  Notice the lowest voltage levels....


syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #14 on: June 16, 2015, 10:03:27 PM »
Finished mocking up the internal weather unit today.  Basically there is another Moteino with a DHT11 providing internal temperature and humidity.  It's connected serially to a Spark Core which is pushing 10 variables of data to the Internet for graphing and analysis.  The internal unit is also driving a 16x2 LCD screen which is currently displaying internal temperature, humidity and the external heat index.  When I'm done it will display a total of 3 different screens:

1) External temp/humidity/pressure/heat index
2) Current windspeed/max windspeed/average windspeed over last 30 minutes
3) Internal temp/humidity

Just ordered the case to hold all this stuff so once it gets here it will take a day or two to assemble.  Will include a reset pushbutton switch just in case something weird happens in the code.  I am also going to use a LDR to regulate the intensity of the backlight for nighttime purposes.

Stay tuned.

joelucid

  • Hero Member
  • *****
  • Posts: 867
Re: Moteino using Spark Core as gateway instead of PI
« Reply #15 on: June 17, 2015, 06:00:38 PM »
You should at least get the DHT22. It's not expensive and much better than the DHT11.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Re: Moteino using Spark Core as gateway instead of PI
« Reply #16 on: June 18, 2015, 09:07:49 AM »
Or a WeatherShield :P

Moteino WeatherShield by Felix Rusu, LowPowerLab.com, on Flickr
« Last Edit: June 19, 2015, 12:37:55 PM by Felix »

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #17 on: June 18, 2015, 10:39:51 AM »
Joe....I have a DHT11, DHT22 and the wired version of the DHT22 (AM2302) available.  I used the DHT11 since it was an indoor application and precision wasn't that big of a deal.  I'm saving the DHT22 for something else.  I was going to use the wired DHT22 on the outside unit until I found the BME180 which does temp/humidity and pressure in one chip.

Great ad Felix!

jra

  • Jr. Member
  • **
  • Posts: 81
  • Country: us
Re: Moteino using Spark Core as gateway instead of PI
« Reply #18 on: June 19, 2015, 12:20:33 PM »
You mean the BME280, right?  Did you make your own breakout or did you buy one (http://www.embeddedadventures.com/bme280_weather_multi_sensor_mod-1022.html maybe)?  I thought it was pin compatible with the BMP280 (temperature + pressure, no humidity) and would work on something like http://www.watterott.com/en/BMP280-Breakout but an email exchange with them indicated that the BMP280/BME280 packages are slightly different.  They plan on having a BME280 breakout available somewhere towards the end of June.  The standard interfaces (I2C/SPI) are definitely a plus and the ability to monitor three parameters with a single sensor can simplify the HW design.  How have you found the temperature accuracy?  I was under the impression that the temperature sensor on the Bosch unit was there primarily to compensate the barometric sensor as the accuracy specs are not as good as something like an MCP9808 (temperature only) or a HDC1000 (temperature + humidity).  I'm looking at doing something slightly different (monitor/control the environment inside a coldframe/greenhouse).

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #19 on: June 19, 2015, 01:39:00 PM »
Yes, sorry.....BME280.  I did get the one from Embedded Adventures.  I am also using the code they provided.  I love being able to measure voltage and current for the LIPO, solar panel and the Moteino and sensors all at the same time.  I've found the temperature accuracy to be as good as any other sensors I've used (DHT11, DHT22, DSB1820).  I also have one of the MCP9808's that I got when I first started learning the Arduino a couple of months ago.  I've also noticed that the BME280 is faster in reacting to quick temperature changes.  Bringing the unit indoors or putting it outside used to take a few seconds to start to compensate but IMHO this unit is much faster.


syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #20 on: June 30, 2015, 10:59:07 AM »
Attached is a picture showing the outdoor unit with the newly painted tray to attach it to my deck.

It also shows the newly painted temp sensor shield.  I painted it with several coats of off-white and by placing a commercial temp sensor next to it I found that in direct sun of 90+ degrees it reduces the reported temp around 15-20 degrees.  The BME280 is hanging inside around the 3rd bowl from the top.  There is enough room for air to blow throw but hopefully keep out the rain.  The top is solid and the rest of the bowls have a 2" cutout down the middle.  Three 1/4" threaded rods and 1/4" tubing for spacers complete the unit.

I'll take a few screen shots of the indoor unit LCD and post them in a few minutes.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino using Spark Core as gateway instead of PI
« Reply #21 on: June 30, 2015, 11:16:11 AM »
LCD screens from the indoor unit:

Currently I have a timer for each of three different displays:

1)  Indoor temp & humidity: 4 seconds
2)  Outdoor temp/humidity/pressure/heat index or wind chill: 4 seconds
3)  Current wind speed/average windspeed/max windspeed:  3.5 seconds

If the proper conditions for either the heat index or wind chill it is displayed, otherwise just a 0.0.  The average/max windspeed calculations are done over the last hour.  The outdoor unit is sending in temp/humidity/pressure/heat index or wind chill every 30 seconds and wind every 10 seconds.

The barometric pressure indicator (up/down arrow) uses a running average to compare each new reading.  I'm meeting a "big data" professor friend of mine and will hopefully come up with a more statistically-relevant algorithm but for now it's OK with me.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Re: Moteino using Spark Core as gateway instead of PI
« Reply #22 on: June 30, 2015, 11:24:56 AM »
Ok, this is sticky worthy  8)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
I'm guessing "sticky worthy" is a good thing Felix?

BTW, I just ordered the lightning sensor from Embedded to add to the project.  I'm also thinking about adding a DHT11 to the outside box to report on temps inside the box.   You can't have enough sensors, right?


TomWS

  • Hero Member
  • *****
  • Posts: 1924
Re: Moteino using Spark Core as gateway instead of PI
« Reply #24 on: June 30, 2015, 12:01:08 PM »
I painted it with several coats of off-white and by placing a commercial temp sensor next to it I found that in direct sun of 90+ degrees it reduces the reported temp around 15-20 degrees.  The BME280 is hanging inside around the 3rd bowl from the top.  There is enough room for air to blow throw but hopefully keep out the rain.  The top is solid and the rest of the bowls have a 2" cutout down the middle.  Three 1/4" threaded rods and 1/4" tubing for spacers complete the unit.
This weekend I saw a weatherstation where someone had enclosed his THP sensor in a cedar box with louvers in the side and an RV Solar powered vent in the sloped top.  The owner claimed that he had good accuracy measuring the outside ambient temperature without 'environmental' issues (like blizzards).  The vent looked similar to this one: http://www.etrailer.com/Enclosed-Trailer-Parts/Ultra-Fab-Products/UF53-945001.html but was around 4" diameter, for a sewer pipe, I believe.

You can probably shop around and find a less expensive one.

Tom

BTW, I like that your weather station has a place to open a beer!
« Last Edit: June 30, 2015, 12:09:12 PM by TomWS »

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Thanks Tom....you have to have your priorities!

I'll take a look at your suggestion.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Was watching some great Cornell classes on MCU's and started learning more than I wanted to about hardware timers.

Ended up adding a watchdog timer on the outdoor unit of 8 seconds and one on the indoor unit of 2 seconds.  Just a simple system reset if not reset.  Might get fancy at some point and write the current date/time into EEPROM so I see when it crashes.

I might end up tweaking these two values after some more experimentation.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #27 on: November 09, 2015, 04:04:08 AM »
We changed the heat shield from the plastic bowls to what was originally a humming bird feeder.  We took out the insides and ran a dowel down the middle.  We attached the BME280 to the dowel and attached the cable.  Slats were installed to allow for fresh air flow.  A fresh coat of white paint and the new heat shield was born.


syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #28 on: November 09, 2015, 04:12:25 AM »
Another note....I changed the BME280 drivers from the one that came from Embedded Adventures to the version provided by Adafruit.  Over time I was getting way too much variation from other devices.  Over 50% of the day, the humidity was always showing 100%.  Since replacing the drivers the results are much closer to that of other devices, and something that I can actually trust.

I also changed the timing and battery management by converting from "delays" using millis() to the following:

1.  Grab/display the wind speed.
2.  Go into a 4x loop:
  - grab/display the wind speed
  - radio.sleep()
  - lowpower.sleep(8s)
3.  Grab/display the temp/humidity/pressure
4.  Grab/display the 3 voltage/current measurements
5.  radio.sleep
6.  lowpower.sleep(8s)

This has dramatically saved battery, especially now the weather is changing and we're getting days with very little sun.  Another change I'm going to make is to turn off power booster for the anemometer (5v->7v) while sleeping.  We found that it only takes about a second to turn the power booster back on and get a reliable sample.  We're going to use one pin on the Moteino with a small power transistor to do the on/off switching.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #29 on: November 09, 2015, 08:46:05 AM »
Very nice, good progress  8)
You still haven't considered a WeatherShield?

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #30 on: November 10, 2015, 10:16:03 AM »
Felix,

Had we not already had the BME280 I would have considered it.  Since the BME280 already gives me temp, humidity and pressure in a smaller package I'm not sure if I see the advantage of switching.  Since I changed the drivers to Adafruit it has become much more reliable in terms of the measurements.  And since it's I2C, it connects from the heat shield to the outdoor unit with a simple 4-wire cable.  If the BME280 lived far away it would have made sense to use your board and connect to a LIPO battery.

If I'm missing or not considering something please let me know.  I'm all for supporting your efforts.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #31 on: November 10, 2015, 11:09:16 AM »
I don't think you're missing anything and there's no issue at all with you using another board or sensor, whatever works best and is easiest should be the way to go in any project.

It was just out of curiosity, I always like to see my own products used in various situations or pushed to more extremes and see how they handle it and this project looked like a nice candidate for that.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #32 on: November 10, 2015, 12:23:20 PM »
I agree completely.

And if I were you I would certainly want my products to be tested and verified under all conditions.  I know I've seen the Moteino take many days of 100+ heat and now it's taking lots of days at 45 degrees.  Soon it will be getting really cold and probably snow for the outdoor unit.  On my indoor unit it's been connected to the Particle and sending all of the weather data to the Internet for many, many months without fail.

I'm getting ready to order some LoRa Moteino's so maybe I'll throw in a WeatherShield and swap out the BME280.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #33 on: November 11, 2015, 12:04:06 PM »
Felix,

As promised, I placed the order this morning.  As soon as the WeatherShield arrives we'll get it installed outdoors.  Just in time for the coldest part of the year.  Should be a good test.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #34 on: November 11, 2015, 08:08:22 PM »
Awesome, be sure to follow up here as you make progress  ;)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #35 on: November 11, 2015, 10:31:09 PM »
Will do.

I'll be anxious to check out any possible differences in accuracy and battery usage.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1296
  • Country: us
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #36 on: November 12, 2015, 03:07:33 AM »
@syrinxtech: Nice project!  I'm wondering where in the cloud you're pushing the data to and how your organizing the data that your accumulating there.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #37 on: November 12, 2015, 07:16:50 AM »
We've done a couple of different things since we started.  For awhile I used a second Moteino to capture data to a serial port.  I then read in the CSV file into Excel and did all kinds of different graphs.  Since the inside weather unit has both a Moteino and a Particle Core, I use the Moteino to push data to the cloud via the Core.  I use Freeboard to graph various bits of weather and electrical measurement data.  I also use the Google app named Postman to view data via JSON calls.  If you're interested in seeing what Freeboard displays, I created this URL which gives you a read-only view:

https://freeboard.io/board/MCsvrV

At some point down the road when I'm finished adding onto the system I will probably get more serious about long-term data storage and start uploading to the cloud into some type of database.  I have a lightning sensor that I want to add at some point.  Besides the code issues that seem to follow this board we also don't get a lot of lightning where I live so installing and tuning is very much of a hit-and-miss proposition.

So, at the moment we're not accumulating any data, just watching it in real time.  It's a great sandbox to play in because it allows us to try so many different forms of h/w and s/w.  One other big goal of ours is to replace the anemometer we currently use with one built from reed switches so we don't need the power boost from 5v->7v.  This is the only real major source of battery drain we have left to remove.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1296
  • Country: us
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #38 on: November 12, 2015, 01:58:53 PM »

At some point down the road when I'm finished adding onto the system I will probably get more serious about long-term data storage and start uploading to the cloud into some type of database. 

I would have recommended plot.ly, except that it suddenly broke just recently for the second time in less than a year, and each time it's a hassle to figure out what needs to be changed in my code to get it working again.  I need to move on to something more stable.  Some people use mySQL, maybe for that reason.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #39 on: November 12, 2015, 02:21:17 PM »
I've used Oracle and mySQL in my "real" job...but not with MCU's.

Probably won't need something for a good while, having too much fun playing with add-on's and tweaks to code over time.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #40 on: November 13, 2015, 12:09:17 PM »
Converted yesterday to ATC on the indoor and outdoor units.  As Felix mentioned there were few changes required.  I had been using just send() with no ACK but the change was trivial.  I set my threshold to -85 and watched the RSSI drop from -27 to -85 in about 6 transmissions.

Hopefully in the next few days I'll have a chance to take some measurements and see how much current/battery life I'm saving.


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #41 on: November 13, 2015, 01:01:25 PM »
Converted yesterday to ATC on the indoor and outdoor units.  As Felix mentioned there were few changes required.  I had been using just send() with no ACK but the change was trivial.  I set my threshold to -85 and watched the RSSI drop from -27 to -85 in about 6 transmissions.

Hopefully in the next few days I'll have a chance to take some measurements and see how much current/battery life I'm saving.

Hey! So you're using the new ATC extension, cool!
Please share how your ATC is impacting the battery life when you have more info.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #42 on: November 21, 2015, 08:45:53 AM »
The new WeatherShield arrived and is now running with a Moteino and a PowerShield.  For a week or so I'm going to let the WeatherShield gather THP data beside the currently running BME280.  Which ever device provides the most accurate (to the best of my knowledge) information will be the winner.

I have been considering making the THP module a standalone device using a Moteino to send the data to the outdoor collection unit instead of having it hardwired to the outdoor unit.  This would allow me the flexibility of having multiple devices that I could install around the yard and have the outdoor unit act as a collection point.

Going to also consider moving the anemometer to a standalone device for the same reason as above.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #43 on: February 13, 2016, 03:06:27 AM »
Getting ready to add the Sparkfun UV sensor to the project.

Also swapped out the anemometer from Adafruit with the WeatherRack unit from SwitchDoc Labs.  This allowed us to remove the power booster which was required to up the voltage to 7v for the anemometer.  It also added wind direction and a rain bucket.  Just finished the integration and now the outdoor unit is gathering temp, humidity, pressure, wind direction, wind speed and rain amount.  Can't sleep the radio and MCU as much since we get interrupts for the wind speed and rain bucket.

Once I gather this info I also calculate the dewpoint, wind chill and heat index.

Still need to add the Lightning Sensor.  Problem is around here that we don't get a lot of lightning storms and there appears to be a fair amount of tweaking.

If you want to see what it looks like on Freeboard, check out this URL:

https://freeboard.io/board/MCsvrV


syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
MASSIVE CHANGES.....completely reworked the entire outside weather station.

Added anenometer, wind direction and rain gauge.  Everything sits on a 4"x4"x8' pole.  Clamp is temporarily holding everything together.

Inside the white heat shield are temp/humidity/pressure sensors.  Also included is an INA3221 current monitor which collects V/I readings from the LIPO, solar panel and load.  All of the data is transmitted indoors by a Moteino which is sleeping 8 seconds between transmissions.  The anenometer and the wind speed sensors interrupt as needed.  On top of the gray box is a 6"x6" solar panel which keeps everything charged.

Once the data arrives indoors it is pushed to freeboard by a serial connected Moteino-Particle Photon.  The data is also displayed locally on a 16x2 LCD.  The data is also pushed out to Felix's gateway for local viewing over a web browser.  All of the major stats reset automatically at midnight using an RTC attached to the indoor unit collecting the data.  I'm getting ready to add an micro SD card reader for long-term storage.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Very elegant, thanks for the update!!  :)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Thanks Felix.

My brother-in-law put in a boatload of hours making the wooden enclosure.  It has screen around the inside of the four slats to keep out bugs.  He made a groove across the bottom in which a perf board slides which connects to a PCB that holds the electronics.  It makes for a lot of air flow and keeps the temperature stable.  All of the corners are mitred and it was a shame to paint it.  Everything is pluggable for easy removal.

The best s/w feature for me is I can do OTA by keeping the radio alive for 2 seconds after the last set of three packet deliveries are made.  It usually takes one or two tries to time the OTA but it works quite well.

The highest wind recorded was during a recent really bad storm at 82mph.


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
The best s/w feature for me is I can do OTA by keeping the radio alive for 2 seconds after the last set of three packet deliveries are made.  It usually takes one or two tries to time the OTA but it works quite well.
Interesting, So you don't use the Listen mode to wake for OTA?

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
I played around with it and to be honest, didn't see where it would fit into my situation.

Please correct me if I'm wrong, but the real value of Listen mode is to sit quietly for some amount of time until you're woken up by an external packet.  In my case, the external weather unit never stops sending packets so sitting quietly for even a second isn't possible.  The wind speed code constantly interrupts the processor and the rain unit interrrupts every time a rain reading of 0.01" is detected.  With the radio constantly transmitting (minus the 8 second sleep I manage to slip in), would Listen mode work in this case?

The only way I got it to work reliably was to simply keep it awake up to 2 seconds after the last packet was transmitted.  If no OTA request is received during that 2 seconds, it then sleeps for 8 seconds and starts the whole process over again.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Oh I see what you're doing now. For your case where you have a solar cell that probably gives more than enough juice it's probably good enough.
But I think the ListenMode would totally be of use in your case, you'd reduce the total OTA delay to the delay window of the listen wakeup window, I think the default was 3seconds.
So basically in the "8second sleep time" you would sleep everything except the radio which sits in ListenMode (that's mostly sleep too, with tiny pulses of RX ON). Then a ListenMode burst would wake it up and make it wait until the burst window expires at which point you can actually do the OTA.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
If you want to see it on Freeboard, check it out:

https://freeboard.io/board/MCsvrV

The max lipo battery charge is 4.2V, which it stays at pretty much all day.  At night it will drop to somewhere around 4.17 but within an hour of the sun coming up it's back to 4.2V.  The LIPO is 4400mAh.

So, does the Windows OTA programmer send this "ListenMode burst"?  If not, what sends the wake-up call? 

And, if no OTA request is received, the unit sleeps for the entire 8 seconds and then wakes up as normal and begins sending data packets again?




Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Well embarrasingly I have not done OTA yet with ListenMode. The windows client might need to be updated when I do and I have a proven pattern that works.
The above is just the theory. ListenMode works nicely to keep a very low power unit in rx mode (ability to wake up at cost of some delay).
I guess the "programmer" unit used for OTA could send the burst first, but still the windows GUI has a limited timeout which might limit this.
I hope to get this working sometime :)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Thanks for the update.

The biggest issue I had with placing the weather unit outside was the OTA consideration.  It's sitting 9ft in the air in the back of my yard so anything other than OTA updates was simply not doable. 

If ListenMode will work with OTA and still let me stream data in real time then I'll certainly consider it.  Otherwise I have to just add one some time like I'm doing now.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Like anything it's a matter of tradeoffs .. like how often you do it, how concerning is the power consumption, etc.
In your case it's already working so why fix something that works.
But I'd like to make it easy(er) and improve OTA at some point to work with ListenMode. If you try it, use another mote and when it works reliably update your real station.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
I agree completely.

I'm sure the majority of people would love to have OTA integrated with ListenMode, but like you said, you're only one person and you certainly seem to have more than enough on your plate so it will take time.


jra

  • Jr. Member
  • **
  • Posts: 81
  • Country: us
Very nice.  How well did the solar/LiPo combo work during the winter months?

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
No problems.  The combination of the 4400 mAh battery and the 6"x6" solar panel kept the battery fully charged.

We connected a thermistor to the charging board which helps prevent charging when the unit gets too hot or too cold.

TomWS

  • Hero Member
  • *****
  • Posts: 1924
No problems.  The combination of the 4400 mAh battery and the 6"x6" solar panel kept the battery fully charged.
What part of the country are you?  How many sunny days a year or, more important, how many sustained cloudy days?

Tom

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
I'm in Richmond, VA.

The most cloudy days in a row I can remember in recent years is about 6 days.  Even during cloudy days I'm charging at just above 20 mA which keeps me just above break even. 

xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
@syrinxtech: I *almost* have the same setup - I'm using a BME280 though for getting temp/humidity and pressure and a small 3" solar panel (you can't see it on the photo it's flat behind the fence)

I tried to use the ListenMode as well but could not get it to work reliably (probably my code though) so I added a solar panel and just have the bananaPi get data every minute or when my iPhone app requests it - I try to put the moteino to sleep as often as possible but the wind interrupt kinda ruins the whole thing. I'm wondering if I'm better off just detaching the interrupt for the wind just keep it for the rain and when the Pi requests data just sample for 10s...

Wanted to use a ESP8266 and try to add an RFM69 instead of the PI but I'm running home bridge on the PI now as well, and asking siri for the outside humidity is just too funny to pass...

I like your enclosure! (my 3D printed one is very flimsy...) - I"ve attached my radio code in case someone has any feedback though it's not very pretty so dont hurt yourself!
« Last Edit: July 17, 2016, 11:38:42 AM by xavier »

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Impressive setup yourself.  I see you're using the SwitchDoc Labs WeatherPiArduino.  How do you like it? 

I haven't seen any ill effects of not using ListenMode.  My battery stays fully charged during the day and at night it only loses a small amount of power even with the rain bucket and the anenometer interrupting the MCU.

I'm thinking of adding Siri.... the cool factor alone is too much to pass up.

My brother-in-law gets full credit for the enclosure.  Damn fine piece of woodworking.  I'll post some more close-up pictures of the outdoor unit when I get back in town later this week.

We finished the first take on the "base station" and the "display" units.  All of the displays share the same network ID so the base station only has to send the data to one address and multiple stations around the house pick it up and display the data.  Since the base station has an 16x2 LCD for time/date/internal temp/humidity, I hacked the OTA code to display "Flashing code.  Please wait." on the screen when I'm updating OTA. 

xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
actually I'm not using WeatherPiArduino, just the weatherRack - I made my own board (always wanted to try!) which interfaces w the weather rack sold on amazon (https://www.amazon.com/gp/product/B00QURVHN6/ref=oh_aui_search_detailpage?ie=UTF8&psc=1) - Got a couple BME280 to get humidity/temp/pressure, works pretty well and it's quite accurate (once you figure out it needs a certain amount of air flow)

Silly question: how did you verify the rain gauge was working fine? I've been trying to find a way to convert say 10ml of water poured into the rain gauge to something I can verify...

I havent implemented OTA, probably should though... Trying now to figure out how to implement a wind speed and wind direction service in homebrdige since HomeKit does not define anything for weather specific devices as far as I know - lmk if you figure it out before me :-)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
I can't say I've ever tried to verify the rain gauge.  I know it dumps 0.01" of rain each time and beyond that I'm taking it on faith.  I know the numbers I get coincide with the weather folks so it's probably close enough for me.

I've never used homebridge or HomeKit so I probably won't be of any use to you there.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Attached is one picture of the base station showing the screen and several showing the display units.  In case I didn't explain before my setup is "3-tiered".  Sensors of many kinds all gather data and send it to a base station which collects everything.  It has a RTC for logging and time management along with an SD card for logging.  It is also connected to my UPS so I don't lose events when the power goes off.  Finally there are display nodes (all with the same node ID) which display the various status messages all around the house.  The display backlights are turned off at 9pm and then back on at 6am.  The display unit in the bedroom has a small lighted pushbutton which will turn on the backlight for ~ 14 seconds so you can read all three rotating screens and then goes back out.  All displays and the base station also has a DHT11 for local temp/humidity readings.  The base station is serially connected to a Particle Photon which uploads a bunch of data to Freeboard.

All devices support OTA.  For the display units with LCDs (most are 16x2), I slightly hacked Felix's code to display a "Flashing code....please wait" message which appears on the LCD.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
The rest of the "display" pictures.

xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
nice enclosure! did you 3D print it?

Last year I connected a a touch screen to the PI (http://www.aliexpress.com/item/Free-Shipping-A562-2SA562-diode-Amplifier-Transistors-NPN-Silicon-TO-92-Transistor-100pcs-lot-New-and/1891748120.html) and had a proximity sensor to turn the screen on and off when someone walked by but frankly it did not look really good and the lack of enclosure let cables runs lose...I should have spent more time on it - attached is a photo, sensor data is coming from moteinos, 4 day weather was from underground i think. the first pict used the eleduino screen which was not touch-screen and low resolution

I need to upgrade my weather station node to support OTA updates and maybe do better than using breadboard for connections, did u design ur own board for connecting the weather sensors to the moteino?

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Thanks.

The enclosures are from Polycase.  They are from the AG series.  The base station is the large one and the display screens use the medium one.

My brother-in-law laid out perf boards and did all the connections.  We haven't designed PCB's yet.

Nice screen layouts.


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6279
  • Country: us
    • LowPowerLab
Nice interfaces and screens guys.
@xavier - what interface is that running on the touchscreen?

xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
hey Felix - from a code pov it's pretty ugly but long story short the UI is html5, socket.io to get data from local node server that caches for 1 hour 4 days weather from underground (for rate limiting purposes) and gets data from moteinos.

the grass in the background comes from http://labs.hyperandroid.com/js1k and then I hacked around to add a weather widget that I found online (I can find the code if you want it)

the Pi had a couple of script that would launch matchbox-window-manager and chromium in full screen at boot time and load the web page - I had a couple of local scripts as well to turn the screen on/off if the moteino thought someone was walking by so the screen is not always on.. I'm moving things to iOS now since I mostly now check weather data from my phone (and w the new siri SDK I should be able to just ask my iPhone!)

I'll make a "nice" UI for your nodes if you build me a prototype for my next project  ;D

xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
and just to make sure you enjoy the nice animation from http://labs.hyperandroid.com here is a video :-)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Good stuff xavier.

I added two pictures of the base station.  One shows the inside and the other shows the rear of the box.  The inside picture shows the two halves of the unit.   The left side shows the Moteino, the Particle Photon, the DHT11, RTC, power jack and the SD card reader.  The right half is the LCD backpack.

The rear picture shows the SD card on the left, the DHT11 in the middle and the power jack on the right hand side.

xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
Fictiv has a breakdown of the netatmo weather module if anyone is interested: http://www.blog.fictiv.com/posts/netatmo-weather-station-teardown-part-1-outdoor-module

they say the module can work for 2 years on 2 AAA batteries a TI sub gig radio sends data to the receiver, arm cortex M3...anyhow, I suppose parts for the module can't be more than $15?

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Recently added a couple of new tricks:

1) Utilizing the Particle Photon, I am using webhooks to send SMS messages when any of the devices in the network (base station, sensors, or display units) boot.  It sends the timestamp and the name of the device.
2) I also use the SMS feature to send messages when the mailbox opens or closes.  This message also includes the current battery voltage.
3) The waterleak detectors also use SMS to send a "hello" packet every 12 hours with the battery voltage.  Of course, a water leak will send an immediate SMS message.
4) The base station sends a packet at midnight to the outdoor weather unit to reset the rain count for the past 24 hours to 0".  The max wind for the last 24 hours is also reset at midnight.

xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
that's neat - I suppose you have an RFM69 connected to the photon? (I suppose the photon is pretty much a feather WICED btw) - I like the idea of the ping to see if node is alive when not communicating at regular intervals.

I opted for putting everything server side (in the cloud!) - so my RFM69s talk to the PI (which is connected to a moteino by serial) - then I have https PHP entry points for saving data from the PI to the cloud server and in that erver I have node+socket.io running for doing RT stuff. The Pi is just a client, so are my iphone, web interface, iphone native app (though my native app just uses the php entry point for getting the data for now).

I reset only the water on a specific interval, the moteino clients are pinged at regular intervals by the PI, the PI runs a scheduler and I can change the timeframes using the web interface (socket.io). the PI then calls the server to save the data in a mysql table, then I can aggregate data there to draw5 min, 1 hour graphs. I only sample the wind data btw for 3 sec when doing a measurement, only the rain is computed on a fixed interval on the moteino and then reset. Not sure if this is optimum but since it never rains in CA I'll have to wait to make sure it works :-) - my garden humidity moteinos are fried so only the weather station is pushing data right now...(just in case you thought I had 10s of moteinos pushing data :-)

I can open up my php entry points if you want to try out the UI, it's not fancy but I can do a couple of changes and send you a https entry point (houseId, apiKey) where you can send your data and you can try out some of the UI. (I may have underestimated how much work I need to do for this but let me know if you want to try it out)

these are the fields I'm using right now in case you want to check it out, if you can fit your data in there it would be relatively easy I suppose...
Code: [Select]
CREATE TABLE `sensorDataTemp` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `houseId` int(11) DEFAULT '-999',
  `sensorId` int(11) DEFAULT '-999',
  `temperature` float DEFAULT '-999',
  `humidity` float DEFAULT '-999',
  `soilHumidity` int(11) DEFAULT '-999',
  `light` int(11) DEFAULT '-999',
  `pressure` float DEFAULT '-999',
  `windSpeed` float DEFAULT '-999',
  `windDirection` int(11) DEFAULT '-1',
  `windSpeedAvg` float DEFAULT '-999',
  `windDirectionAvg` int(11) DEFAULT '-1',
  `rainForPeriod` float DEFAULT '-999',
  `windGustForPeriod` float DEFAULT '-999',
  `batteryLevel` float DEFAULT '0',
  `timestamp` int(11) DEFAULT '0',
  `timestampServer` int(11) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
this is probably overkill for a side project but it's been fun!
« Last Edit: August 19, 2016, 06:34:38 AM by Felix »

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Added a simple temp/humidity sensor for the attic.

It's AC powered and checks in every 15 mins with the temp and humidity.  If the temp is over a pre-set limit it will send a text message.

Added a bunch of multilevel debug (DEBUG, DEBUG1, etc) which helped with a couple of obscure bugs.  Also consolidated the various packet types (enums, structs, and unions) into a library so now I don't have to change 15 copies of things when I want to add a new type of packet.

Hindsight is 20/20.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #75 on: September 04, 2016, 06:44:44 AM »
Started getting too many SMS messages during testing so I added email via the great "mailgun" service.  Now I only get SMS messages when the waterleak detector goes off or one of the motion sensors fires.

Added an in-memory node database so I can perform two checks at midnight:
1. See if any sensor node hasn't checked in during the past 48 hours.
2. For battery operated nodes, send an email if any battery level is getting low.

Getting ready to add another in-memory structure holding the highs/lows of key weather metrics on a daily basis.  I'll put this as another screen on Freeboard.

xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #76 on: September 08, 2016, 02:07:36 PM »
hey silly question: do you store all data points locally? why not push everything to a server and have some cron jobs check the data and calculate daily, weekly averages?

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #77 on: September 08, 2016, 02:57:03 PM »
xavier,

Not a silly question at all.  Right now I'm technically "storing" the data points.  For my weather-related data, it goes over the serial connection to a Particle Photon and up to the cloud where it is displayed via Freeboard.  I also have an SD card on-board if I want to do some local storage.  Down the road I plan on incorporating a MySQL server that will be feed via webhooks from the Photon.

On my list of TODO's is a small local file containing the daily highs/lows/averages that is kept on a daily basis.  At midnight the base station will run a job to zero out the counters and start fresh the next day.  Freeboard will be used to show the results of that daily file.  At some point I will probably write that daily information out to a longer term database like the weather data.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #78 on: September 11, 2016, 10:28:49 AM »
Added a "daily recap database", (in memory), that holds the previous 24 hours mins/maxes for temp, hum, pressure, wind, rain, etc.  This resets at midnight.

Getting ready to write code to produce two reports to run at noon each day.

1. Those nodes that haven't checked in for at least 48 hours.
2. Battery-operated nodes that have a battery level less than a preset value.

Including the various modules where I've broken out code to make things easier to find and modify, I guess there is about 1,200 lines of code for the base station.  There is least another 1,000 lines combined for the various sensors and display units.  If the 328p was only multi-threaded!!



xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #79 on: September 16, 2016, 12:34:51 PM »
hey syrinxtech: how long do you measure wind speed before returning the data? I'm currently sampling for 3s and my gateway requests data every minute, probably overkill since I now have 81K entry points (2 months of data) - the pressure data is interesting though and by calculating the rate of change I can "almost" say if the fog comes in or just clouds!

I missed the fact you were using Freeboard - I was thinking switching my bananaPI to a ESP8266 (just saw the post from Xose as well, very interesting and detailed blog!) but I'm not sure it would improve anything...I'll just wait for the ESP32 so I can configure the gateway using my iPhone (that would enable anyone to pretty much grab a gateway and some nodes and configure everything without coding)

I like the fact I can run socket.io on the PI and have web client anywhere be able to request data, I suppose mqtt would work as well but I looked at the adafruit samples and it's heavy (or maybe I need to spend more time looking at the code)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #80 on: September 16, 2016, 09:40:42 PM »
xavier,

I'm not actually sure how long it measures.  I'm using the WeatherRack from SwitchDoc Labs.  The code is on the page if you're interested in looking it over:

http://www.switchdoc.com/weatherrack-weather-sensors/

I'm in a sampling loop between 3 sets of data:  1) Temp/hum/press, 2) Electrical - 6 different values from the INA3221, and 3) Wind/Rain. 

I really like Freeboard, in fact I just added a mobile version of the normal weather page that doesn't use any fancy graphics so everything fits onto the screen.  I just finished the daily statistics page that I added to the mobile version.

I am really interested in playing more with mqtt myself. 

Here's the URL for the Freeboard "mobile" version with daily recap:

https://freeboard.io/board/5epTjs


xavier

  • Jr. Member
  • **
  • Posts: 65
  • Country: us
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #81 on: September 22, 2016, 08:15:31 PM »
is that last URL you sent using data from your weather rack setup? (100% humidity seems high though :-)
I see the data changing almost RT in certain cases... I guess I'll check their code.

My thinking w using node and socket.io was to use that and an external server to get data every 3 sec from the weather station when the iPhone app is used. I guess I should start updating my iPhone app...

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #82 on: September 22, 2016, 10:48:21 PM »
Yes, that last link is my 2nd Freeboard setup.  I created it without using any gauges or fancy icons so it will fit on an Amazon Fire in landscape mode.  I get all of the weather and electrical data plus a 24-hour recap of the highs/lows.

We frequently see 100% humidity around here.  Particularly when it has recently rained or there is a lot of dew in the morning.

Some of the measurements are sampled at 30 seconds while others, like the wind, are sampled at 3 second intervals.  Freeboard reads the data from Particle.IO in JSON format.  The Particle Photon connected serially to the Moteino receives all of the data and uploads it to be read by Freeboard.  The only limitation at the moment is a total of 20 variables you can monitor.  In some cases I've had to make a string and combine 2 or 3 measurements instead of reporting them individually.

The wind/rain component I'm using are setup to use interrupts for wind and rain changes.  Each .01" of rain causes an interrupt to count the rain and the anenometer also uses an interrupt.  The wind direction is measured using reed switches.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #83 on: February 07, 2017, 10:11:28 AM »
Made a couple of improvements in timekeeping, both on the Spark Photon and the Moteino.

Added code to adjust for DST.  My normal is EST (-5) and twice a year it changes between EST and EDT.  The offset is one hour.  The code basically adjusts for the difference and sets the time accordingly.  The Photon gets its time via NTP from the Internet and the Moteino keeps time using a RTC board.  Before this, I had to recompile programs on both platforms in order to keep the time correct, especially since all texts and emails originate from the Photon and when the time changed the timestamp on the emails was wrong.


syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
Finally got around to making an improvement on the SD card logging routines.  I added a couple of control functions and now I can remotely dump the contents of the SD card over the radio to a client.  This allows me to dump the log to a file using CoolTerm without having to physically remove the SD card, copy off the file, and replace it.  I borrowed this code from another project I just recently finished and in the other project I also have the ability to delete the file so I can always start over fresh without retrieving the card. 

I wrote a "universal" client, allowing me to connect to these two different applications running on two different basestations.  Each has their own radio frequency and node ID's.  With a little input from Serial.available I dynamically map the radio to correct configuration and deliver a unique structure of information to request the SD card file dump, or delete.

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
And since I do security auditing for a living, I thought I would add some additional layers of security.

On top of the normal network ID and encryption key needed, I added two additional security features when downloading the SD card logfile contents OTA:

1.  I added a "magic cookie" in the request structure so if you don't have the right bytes in the right fields you don't get any data.
2.  I restricted the source node ID to a single device so you have to make requests from the mgmt station.


rwb

  • Newbie
  • *
  • Posts: 6
  • Country: us
@Syrinxtech 

I saw this thread and wanted to check in and let you know that we have the Radio Head library working on the Particle Photon devices now. So you can hook up an RFM95 module directly to the Photon now and it works great.


You can find more info on the Radio Head library working directly with the Particle Photon in this thread: https://community.particle.io/t/particle-photon-electron-rfn95w-long-range-radio/22439/20?u=rwb

I'm looking to create a network like pictured below where only the Server Photon has WiFi access.


I'm looking for help on how to format variable/ sensor data using the Radio Head RFM95 Reliable Datagram code when sending to from the Client radios to the Photon server radio.

Once the data is received via the Server Photon I need to update the proper variables with the new sensor data.

I see you have done this already with the RF69 radios but I'm not sure how similar that is to the RFM95 radio send data format.

Let me know what you think if you have time! Thanks! ;)

« Last Edit: May 26, 2017, 04:13:42 PM by rwb »

syrinxtech

  • Sr. Member
  • ****
  • Posts: 330
  • Country: us
    • Syrinx Technologies
@rwb,

Thanks for the heads up on the Photon.

Second, in your "Particle Lora" picture, you wouldn't necessarily need the Photons on the edge.  You might be able to save some money by just purchasing a LowPowerLabs Moteino with the appropriate radio.  Seems a waste to have wireless connectivity provided by the Photons and then use the RF radios to transmit your sensor data.  Just a thought.

Third, I've worked with the RadioHead code in the past and there really isn't a difference in the mechanics of sending a packet over their API versus Felix's RFM69 code.  You create the appropriate structure containing the necessary data and call some form of a "send" function.  Creating the best structure for the wireless data depends on exactly what you're sending and how you plan on representing the data.  There have been many discussions on this forum about transmitting chars, floats, ints, long ints, etc., that you might want to search for and take advantage of the collective wisdom of this group.

raenrfm

  • Newbie
  • *
  • Posts: 20
Re: Moteino + Spark Core gateway instead of Pi - Solar Powered Weather Station
« Reply #88 on: September 11, 2017, 04:56:47 PM »
I'm basically doing the same setup right now, accept I'm storing my data locally on an MQTT server, then on my PI I'm running WeeWX (weather software), you should really look at it, instead of re-inventing the wheel.  That package has everything you need to archive data (SQL based) and do trending etc...it also does calculations for you.  If you set it up with realtime gauges it generates a web page that you can display on any device (wall mounted tablet??) and the gauges look like old school weather gauges.  There is also a very good community of weather nerds like myself that do all kinds of stuff like this and have their own builds.

Right now my MQTT server is running on a PC, but I hate having it on all the time, so my goal is to create a PI cluster and run a Docker swam and have MQTT and Weewx, rednode and whatever else I can think of running on it.  Want to have it on battery backup as well in case of an outage so it will never stop.  My base station will also have a lipo battery for the same reason.  I'm using the same Adafruit solar charger and it's the bomb, works amazing as long as you feed it a 6V panel.

Go check out Weewx, you'll thank me later.