Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Stavros Korokithakis
@skorokithakis
it's just two paragraphs, it'll take two seconds :smile:
geman220
@geman220
Ha I already read that page. I meant the other content on your blog =)
Stavros Korokithakis
@skorokithakis
oh right :P
geman220
@geman220
I'm sure it's going to be a headache to get running at first, but it's always fun to learn something new and make something.
Stavros Korokithakis
@skorokithakis
nah, it's trivial, get platformio
mkdir mything
cd mything
platformio init --board=esp12e
<edit your src/main.ino>
platformio run -t upload
done
geman220
@geman220
Is there a way to emulate a program? Or will I have to wait until my ESPs and servo get here
Stavros Korokithakis
@skorokithakis
you'll have to wait, i'm afraid
which nodemcu did you get?
Stavros Korokithakis
@skorokithakis
ah, that's my favorite
geman220
@geman220
I read online it was the best overall
Stavros Korokithakis
@skorokithakis
i should probably buy a few more
yeah it is
geman220
@geman220
I actually did SOME research =P
Stavros Korokithakis
@skorokithakis
haha
geman220
@geman220
Should platformio have made the src/main.ino?
Stavros Korokithakis
@skorokithakis
i don't think it does
just use mine
geman220
@geman220
Ah okay just making sure I didn't miss something
Stavros Korokithakis
@skorokithakis
nope, i think it makes one if you use the blink template
you can use templates, i seem to recall
hey, @ivankravets, can i use a git repo as a template? i'd like to do something like platformio init --from-repo=git@github.com:skorokithakis/wifi-template.git
geman220
@geman220

Where are these includes in your program coming from?

#include "PubSubClient.h"
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <DHT.h>

Do I need to physically get those? Are they just default Arudino IDE libraries? If so I can just look up the included servo library and add it correct?

Stavros Korokithakis
@skorokithakis
oh yes, sec
add to your platformio.ini:
targets = upload
lib_install = 19,89
build_flags = -DMQTT_MAX_PACKET_SIZE=1024
upload_flags = -a OTAPASS
upload_port = 192.168.10.144
it'll download and install the libraries
change otapass to your otapass and the IP to your wifi ip
geman220
@geman220
Sorry, OTA pass? Is that just the wireless password? I was confused about that in the program as well because there is WIFI_PASS is OTA_PASS
Stavros Korokithakis
@skorokithakis
OTA pass is authentication for flashing over wifi
so random people can't just drive by and flash new firmware
running this will make your ESP flashable over wifi
so you don't need to have it connected to the pc
geman220
@geman220
Oh, I see. Makes more sense now
Stavros Korokithakis
@skorokithakis
i need to take some time and write all this up
geman220
@geman220
upload_port = 192.168.10.144 is that generic or will I need to modify that for my subnet

And just so I'm clear in my own head...

[env:nodemcuv2]
platform = espressif
framework = arduino
board = nodemcuv2
targets = upload
lib_install = 19,89
build_flags = -DMQTT_MAX_PACKET_SIZE=1024
upload_flags = -a pass
upload_port = 192.168.10.144

This will download the libraries to the ESP, does this include all included Arduino IDE libraries? So I can add whatever library I want and it will download it to the ESP?

Ivan Kravets
@ivankravets
@skorokithakis hi. We have an issue for that in PlatformIO 3.0
Stavros Korokithakis
@skorokithakis
ah, fantastic
@geman220, you need to change the IP, yes
it'll download everything, yes
you can find libraries with platformio lib search i think
have a look at the docs
geman220
@geman220
And that's the IP of what? Each ESP?
Ivan Kravets
@ivankravets
platformio/platformio#446
geman220
@geman220

I've added:

#include <Servo.h>

and

Servo myservo;  // create servo object to control a servo
int pos = 0;    // variable to store the servo position
void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}
Stavros Korokithakis
@skorokithakis
seems reasonable
each ESP, yes
geman220
@geman220

What's the most logical way to store this so I can just call it in the MQTT section?

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

So when this runs:

    if (command == "forward") {
        motor(1, FORWARD, power);
        motor(2, FORWARD, power);

I could have something like this:

  if (command == "open") {
        myservo(open180);
    }

Or am I off track?