element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Enchanted Objects
  • Challenges & Projects
  • Design Challenges
  • Enchanted Objects
  • More
  • Cancel
Enchanted Objects
Blog Enchanted Objects Design Challenge - The townsfolk get Rickrolled
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Workshopshed
  • Date Created: 25 May 2015 6:53 AM Date Created
  • Views 1618 views
  • Likes 5 likes
  • Comments 9 comments
  • enchanted_cottage
  • dos
  • enchanted_objects
  • rick_astley
Related
Recommended

Enchanted Objects Design Challenge - The townsfolk get Rickrolled

Workshopshed
Workshopshed
25 May 2015

Good morning Ricksville

 

One morning Farmer Hogg woke up, looked out the window and checked the colour of his field.He headed down to the kitchen and turned on his internet radio, Rick Astley was playing so he turned it off again.

Old Mother Hubbard turned on her computer to check her inventory management system. A Rick Astley video was playing, she liked Rick so left it playing and forgot what she was about to do.
At the top of the stairs, around the back of the town hall, the man from the Historical society was trying to find film footage of the old mine workings but every time he clicked on a link, Rick Astley appeared.
The inn keeper had Rick Astley playing on his jukebox and also on the POS system.

The woodcutter was normally a man of few words but after 30 minutes trying to rid his computer of Rick, he had managed to find a few extra ones that even the dwarves would have been shocked by.

The mayor turned on his TV to watch Lizzy the Lizard exercise video and also got Rick Astley. Enough was enough, a town meeting was called.


Mean whilst in the forest, Hans and Matilda were trying to connect up to the internet. "Strange?" said Hans, "the requests get past our firewall but timeout when reaching the town ISP, it is there because I can get a response by extending the timeout, but it just seems to be too busy to forward on our weather requests."

 

The old fashioned way


"We are going to have to do it the old fashioned way", said Hans. "Not the cat gut?!" cried Matilda. "Not quite that far back" he said. Hans rummaged in his spares box and brought out a tiny device that looked a bit like a cheese grater. "We can get the local temperature and humidity with this DHT22 and estimate the chance of precipitation from that" said Hans.

 

   imageimage

 

// Based on the work of ladyada, public domain
#include "DHT.h"
#define DHTPIN 4     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// NOTE: For working with a faster chip, like an Arduino Due or Teensy, you
// might need to increase the threshold for cycle counts considered a 1 or 0.
// You can do this by passing a 3rd parameter for this threshold.  It's a bit
// of fiddling to find the right value, but in general the faster the CPU the
// higher the value.  The default for a 16mhz AVR is a value of 6.  For an
// Arduino Due that runs at 84mhz a value of 30 works.
// Example to initialize DHT sensor for Arduino Due:
//DHT dht(DHTPIN, DHTTYPE, 30);
void setup() {
  Serial.begin(9600); 
  Serial.println("DHTxx test!");
 
  dht.begin();
}
void loop() {
  // Wait a few seconds between measurements.
  delay(2000);
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Serial.print("Humidity: "); 
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: "); 
  Serial.print(t);
  Serial.print(" *C ");
  Serial.println("");
}

 

Hans decided to pass the local temperature and humidity over to the Python script and if there is no network or an error it can still return a position reference for them. That way all the weather related algorithms are in one place. Hans could not find any algorithms that connected humidity to precipitation but he thought if he based it around the dew point that would give a very similar result to the old cat gut.

 

The boy who cried wolf

 

Mean while at the town meeting a small boy pointed to a logo in the corner of a screen playing Rick Astley videos and cried "wolf! wolf!", the townsfolk told him to be quiet and stop bothering them.

 

Next: Enchanted Objects Design Challenge - This is not the WiFi you are looking for

 

Reference

 

Adafruit Learning - Using a DHTxx sensor

Estimating air humidity from temperature and precipitation measures for modelling applications

How do I calculate dew point?

Precipitation Estimation in Canada using Archival Climate Data - William A. van Wijngaarden* - Physics Dept., York University, Toronto, Ontario

Lecture: Humidity as an Element of Weather, Dr. Rodrigue

  • Sign in to reply

Top Comments

  • mcb1
    mcb1 over 10 years ago in reply to Workshopshed +2
    you can't predict the weather based on just humidity and temperature In your application you're inside, which is also going to change it. If you added barometric pressure, would that improve the predicability…
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to mcb1 +2
    Another very valuable information that can be extremely helpful for predictions is the collection of an historical series to analyse some statistical information along the timeline, i.e. the standard deviation…
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to Workshopshed +2
    Andy there is also another trick that in cases like this maybe very useful to test the predictive algorithms: getting a bunch of data from the internet (six months or one year, i.e. two or four seasons…
  • Former Member
    Former Member over 10 years ago

    god damn you Rick Astley!!! lol!!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 10 years ago

    I put the numbers into a spreadsheet and came up with the following algorithm. I'll see how well that does and adapt as necessary.

     

    # Take the two command line arguments and generate a 1 to 5 rating of it it will rain
    # See http://www.tutorialspoint.com/python/python_command_line_arguments.htm
    
    import sys, getopt
    
    def guess_weather(rel_humidity, temp):
        # Temperature in Degrees C and Relative Humidity as a percentage
        # Based on an approximation of these graphs
        # ftp://www.star.nesdis.noaa.gov/pub/smcd/spb/lzhou/AMS86/PREPRINTS/PDFS/97921.pdf
        if rel_humidity < 0.66 * temp + 53:
            weather = 1  # Very likely dry
        elif rel_humidity < 0.66 * temp + 63:
            weather = 2
        elif rel_humidity < 0.66 * temp + 73:
            weather = 3  # Changeable
        elif rel_humidity < 0.66 * temp + 83:
            weather = 4
        elif rel_humidity >= 0.66 * temp + 83:
            weather = 5  # Probably rainy
        return weather
    
    
    def main(argv):
        try:
            opts, args = getopt.getopt(argv, 't:r:', ['temperature', 'relativehumidity'])
            for opt, arg in opts:
                if opt in ('-r', '--relativehumidity'):
                    rel_humidity = float(arg)
                elif opt in ('-t', '--temperature'):
                    temp = float(arg)
        except getopt.GetoptError:
            print 'test.py -r <relativehumidity> -t <temperature>'
            sys.exit(2)
    
        print guess_weather(rel_humidity, temp)
    
    
    if __name__ == "__main__":
        main(sys.argv[1:])

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to Workshopshed

    Andy there is also another trick that in cases like this maybe very useful to test the predictive algorithms: getting a bunch of data from the internet (six months or one year, i.e. two or four seasons) and create a self-destroying database. As day passes the old data in the queue are replaced by the new sampled by the system. As the predictions are not fully reliables the algorithm is refined then as the time passes the old data are replaced by the new reliable ones sampled by the system. This means that starting from day zero you always have a good number of information to develop average time statistics.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 10 years ago in reply to Workshopshed

    Hi Andy.

     

    They use the humidity and temperature to determine the local dew point.

    Once you reach that level, you have a greater potential for precipitation and its fairly reliable.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 10 years ago in reply to mcb1

    Yes, more sensors would make for a better results but I was thinking just having a simple backup for when the net is out.

    Perhaps one of the reasons for decline of the weather house is modern double glazing and central heating. I might find that Hans comes out when you have a shower and Matilda takes an interest when you grill some bacon.

     

    An adaptive algorithm as suggested by Enrico could work and I'd not need to change the arduino code just the python.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube