Author Topic: Super low-cost heliostat with ESP8266 for WiFi control  (Read 638 times)

sheffieldnick

  • New Member
  • *
  • Posts: 4
    • View Profile
    • Raspberry Pi, ARM SBCs & computer hackery
Super low-cost heliostat with ESP8266 for WiFi control
« on: March 26, 2017, 03:08:45 AM »
I don't know if this forum is still active, but I'm starting on my own heliostat project and I'd really appreciate any advice that you experienced builders can offer  :)

Video of my prototype mechanical design, based on Gabriel's v2.0 design with lead screws. I don't need a wide range of motion, and I want to try something simple to maximise my chances of getting it working!
https://www.youtube.com/watch?v=fXRA-wfXz5A&feature=youtu.be

Each mirror is roughly 1000x750mm. Simple heliostat using a 5-10kg mirror made from 18mm plywood, CNC-milled into a shallow parabolic curve, reinforcing box metal strips (scrap) on the rear, and mylar film (emergency blanket) PVA glued on the front.

The mount is a 100x100mm timber post, rotating on a 12mm threaded rod through the center. I don't think I need a low-friction bearing, but rather something with the 'right' amount of friction that can be overcome by the stepper motors, while remaining still in the wind when the stepper motors are powered off? I was thinking perhaps drill+glue 100mm of a 200mm threaded rod into the bottom timber post, then run the rod all the way through the top timber post, securing it with a recessed nut at the top, but enough slack to allow the 0..45deg rotation?

Elevation and Azimuth motion provided by 2x NEMA17 stepper motors (purple), with physical limit stops and 4x electronic limit switches (red). The required range of motion is -15deg to +45 deg elevation, and 0 to +45 deg azimuth. I'm planning on using door hinges. Not sure how to attach the screw nuts (purple) so they can pivot freely?

Do I want a counterweight on the other side of the mount, to balance the 5-10kg weight of the mirror?

Controlled by an ESP8266 inside a waterproof case at the rear of the mount, along with 2x EasyDriver motor driver boards and a MPS1584 DC 12V -> +3.3V step-down voltage converter. I've ported Gabriel's Sun Harvester Program to the ESP8266, and added things like deep sleep mode for extra power saving, and fetching time/date with NTP rather than needing a physical real-time clock.

Total cost should be under 50.


Paul L

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #1 on: April 04, 2017, 06:48:20 AM »
Hi Sheffieldnick,

  I would say yes, a counterweight would be a great idea; 10kg is pretty heavy for NEMA17, so if it's not balanced properly, they might have a tough go.  You shouldn't have to worry about wind movement when the steppers are off - the leadscrews are essentially self locking.  I used casters with the wheel taken off for the "screw nuts".  I took pictures and posted them in the forums here: http://cerebralmeltdown.com/forum/index.php?topic=305.msg1583#msg1583

For this design to work properly, you have to have everything plumb and level, with super accurate measurements and as little play in the parts as possible.  If any of those things are off slightly, you'll notice in the end, so take your time and do it right the first time!  Even my best build had a little bit of drift, and I tried damn hard to be accurate.  This is one of the reasons why I think worm gearboxes are the way to go - way less room for user/build error.  But if you're trying to keep costs to a minimum, this is the way to go!

Very cool that you'll be using the ESP8266 and the added features you've added in - it'd be great if you posted your code once you have it all up an running.  Also, ff I recall correctly, the Easy Driver has a 3.3v/5v linear regulator on board for external power supply, so you'd be able to use that to power the ESP8266 rather than the MP1584. 

Best of luck, and keep us posted!


sheffieldnick

  • New Member
  • *
  • Posts: 4
    • View Profile
    • Raspberry Pi, ARM SBCs & computer hackery
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #2 on: April 06, 2017, 12:10:10 PM »
Thanks for all that info Paul - very helpful!  :)

Do you think I'd need an anti-backlash nut on my lead screws? They seem popular on CNC cutters/3D printers, but perhaps that precision isn't needed in this application?

I love your idea of using glued nuts for pivots! Simple and very economical.

