Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

Weather Station Ideas


Gina

Recommended Posts

46 minutes ago, Gina said:

I may be wrong but I don't think your for loop gives the right results.  I worked out that the pins needed special numbering viz.  1 2 4 5 6 7 8 9.  Note that 3 had to be left out as we get that with NNE from N + NE (1+2).

Hmmm.  I did just write it off the cuff so it may not be right, but I'll check.

James

  • Thanks 1
Link to comment
Share on other sites

I think it's correct, Gina.    pinValues should end up with a binary representation of the pins set with N as the least significant bit, so if NE and E are set then it should be 00000110 or 6 decimal and W and NW should be 11000000 or 192.  I chose hex for the case statements above because it's easier to think in when you're representing binary values.

Try this as a test program on a Linux machine:

#include <stdio.h>

int main ( int argc, const char* argv[] )
{
	int pinValues, p;
	float windAngle;

	pinValues = 0;
	for ( p = 0; p < 8; p++ ) {
		if ( argv[1][p] == '1' ) {
			pinValues |= ( 1 << p );
		}
	}
	printf ( "pinValues = %02x\n", pinValues );

	windAngle = -1;
	switch ( pinValues ) {
		case 0x01: windAngle = 0; break;
		case 0x03: windAngle = 22.5; break;
		case 0x02: windAngle = 45; break;
		case 0x06: windAngle = 67.5; break;
		case 0x04: windAngle = 90; break;
		case 0x0c: windAngle = 112.5; break;
		case 0x08: windAngle = 135; break;
		case 0x18: windAngle = 157.5; break;
		case 0x10: windAngle = 180; break;
		case 0x30: windAngle = 202.5; break;
		case 0x20: windAngle = 225; break;
		case 0x60: windAngle = 247.5; break;
		case 0x40: windAngle = 270; break;
		case 0xc0: windAngle = 292.5; break;
		case 0x80: windAngle = 315; break;
		case 0x81: windAngle = 337.5; break;
	}

	printf ( "wind angle = %f degrees\n", windAngle );
	return 0;
}

Run the program with a string on the command line that represents the pins that are "on" as "1" in a string of eight characters.  Unhelpfully perhaps, the pin for N is the first character, NE next and NW the last.  So if I compile the program and call it "t", then:

$ ./t 00100000
pinValues = 04
wind angle = 90.000000 degrees

or

$ ./t 00000011
pinValues = c0
wind angle = 292.500000 degrees

but if you set something not valid you get -1 as the wind angle:

$ ./t 00000111
pinValues = e0
wind angle = -1.000000 degrees

There's no obviously other error checking though, so it will bomb if you don't set a value or don't use a long enough string.

James

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

On 28/07/2020 at 18:44, Gina said:

The "pretty" version of the web page.

1089803920_Screenshotfrom2020-07-2817-43-25.png.d1c0f44dac1eb7054a2a6a208cdfb5c8.png

Gina I got mine working today but could not figure out where to put the following command which line do i put it in 

<meta http-equiv="refresh" content="2" >

so the webpage refreshed automatically

greatly appreciated 

Andy

One of the improvements you can do with our code is refreshing the page automatically in order to update the sensor value.

With the addition of a single meta tag into your HTML document, you can instruct the browser to automatically reload the page at a provided interval.

<meta http-equiv="refresh" content="2" >

Place this code in the the <head> tag of your document, this meta tag will instruct the browser to refresh every two seconds. Pretty nifty!

 

 

Link to comment
Share on other sites

If you look at the source for the web in an editor can you find text that starts (very near the beginning of the file) "<head>" and then ends a little further down "</head>" ?

I'd put the text to do the refresh immediately before "</head>".

James

Link to comment
Share on other sites

5 minutes ago, JamesF said:

If you look at the source for the web in an editor can you find text that starts (very near the beginning of the file) "<head>" and then ends a little further down "</head>" ?

I'd put the text to do the refresh immediately before "</head>".

James

James

