Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
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?

geman220
@geman220
I'll have to wait for my servo to get here but I think the code is
// Receive a message from MQTT and act on it.
void mqttCallback(char* chTopic, byte* chPayload, unsigned int length) {
    chPayload[length] = '\0';
    String payload = String((char*)chPayload);

    String command = getValue(payload, ' ', 0).c_str();
    int power = getValue(payload, ' ', 1).toInt();

    mqttPublish(LOG_TOPIC, String("Command ") + command + String(" received."));

    if (command == "open") {
        myservo.write(180);
    } else if (command == "close") {
        myservo.write(0);
    }
}
Stavros Korokithakis
@skorokithakis
that looks reasonable, i've never used a servo so i don't know, but i assume the first goes to 180' and the second back to 0'
geman220
@geman220
Yea what I've read online is the max setting is 180 and the lowest setting is 0. I can remove the potentiometer if I need to and setting it to 180 will essentially rotate it right forever and 0 will rotate it left forever. If I need to remove the potentiometer I'll have to add something like
    if (command == "open") {
        myservo.write(180);
        delay(2000);
    } else if (command == "close") {
        myservo.write(0);
        delay(2000);
    }
I think at least
Stavros Korokithakis
@skorokithakis
@ystrem i've been wanting a gsm module, have you used it?
@geman220 if you only need to rotate to 180 degrees, i think keeping the potentiometer would be good
@geman220 the servos i got could rotate with accuracy forever
so they can rotate for 1000 degrees if you want
ystrem
@ystrem
@skorokithakis nope
Stavros Korokithakis
@skorokithakis
@ystrem hmm, i got one that's more ready-to-use, it had a sim card slot, antenna, etc
but that looks interesting
geman220
@geman220
@skorokithakis I plan to leave the potentionmeter unless I need it to rotate more. Or I'll buy a new servo that has full rotation
Stavros Korokithakis
@skorokithakis
@geman220 yeah, i think that's a better solution
@geman220 how many D1s did you get?
geman220
@geman220
10
Stavros Korokithakis
@skorokithakis
haha, great
i was going to tell you to get 3-4 because you might fry a few, but 10 is good
geman220
@geman220
I need 6 to work on my first order so I can get downstairs completed. I need 10 total so if I'm lucky I don't fry any, if I'm unlucky I have 4 spare and I can make a second order

@skorokithakis so I hacked up your code and I do realize there is a lot of dead useless code now but I don't want to remove anything until I can test and go step by step through my "cleaning" here is what I have https://www.pastery.net/zegxhg/ . Notice anything that is glaringly wrong? Also to verify

WiFiClient wclient;
char COMMAND_TOPIC[] = "rccar/" NAME "/command";
char STATE_TOPIC[] = "rccar/" NAME "/state";
char LOG_TOPIC[] = "rccar/" NAME "/log";

Command_topic would be rccar/command so rccar is the name and command is the topic correct?

geman220
@geman220
And don't I need a username / password to connect to the MQTT topic?
Stavros Korokithakis
@skorokithakis
oh sorry
hmm
that's the old code
i replaced rccar
sec
that's the problem with not having a library
i have to hunt down the latest version of this code
project name is something like "shutters"
instance name is something like "living room"
mqtt auth will change depending on your setup, mine is on my lan, so i don't have it authed
hmm
geman220
@geman220
I could set up MQTT on my LAN. Right now I use HASS and CloudMQTT but HASS has a built in local MQTT so I could just move to that
I only use MQTT currently for device tracking so no big deal
char COMMAND_TOPIC[] = PROJECT_NAME "blinds" INSTANCE_NAME "/command";
char STATE_TOPIC[] = PROJECT_NAME "blinds" INSTANCE_NAME "/state";
char LOG_TOPIC[] = PROJECT_NAME "blinds" INSTANCE_NAME "/log";
So in MQTT I make the name "blinds" and the topic inside of blinds command, state, and log. Correct?
geman220
@geman220
Or I could just install Mosquitto
Stavros Korokithakis
@skorokithakis
just define the vars