I'm sharing all my code with Gabriel as I go along, and I'm hoping that at some point we'll have a single source tree that automatically recognises its hardware, and compiles the correct code for the Uno/Mega/ESP8266.

The EasyDriver board does indeed have its own regulator which can output 3.3V/5V, but apparently it can't manage a high enough current to drive the ESP8266 when it is using WiFi. I also want to completely disable the EasyDriver boards unless I need the motors to move, so for those reasons it makes sense to have the separate MP1584 powering all the logic.

I don't know how practical it will be to run the heliostats off (solar-fed) batteries, but I'm trying to minimise the power requirements so I can hopefully try that in the future.

Cheers

Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 654
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #3 on: April 15, 2017, 10:28:27 AM »
This is a bit of a delayed reply, but you shouldn't need anti-backlash nuts. What would be more helpful is more of a say anti-backlash heliostat. So, the altitude and azimuth motions would be pulled in one direction by say a spring or a weight. That would help eliminate any wobble.

Also, It's something that I don't think I have documented well, but the closer you can keep the mirrors towards the axis of rotation the better. There will always be some drift as they get further and further  away, which may or may not be the reason for Paul's drift.

It's technically something that could be compensated for in the software, but it would add yet one more variable to the settings as I believe that you also need to have the distance to the target programmed in. I haven't gotten around to figuring out the math to compensate for it either.

I don't think it would take much to run a heliostat, or heliostats, off of solar. In the grand scheme of things they don't use much power. All they do is move part of a revolution forward and backward in each axis once a day, which amounts to practically nothing for smallish machines.

I actually managed to pick up a solar kit which even has the outdoor box for the batteries and charge controller for $10 dollars where I work, so I am planning on doing pretty much the same thing. Whenever I finally finish 3D printing all of the parts for it. Only 40 more hours of printing to go. ;)


moritz

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #4 on: May 29, 2017, 01:01:50 AM »
Hi Nick and Gabriel,

I have that bi-weekly maker / diy radio show called "Netzbasteln" on german national public radio Deutschlandfunk Nova. See netzbasteln.de for all past projects. Quite some of them contained an ESP8266, which i really felt in love with. Same goes for the idea of a heliostat which I wanna build in one of the two next shows - which is already next sunday - or also two weeks later. I am really enthusiastic and grateful for the great work you did here, Gabriel!

For my heliostat I already welded the frame (using a bicycle fork), now its up to the motors (will use steppers and Pololu A4998 / 8825 drivers I already used for a CNC and and an Eggbot) and the code. I want to use an ESP8266 (propably Wemos D1 Mini) and program a small webserver on a hotspot that allows you to control everything in a web-browser. Nick wrote:

I'm sharing all my code with Gabriel as I go along, and I'm hoping that at some point we'll have a single source tree that automatically recognises its hardware, and compiles the correct code for the Uno/Mega/ESP8266.


My question: would you mind me (and two friends who are professional programmers and would help) joining this effort and send me the code you are already working on? Guess it would even be best to put it on github and work on it together there! I can do that if you want.

Some work for ESP8266 has already been done - but i assume its a very old version and we should start over anyway:
http://cerebralmeltdown.com/forum/index.php?topic=854.msg3400#msg3400

Many greetings, really looking forward!
Moritz
« Last Edit: May 29, 2017, 01:03:27 AM by moritz »


sheffieldnick

  • New Member
  • *
  • Posts: 4
    • View Profile
    • Raspberry Pi, ARM SBCs & computer hackery
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #5 on: July 28, 2017, 04:03:34 AM »
I thought some of you might like to see my progress with this project - I've been working on the electronics, and I have my own custom PCB! No need for any Arduino or other board. It takes a single DC input 4.75V-28V, and has an ESP8266 for WiFi control, 2 stepper motor drivers (the red EasyDriver boards), and connections for attaching limit switches:



I have a handful of prototype PCBs without any components on - would anyone like one? I can give you a list of the extra bits you'd need to buy, and you'd obviously need to be able to solder (the smallest components are 0805 SMD). The total cost once you've put it together will be less than 20/20/$20. For all the electronics to control a heliostat! It does work, but remember it is a prototype and I'm making no promises  ;) I haven''t got the software finished yet, but you can program it with any code you like using the Arduino IDE and a USB-to-serial adaptor.

