Jump to content

SkySurveyBanner.jpg.21855908fce40597655603b6c9af720d.jpg

tekkydave

Members
  • Posts

    1,798
  • Joined

  • Last visited

Reputation

1,135 Excellent

1 Follower

Profile Information

  • Gender
    Male
  • Location
    West Yorkshire, UK

Recent Profile Visitors

4,350 profile views
  1. Might be worth putting that on the Duet forum. It's not one I have seen before. What version of DWC do you have. The latest stable version is 3.1.1 with 3.2 out soon. If you are still on 2.x it might be worth considering the upgrade to v3.
  2. The class I posted is part of the aggregation functions in my system. I have a separate logger that just puts raw values into the db with minimal processing for speed. The aggregation functions read from the db and write back things like wind speed & direction concensus that depend on values over a set period. Also I have hourly, daily, monthly, yearly aggregation of temperature, rainfall and wind speed going on in the background. My database is at 1.5Gb already with data going back to 2016. Daily backups happen automatically
  3. I put everything in the same class as it writes them to the database as a single row. You are probably only interested in the direction bits.
  4. If you read Java this is my class package piweather4jv2; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; // Class constructed using instructions at: http://www.beals5.com/wx/faqs.htm public class WindConcensus { public void readWindConcensus(Database db, int dbSensorId, FileManager fm) { List<Double> windDirectionResults; List<Double> windSpeedResults; List<Double> windGustResults; double windSpeed = 0; double windGust = 0; int[] bin = new int[20]; boolean validConcensus = true; Date endDate = new Date(); // endDate of readings = now windDirectionResults = db.getRecentReadings(1, endDate, 900L, "NONE"); // Get all the values from last 15mins windSpeedResults = db.getRecentReadings(16, endDate, 900L, "AVG"); // Get the Average of the values in lat 15mins windGustResults = db.getRecentReadings(16, endDate, 120L, "MAX"); // Get the Maximum of the values in last 2 mins if ((windDirectionResults.size() >= 1) && (windSpeedResults.size() == 1) && (windGustResults.size() == 1)) { // Put windDirectionResults in bins Iterator dirIterator = windDirectionResults.iterator(); while (dirIterator.hasNext()) { double degrees = (double)dirIterator.next(); int sector = ((int) ((degrees + 11.25)/22.5))%16; bin[sector] += 1; //System.out.println("WindConcensus: " + String.valueOf(degrees) + " in sector " + String.valueOf(sector)); } // bins 16 to 19 are same as bins 0 to 3 bin[16] = bin[0]; bin[17] = bin[1]; bin[18] = bin[2]; bin[19] = bin[3]; // Process bin outcome int I = 0; int S = 0; int Smax = 0; for (int i = 0; i < 16; i++) { S = bin[i] + bin[i+1] + bin[i+2] + bin[i+3] + bin[i+4]; if (S > Smax) { I = i; Smax = S; } //System.out.println("bin " + i + " = " + bin[i] + " , sum = " + S); } //System.out.println("I = " + I + ", S = " + Smax); double W = ( bin[I+1] + (2 * bin[I+2]) + (3 * bin[I+3]) + (4 * bin[I+4]) ) * 45.0D / Smax; double D = (((I * 45.0D) + W) % 720)/2; //System.out.println("W = " + W + " , D = " + D); // get windSpeedResults value windSpeed = (double)windSpeedResults.get(0); //System.out.println("WindConcensus: Average Speed = " + String.valueOf(windSpeed)); // get windGustResults value windGust = (double)windGustResults.get(0); //System.out.println("WindConcensus: Gust Speed = " + String.valueOf(windGust)); // Check Validity of Wind Direction and Speed if ((D < 0.0D) || (D >= 360.0D) || (windSpeed < 0.0D) || (windSpeed >= 100.0D) || (windGust < 0.0D) || (windGust >= 100.0D)) { validConcensus = false; } Reading3 windDataReading = new Reading3(new Date(), D, windSpeed, windGust, validConcensus); windDataReading.print("Wind Direction Concensus (" + windDirectionResults.size() + " readings)","Wind Speed","Wind Gust"); if (windDataReading.isValid()) { windDataReading.saveDB(db, dbSensorId); windDataReading.saveFile(fm, dbSensorId); } } else { System.out.println("WindConcensus: No results to process."); } } }
  5. I used the algorithm on this web site for my calculations.
  6. Check you have USB enabled in the VMs settings: and also when you connect a USB device to the host PC select it from the Devices --> USB menu so the VM can capture it from the host.
  7. Isn't the browser fetching data from the esp32? You need to do the same. Try curl maybe.
  8. The very first 1-wire wind-vane I had contained 8 reed switches. It selectively shorted out resistors in a chain to give a 4-bit analogue reading. This was read by a 4-bit 1-wire AtoD chip and the software then used the values to calculate 1 of 16 compass directions. I'll see if I can find the original circuit. Edit: found it! This is pdf so d/l then open up CalculatingWindSpeedAndDirection.PDF
  9. Could a pi be set up to poll the ESPs in turn to get the latest/current values?
  10. Have you considered storing your readings in a database. Then you can split the system into 2 parts; 1. A part based on the ESP32 that simply takes readings & logs raw data to the database 2. A front-end based on a pi or pc that displays the data. This can be more powerful for the processing required. Having the data in a db also allows you to keep a history of your readings. I now have readings going back to 2016 in my weather db.
  11. Do you mean web server or web service? Running a web service on the ESP32 would be a good solution as it can be accessed over the wifi from any other networked device easily. Almost like a one-way MQTT
  12. I think MQTT is definitely worth considering. All you need is a server/broker (RPi?) which is easy to set up. Then you can send messages (data etc) between clients easily. The ESP32 should have an MQTT library and there will be one for whatever language you go with on the indoor side. There are also free sites on the web that you can use as your broker - see CloudMQTT. I have used it just for testing so you can play with the client ends without needing to build the broker. So it might look like this: (WiFi) (WiFi/Eth) Weather Station <------------------> Broker <------------------> Client (RPi or PC?) (ESP32) | (RPi or CloudMQTT) | | | Sensors Dials Some instruction on building a pi based broker: here I would probably go the MQTT route if I started my WS from scratch. I have an RPi in my WS outside as all my sensors are 1-wire and some were quite expensive (rain gauge & wind vane/gauge). I use oww server to make the 1-wire devices connected to the RPi in the WS appear as local devices on the indoor RPi. Then the rest is coded in Java (backend logging to MySQL db) and a PHP/javascript web front-end also on the indoor Pi.
  13. Buck converters are ideal for this. Make sure each one has sufficient current rating and put a fuse on each individual output too
  14. Programming ESP32 via Arduino IDE Note: Also works using Arduino IDE in Linux
  15. ESP8266 only has one analogue input - you need the ESP32 I think The ESP chips can be programmed via the Arduino IDE as if they were arduinos with the addition of a few extensions.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.