Node.js server for VSOP87 planet calculations #6
Replies: 4 comments
-
Looks really cool, and thanks for the feedback. I'm not really sure what you mean by a Node.js server. My plan for this project is to supply a as bare bones as possible implementation, because as you already discovered, it might require slight tweaks for certain platforms. But I do have many other projects that build off of it. Also, please post some links to your project and 3D files if they're public. |
Beta Was this translation helpful? Give feedback.
-
Once again, many thanks for your extensive code collection, and for publishing it online. My goal is to get the planetary calculations entirely on an ESP32 microcontroller so that I can build standalone things, but running using a REST API hosted on my own network is a pretty good solution for now. Offering a REST API to your website would be a great addition, and a help to amateur astronomers everywhere - a much easier alternative to JPL Horizons. A Node.js server runs Javascipt outside of a browser, in this case to provide a REST API delivering data over WiFi. The code for my example is rather embarrassingly small: here is the entire code of app.js:
To run, you enter "node app.js" at the linux prompt (Node.js must be installed on the host system). calling the REST API from curl produces the current planet positions like this:
I modified your alt_az_small.js to add module exports and call the reduce function like this:
The computePosition function called above is an edit of your testPosition function to populate the json:
Once the Node.js server is running, I can call it from my Home Assistant server or from an ESP32 microcontroller (as shown above). I have not released the Planets Clock on TinkerCAD/Github yet, my Moon Clock is at
Here is a photo of the prototype build of the Planet Clock. My Grandkids already love pushing the button to show the next planet. I'll be posting it on Github/TinkerCAD shortly, if you are OK with a reference to your website. |
Beta Was this translation helpful? Give feedback.
-
Ah. I wouldn't want to get in to running a service, not so much because it's tough to do, but because if it got popular it'd start costing significant money, and I don't care to get in to that side of things. I'm sure if you search around there already are some sites that provide that. But the code should be able to run directly on the ESP32, and eliminate the need for a service. Depending on the language you're using, there is an Arduino folder that has the .ino files for testing the C versions directly. I was able to get the vsop87a_small working on an esp8266. If you're using Micropython or Lua, you should be able to use the Python or Lua code directly. Another option is to use the less accurate ephemeris from the Explanator Supplement to the Astronomical Almanac: https://www.celestialprogramming.com/planets_with_keplers_equation.html It's accurate generally to an arcminute, and is small enough to run even on an Arduino. But it doesn't have the Moon. |
Beta Was this translation helpful? Give feedback.
-
I totally understand about the cost part - when a user runs the Javascript code on your webpage, he is paying for the computing. I will continue to pursue getting the code to work on an ESP32 - it is running ESPHome (a yaml precompiler to C++), which adds quite a bit of overhead to the (Arduino) libraries, but greatly simplifies the concurrent programming of servos, displays, and an embedded web page. I believe I can make the Javascript/C++ versions of your functions look like a (pretty big) custom component, which would also make it available to all users of the Home Assistant Home Automation server. I'll let you know how I do. Thanks again for the help. Regards, |
Beta Was this translation helpful? Give feedback.
-
Greg,
First, thank you for your truly excellent code and website - it is truly a testament to your hard work and "astronomical" effort. As an amateur astronomer and engineer of things, I have found your VSOP87 code invaluable. I have found most astronomy websites extremely cumbersome and inscrutable, and I long desired something much more concise and understandable - I just wanted planet positions and rise/set times for an ESP32 project (A Planet Tracker Clock), and I have managed to build my prototype with your code.
As the title suggests, I was wondering if you have considered a fully-capable Node.js server code for your examples: I have built a basic json server using your example .js files - it is only 30 lines of Javascript !
I had to make some relatively cosmetic changes to your standard Javascript files to make them compatible with Node.js (requires and module.exports, and static rather than function declarations). I used CelestialProgrammingReduce_small.js, vsop87a_small.js, and vsop87a_small_velocities for my implementation. And, I modified the alt_az_small.js example to calculate the planet positions at the current time (and rise/fall times, as in your rise and set webpage) and publish it all in a json.
I poll the Node.js server from my Home Assistant server to get the json data into a dashboard, which looks great (see attached).
![Planets_Screenshot](https://private-user-images.githubusercontent.com/24682344/367613488-a0d8c898-7775-491b-9790-f2e52cb0388b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMzI2ODAsIm5iZiI6MTczOTIzMjM4MCwicGF0aCI6Ii8yNDY4MjM0NC8zNjc2MTM0ODgtYTBkOGM4OTgtNzc3NS00OTFiLTk3OTAtZjJlNTJjYjAzODhiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDAwMDYyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRjOTAyMzZhN2ZjYzE2ODZjZDM2MmE4ZDViYTNiMDExYTgwMjVjYWM1NmMyNmJlNjFhNDE5ZjU1YjJhYTRmMTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.xwD-0sjfnWwxiXZ8-gvb3YbSZQnAdtWD7NIdAWqOeOI)
Finally, I can also get the planetary data into an ESP32 running ESPHome using a http_request (similar to arduino). With a couple of servo motors and a display, I have a Planet Tracker/Clock which can track any of the planets and the Sun/Moon. The LED tracks the planet (Azimuth and Elevation), selected from a built-in web page.
![Planet_Clock](https://private-user-images.githubusercontent.com/24682344/367614699-2109ad5b-a7e6-4a98-92d9-b88a372c4b98.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMzI2ODAsIm5iZiI6MTczOTIzMjM4MCwicGF0aCI6Ii8yNDY4MjM0NC8zNjc2MTQ2OTktMjEwOWFkNWItYTdlNi00YTk4LTkyZDktYjg4YTM3MmM0Yjk4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDAwMDYyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjZTgwMDMzMmM1YzA0NmUwYzdkZmQ4ZjA1YzkwMGIxN2M4YTI2ODliNTE1YjIyZTQyYzk1Y2IyYTI4N2FkNjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.B_ngDTDYLhbhFE_skpDC3v0DiA3_PGxoSuaDSDVHEQE)
I'll be publishing all of the 3D design files on Tinkercad and the project on Thingiverse, where I will be sure to include an acknowledgement for your work. A standalone Node.js server would be the icing on the cake, and make to project into a complete self-contained amateur observatory.
Thanks and regards,
Beta Was this translation helpful? Give feedback.
All reactions