3 in the UK, including P&P
5 for mainland Europe, including P&P
$6 for the rest of the world, including P&P

This is what you'd get - just the bare board, no components and no software:



I am planning a new version of the board that I hope to be able to sell already-soldered so you can just plug it in and go.

Cheers
« Last Edit: July 29, 2017, 01:04:43 AM by sheffieldnick »

Paul L

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #6 on: August 06, 2017, 05:17:56 AM »
That looks great, and I'm excited to see it working!  I'd order a board, but I'm strapped for time and have never done SMD before, so I'll have to pass, but I'm interested in buying a fully finished one when you get to that point!  Keep us updated and keep up the good work! 

Just a thought, and it would require a board redesign, buy if you use A4988 driver boards (I think they're similar to the Easy Driver in specs), you could shrink the size of the board (or put 4 drivers on it and control 2 separate heliostats) quite a bit. 
   
Cheers,

Paul

sheffieldnick

  • New Member
  • *
  • Posts: 4
    • View Profile
    • Raspberry Pi, ARM SBCs & computer hackery
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #7 on: August 06, 2017, 03:21:27 PM »
Thanks Paul! :)

If anyone would like to experiment with a prototype board, but is put off by the SMD soldering, I can do that bit for them? Or do all the soldering. Let me know.

The A4988 looks good, I hadn't seen that before. The current board is only 74x67mm (3" x 2.5") so I don't know how useful shrinking it down further would be? I have done a new design that fully integrates 2x A3697 (as used on the EasyDrivers) and the power circuit onto a single board, which would be more compact, but that wouldn't save much money as it is already so cheap.

I think a single board controlling multiple heliostats makes sense when it is expensive, but if you can make the controller cheap enough, it makes the wiring a LOT neater to have one controller per heliostat? You also have fewer problems with signal noise over long cable runs. I'm planning to have 5 heliostats in my back yard, with just a single 12V line powering them.

Cheers

alobo

  • New Member
  • *
  • Posts: 36
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #8 on: November 27, 2017, 11:08:37 AM »
It's been quite awhile since I've been on this forum! I got busy doing other things, but I did end up working a bit more on my heliostat coding afterward. The idea was to have a single ESP8266 controller for every machine, avoiding the need for long wire runs and messing with I/O expanders. I used A4988 stepper motor controllers but I'm sure almost anything could be used.

It ended up that I got my heliostat to:
- connect to WiFi to get network time,
- assign the target using the Blynk app joystick on my phone, and
- save target coordinates to EEPROM.
(Additionally there is a provision to be able to wirelessly reprogram the board, as long as the total program size is half the size of the internal memory. The ESP-12 modules usually have 4MB of memory, so as long as your program is under 2MB it can be reprogrammed over WiFi!)

I'm uploading my code here pretty much as it was when I last looked at it (over a year ago, so I'm not entirely sure what it looks like ...), and I'd made quite a few modifications without commenting but I hope it's readable. It should compile and run directly on the ESP12 board. Give it a shot and see (modify necessary variables like WiFi name/password, I/O pins etc)

And get familiar with Blynk because it'll really help to add functionality without needing more hardware connections. (Another option is RoboRemo, but I've never used it. Heard good things about it, so keep it in mind if Blynk doesn't work for you.)
« Last Edit: November 27, 2017, 11:18:05 AM by alobo »

Paul L

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #9 on: November 27, 2017, 10:12:47 PM »
Hey Alobo,

Thanks for sharing your code; you've inspired me to go out and buy my first ESP8266 - I can't believe how affordable they are!  Now I just have to find the time to use it! Thanks again!  When I get around to playing with it, I'll post an update here!

Cheers,

Paul 

alobo

  • New Member
  • *
  • Posts: 36
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #10 on: December 01, 2017, 08:29:47 PM »
It's great feeling to set up the ESP-12 board from scratch (all you need is 3.3V regulator, capacitor, 3 resistors, 2 switches, and a header for hooking up your FTDI programmer) as compared to building an Arduino board from scratch! You can program it many times faster than the Arduino, too (which is important considering how much program memory it has). I have my IDE set to 921600 baud programming speed, whereas the typical max Arduino upload speed is 115200. And Wi-Fi programming, when it doesn't fizzle, is even faster!