I tried that do you type is as stated <meta http-equiv="refresh" content="2" >

or with

ptr +="<meta http-equiv="refresh" content="2" > ";

for example my code is as below screen copy from within Arduino IDE as would not compile or am I doing something wrong?

cheers

Andy

 

 

String SendHTML(float temperature,float humidity,float pressure,float altitude){
  String ptr = "<!DOCTYPE html>";
  ptr +="<html>";
  ptr +="<head>";
  ptr +="<title>ESP32 Weather Station</title>";
  ptr +="<meta name='viewport' content='width=device-width, initial-scale=1.0'>";
  ptr +="<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet'>";
  ptr +="<style>";
  ptr +="html { font-family: 'Open Sans', sans-serif; display: block; margin: 0px auto; text-align: center;color: #444444;}";
  ptr +="body{margin: 0px;} ";
  ptr +="h1 {margin: 50px auto 30px;} ";
  ptr +=".side-by-side{display: table-cell;vertical-align: middle;position: relative;}";
  ptr +=".text{font-weight: 600;font-size: 19px;width: 200px;}";
  ptr +=".reading{font-weight: 300;font-size: 50px;padding-right: 25px;}";
  ptr +=".temperature .reading{color: #F29C1F;}";
  ptr +=".humidity .reading{color: #3B97D3;}";
  ptr +=".pressure .reading{color: #26B99A;}";
  ptr +=".altitude .reading{color: #955BA5;}";
  ptr +=".superscript{font-size: 17px;font-weight: 600;position: absolute;top: 10px;}";
  ptr +=".data{padding: 10px;}";
  ptr +=".container{display: table;margin: 0 auto;}";
  ptr +=".icon{width:65px}";
  ptr +="</style>";
  ptr +="</head>";

 

Link to comment
Share on other sites

String SendHTML(float temperature,float humidity,float pressure,float altitude){
  String ptr = "<!DOCTYPE html>";
  ptr +="<html>";
  ptr +="<head>"; <------------------------------------------------- WRONG!!
  ptr +="<title>ESP32 Weather Station</title>";
  ptr +="<meta name='viewport' content='width=device-width, initial-scale=1.0'>";
  ptr +="<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet'>";
  ptr +="<style>";

 

Link to comment
Share on other sites

Ho ho.  There's a nice little "gotcha" there because of the multiple uses of double quotes.  Were it in an HTML file rather than Javascript, it wouldn't matter.

After this line:

ptr +="<meta name='viewport' content='width=device-width, initial-scale=1.0'>";

Try adding:

ptr +="<meta http-equiv='refresh' content='2'>";

(Note that I have changed some of the double quotes to single quotes.)

James

  • Thanks 1
Link to comment
Share on other sites

1 minute ago, Gina said:

String SendHTML(float temperature,float humidity,float pressure,float altitude){
  String ptr = "<!DOCTYPE html>";
  ptr +="<html>";
  ptr +="<head>"; <------------------------------------------------- WRONG!!
  ptr +="<title>ESP32 Weather Station</title>";
  ptr +="<meta name='viewport' content='width=device-width, initial-scale=1.0'>";
  ptr +="<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet'>";
  ptr +="<style>";

 

where do I put the text?

Link to comment
Share on other sites

I've uploaded the sketch to the two new ESP32s I've just bought so this gives me the framework to add my own code and remove what I don't want.  Really it just a test that the Upload works on the two new modules.

Link to comment
Share on other sites

2 minutes ago, Gina said:

String SendHTML(float temperature,float humidity,float pressure,float altitude){
  String ptr = "<!DOCTYPE html>";
  ptr +="<html>";
  ptr +="<head>"; <------------------------------------------------- WRONG!!
  ptr +="<title>ESP32 Weather Station</title>";
  ptr +="<meta name='viewport' content='width=device-width, initial-scale=1.0'>";
  ptr +="<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet'>";
  ptr +="<style>";

 

I'm probably being dumb, Gina.  I am quite tired and it's been a long day, but I can't see why that is wrong.

James

Link to comment
Share on other sites

4 minutes ago, JamesF said:

Ho ho.  There's a nice little "gotcha" there because of the multiple uses of double quotes.  Were it in an HTML file rather than Javascript, it wouldn't matter.

After this line:


ptr +="<meta name='viewport' content='width=device-width, initial-scale=1.0'>";

Try adding:


ptr +="<meta http-equiv='refresh' content='2'>";

(Note that I have changed some of the double quotes to single quotes.)

James

James,

You are the Man. One virtual beer on the way it compiles......🥂

Andy

  • Like 1
Link to comment
Share on other sites

6 minutes ago, Gina said:

Must make sure brain is fully engaged and working before engaging fingers to keyboard!!

If I did that I'd still only have a few hundred posts :D

James

  • Like 1
  • Haha 2
Link to comment
Share on other sites

2 minutes ago, JamesF said:

Excellent :)

James

cheers James and I can confirm that it refreshes. Not being a programmer of any nature but a bain of my life when trying to copy/paste what people write as meaning to work then fails what gives.

but thanks once again

Andy

Link to comment
Share on other sites

As I add stuff to my observatory I continue to add 13.8v to 5v buck converters.  I could be adding 3 more with the weather sensors.  This is making me wonder whether I should add a 5v power bus to my observatory power distribution system.

Link to comment
Share on other sites

7 minutes ago, Gina said:

As I add stuff to my observatory I continue to add 13.8v to 5v buck converters.  I could be adding 3 more with the weather sensors.  This is making me wonder whether I should add a 5v power bus to my observatory power distribution system.

Sounds like it might make sense.  Reducing the component count surely has to increase reliability, as long as you use sufficiently thick cable that it isn't dropping the voltage too much.

James

  • Like 1
Link to comment
Share on other sites

Yes, I was wondering about the cable resistance problem.  I shall have to look into the current requirements.  I think the weather units will be under 100mA.  Mostly the other devices are RPi boards which need around 2A as I recall which adds up.  Maybe it's a case of just running 5v for the weather station units.  These require only 5v and not the 13.8v whereas the imaging systems require both.

Edited by Gina
Link to comment
Share on other sites

If I may for 5v 100mA, quite literally cat 5e cable will carry this all day long. Personally, if this was for external applications like an outside weather sensor you maybe better of using something like a 0.5mm flexible cable. Stranded core cables such as flexibles are better suited to connections where movement may be possible.

Dependant on how it is installed 2.5mm T@E is good for anything between 17 and 27ish amps. The volt drop across 5m, even at 25a will be negligible.

A 0.5mm 2 or 3 core flex will carry 3 amps.

0.75mm is good for 6 amps

 

Edited by steveex2003
Link to comment
Share on other sites

I have a Meanwell 5 v power supply for my sbc's and a usb hub at the foot of my pier, but am actually considering binning that and have one buck converter on the scope. Fewer and shorter cables that way. Btw, it's not just cable resistance, but also contact resistance you have to consider. One more reason I have to bin the 5v supply is cable stiffness. I replaced all my plastic insulated power cables with teflon insulated. These are a bit heavier, especially the thicker ones. So there's more risk for cable drag. The 5v and 12 v cables go up the pier & scope, where I have a 12v and 5v power distribution box. I could put a buck converter in the 5v box and have one less cable to worry about.

Edited by wimvb
  • Like 1
Link to comment
Share on other sites

I have 13.8v fed to my pier with a 16.5A low voltage flexible cable plus thick domestic type earth cable, from the distribution box in the warm room - separate supplies for mount and imaging rig.  I have a network switch on the pier feeding the two RPi control boards and a cable from the mount to one RPi so minimal cables while still using wired Ethernet.  I could probably get away with WiFi but prefer high reliability for imaging.  Except for the ASC which uses WiFi as it's less important. Now if INDI supported the ESP32 I could cut down a lot on power requirements!

Edited by Gina
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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.