-
Posts
1,798 -
Joined
-
Last visited
Content Type
Profiles
Forums
Gallery
Events
Blogs
Posts posted by tekkydave
-
-
19 minutes ago, Gina said:
I'm not using a database yet. Also, I'm not familiar with Java and using C++ (Arduion IDE). I like a compiled language.
I think I shall keep direction and speed data and functions separate as this aids debugging.
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
- 1
-
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.
- 1
-
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."); } } }
- 1
-
I used the algorithm on this web site for my calculations.
- 1
-
19 minutes ago, Gina said:
I don't have Windows at all other than in a Virtual Box on the Mint machine and I've never got USB to work from that.
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.
- 1
-
Isn't the browser fetching data from the esp32? You need to do the same. Try curl maybe.
-
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
-
Could a pi be set up to poll the ESPs in turn to get the latest/current values?
-
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.
-
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
-
10 hours ago, jiberjaber said:
My experience with the ESP8266 was the web service and dealing with interrupts for the wind and rain didn't mix. Might be OK with the '32 but this is why I went for MQTT
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.
- 1
- 1
-
Buck converters are ideal for this. Make sure each one has sufficient current rating and put a fuse on each individual output too
- 1
- 1
-
Programming ESP32 via Arduino IDE
Note: Also works using Arduino IDE in Linux
- 1
-
3 minutes ago, Gina said:
Yes. I thought the ESP8266 was just a WiFi adapter hadn't thought of it as a microprocessor as well. I will want one digital and 4 analogue inputs or maybe 9 digital inputs depending on how I implement the wind vane sensor. OTOH that encoder chip only needs 3 data lines (SPI or I2C forget which).
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.
- 1
-
The ESP32 seems endowed enough for a weather station:
- 18 Analog-to-Digital Converter (ADC) channels
- 10 Capacitive sensing GPIOs
- 3 UART interfaces
- 3 SPI interfaces
- 2 I2C interfaces
- 16 PWM output channels
- 2 Digital-to-Analog Converters (DAC)
- 2 I2S interfaces
- 1
-
Why do you need nano as well as the ESP8266? Is it just a lack of I/O pins on the ESP?
-
1 minute ago, Gina said:
Thanks Dave. Interesting but a) I don't want to spend that much money and b) prefer to make my own.
Appreciate that but I thought those sensor chips look interesting to have a play with 😮
- 1
-
Maybe it uses one of these.
- 1
-
I have had one of these inspeed eVane wind vanes for many years now. Claims to use a Hall effect sensor but I'm not sure how they get the analogue output as a proportion of the input voltage. It works great with 1-wire AtoD to give a very accurate reading to less than 1 degree resolution. It's a sealed unit so I'm in the dark about how it works internally.
- 1
-
You do realise you are now on two slippery slopes; astro and 3d printing 😱😊
- 1
- 1
-
Not sure why he wants to build it on stilts!
-
14 hours ago, tekkydave said:
Well spotted. I might get some of those
2 on order
- 1
-
Well spotted. I might get some of those
-
3D Printer Error with Duet WiFi, Firefox and JavaScript
in DIY Astronomer
Posted
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.