But to speed things up, I will recommend you find a NodeMCU breakout board, these usually come with an ESP-12 already soldered on, with built-in USB/FTDI and regulator. In other words, with a NodeMCU you buy it, plug it in and start programming immediately!
Saves a lot of effort for a minor increase in cost (and you won't have to deal with the 2mm header spacing of the raw ESP-12 module).
However, there can sometimes be minor confusion regarding the 'NodeMCU' pinout vs the 'ESP12' pinout so always have a reference handy like this one.

The NodeMCU was designed as a Lua-based device, but it functions perfectly well in the Arduino IDE! Hell, there's even a version of Python that'll fit on the ESP-12.
... But I digress.

Get yourself a NodeMCU and download the Blynk libraries into Arduino, and I can almost guarantee you that could have your phone talking to the ESP-12 within, like, half an hour (depending on your coding skill). :-)

Paul L

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #11 on: December 01, 2017, 09:34:50 PM »
Thanks for the guidance Alobo!

   I somehow (dumb)lucked out and actually ordered a NodeMCU, so I'm on my way, the easy way!  Woohoo!  (For those wondering, i got it off Aliexpress.com for 2.81 USD - insanely cheap!)  Thanks for the heads up on the possible confusion on the pinouts - it would have probably scuttled me, but honestly, now I'm a little worried about the mention of coding proficiency, of which I have none.  I have a feeling it'll be a steep learning curve, since I haven't touched anything code related in a few years!! :)

Cheers,

Paul
« Last Edit: December 01, 2017, 09:39:20 PM by Paul L »

alobo

  • New Member
  • *
  • Posts: 36
    • View Profile
Re: Super low-cost heliostat with ESP8266 for WiFi control
« Reply #12 on: December 02, 2017, 11:17:25 AM »
You'll manage as long as you have minimal programming chops, and I'm sure it'll come back to you quickly! Blynk is insanely easy to use considering just how much you can do with it. Interpreting my heliostat code is where it might get hairy though ... I was looking through it myself and almost couldn't remember what I'd done!

Follow the instructions on the GitHub pages as closely as you can. ESP8266-Arduino here and Blynk here

Tips:
- be sure to select the correct COM port in the Arduino IDE, and set the programming speed to maximum (921000 baud)
- you'll need to enter an additional source into the Arduino 'boards manager' and install the under-the-hood components that allow you to program the ESP8266 directly.
- Blynk uses hard-coded 'auth token' strings to make sure it communicates with the correct device over the Internet. Keep track of yours, they are generated each time you open a new project in your Blynk phone app.

Start off with the easy Arduino example of 'blink an LED', and then you can move on pretty much immediately to 'blink an LED with Blynk' from the phone app. It's insanely simple - hell, you could even skip the basic Arduino examples entirely and start directly in Blynk using their example code.
In the example below, simply insert your Wifi name/password, and the auth token provided from the Blynk phone app, and upload as-is to the NodeMCU, then plug in a LED to any of the GPIO pins.
Then open your phone app, pull up a 'button' module in the project, assign it to the pin you have the LED connected to ... and press play! You're done - the LED should light up pretty much immediately as you touch the button. Wireless control in under 10 minutes and 10 lines of code! (ignoring the comments and spaces, obviously). They've seriously done some amazing magic behind the scenes of Blynk. (Hell, I should be getting paid for how much I tell people about it!)

Code: [Select]
#include <ESP8266WiFi.h> // can't connect to Wi-Fi without this
#include <BlynkSimpleEsp8266.h> // can't do Blynk magic without this

char auth[] = "YourAuthToken";  // You should get an Auth Token in the Blynk phone app, when you open a new project.

// Your WiFi credentials.
char ssid[] = "insert_wifi_name_here";
char pass[] = "insert_wifi_password_here";

void setup() {
  Blynk.begin(auth, ssid, pass);
}

void loop() {
  Blynk.run();
}
« Last Edit: December 02, 2017, 11:19:06 AM by alobo »