Forum Replies Created

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • in reply to: Second Sensor for One Door 2 Car #873

    penright
    Participant

    @lawrence_jeff the 2.2k worked like a champ as expected. So now I had confidence, I tried my 200 ohm and it worked. I will stay with the 2.2k, but not sure what I had wrong. Looks like we can use the single pin mode. Cool thing is we can pass the same pin for both parameters to the read_dianstance.

    in reply to: Second Sensor for One Door 2 Car #872

    penright
    Participant

    Thanks for sanity check. 🙂

    My assortment of resistors are at work. All I have today are a few led current limiting and putting them in series was not enough. I will test it, which I am sure it will work, when I can get access to them, maybe Monday.

    My first thought was maybe the pin mode could not switch fast enough. I tested some delays, still did not work.

    Switching thoughts for a second. I been digging through your code trying to get my bearings. Also I read the post on mqtt.
    I like the direction with the drop down box, switching function of the input pin.
    Looking at MCP23017 16-Bit-I-O-Expander-with-I2C

    I have two different train of thoughts. 1 is like above select a combinations of sensors or level of configurations.

    Level of Configuration
    What about 2 Categories of drop down boxes.
    1. Hardware OG/NodeMCU without expander,NodeMCU with expander
    2. List of supported Sensors and what pin they are on.
    The pseudo logic would be for example Hardware OG, All the second group will be hidden and would expect the OG hardware. The NodeMCU* would expect custom hardware. This still does not keep someone from hacking the OG hardware, but by definition it would be custom at that point.

    What do you think about having a discussion over skype or facetime? I like to keep all the discussion public, but some of what i am calling discussion details are really tedious for here. I just want to help ever how you think it should go.
    If you are interested PM me.

    in reply to: Second Sensor for One Door 2 Car #868

    penright
    Participant

    Sorry took so long, setting up the home network. Never had access to a public IP before, I was behind 2 or 3 different NAT with the hotspot.
    Anyway, tried the 3 wire again. Not sure what I am missing, maybe a second set of eyes.

    So I cut the read_distance and read_distance_once straight from the OG. Then I call the read_distance from the loop. One sensor.
    If I wired it for 4 wires I pass the correct PIN_TRIG/PIN_ECHO. If I wired it for 3 wires then I pass the same pin (PIN_TRIG/PIN_TRIG).
    You can see where I can comment/uncomment to switch back and forth. Three wire gives me all zeros. It’s almost like the pin mode is not switching. I am linking to some pictures, but I don’t know if they are good enough to help.
    Do you have something you could try and see if you get same results? Not sure if it matters, I am using a NodeMCU V3.

    
    /** GPIO pins */
    #define PIN_RELAY  15 //D8
    #define PIN_BUTTON  0
    #define PIN_TRIG   12 //D6
    #define PIN_ECHO   14 //D5
    #define PIN_LED     2
    #define PIN_RESET  16
    #define PIN_BUZZER 13 //D7
    #define PIN_JP2_4  5 //Jumper 2 ping 4 which is GPIO 5 d1
    #define PIN_JP2_3  4 //Jumper 2 ping 3 which is GPIO 4 d2 (Reserved for switch primary door)
    #define PIN_JP2_6  0 //A0
    #define pingPin    PIN_TRIG
    
    void setup() {
      // put your setup code here, to run once:
       Serial.begin(115200);
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      Serial.print("Distance 1 ");
      //uint dist = read_distance(PIN_TRIG,PIN_ECHO); //Works
      uint dist = read_distance(PIN_TRIG,PIN_TRIG); //Returns 0
      
      Serial.print(dist);
      Serial.println("");
      delay(1000);
    }
    
    long read_distance_once(int TRIG, int ECHO) {
      //TODO handle max value as handled error in the UI - check long distance for car detection
      
      pinMode(TRIG,OUTPUT);
      digitalWrite(TRIG, LOW);
      delayMicroseconds(2);
      digitalWrite(TRIG, HIGH);
      delayMicroseconds(10);
      digitalWrite(TRIG, LOW);
      pinMode(ECHO,INPUT);
      // wait till echo pin's rising edge
      unsigned long quit_time=micros()+26233L;
      while((digitalRead(ECHO)==LOW)&& (micros()<quit_time));
      {//Do nothing
      };
      unsigned long start_time = micros();
      quit_time=start_time+26233L;
      //wait till echo pin's falling edge
      while((digitalRead(ECHO)==HIGH) && (micros()<quit_time));
      ulong lapse = micros() - start_time;
      if (lapse>26233L) lapse = 26233L;
      //DEBUG_PRINTLN(F("Distance issue, setting to low value"));
      //DEBUG_PRINT(lapse);
      Serial.print(" lapse ");
      Serial.print(lapse);
      Serial.print(" ");
      return lapse;
    }
    
    uint read_distance(int TRIG, int ECHO) {
      byte i;
      unsigned long _time = 0;
      // do three readings in a roll to reduce noise
      byte K = 3;
      for(i=0;i<K;i++) {
        _time += read_distance_once(TRIG, ECHO);
        delay(50);
      }
      _time /= K;
      //echo_time = _time;
      return (uint)(_time*0.01716f);  // 34320 cm / 2 / 10^6 s
    }

    4 Wire
    3 Wire

    in reply to: Second Sensor for One Door 2 Car #843

    penright
    Participant

    I have not figured this sites markdown and style conventions yet, so I just guessing.

      Are you powering the sensor with 5v or 3.3?

    5V

      My code uses the 3 wire mode as in the URL you sited

    Ok, let me make another run at it. My code is on my mac at home. Just to be clear, I am using the read distance and read distance once functions from the OG class. I am passing the same pin number for the Trigger and Echo. Let me do some work and I will post the code and pictures of my breadboard if I can’t get it to work.

    BTW, I sent you a couple of pull requests that fixes ap_home and compiled the html2esp code for macbook.
    AND
    I hope to have some time to spend on it tonight. Today is an exciting day. Leaving work early to get my house connected to fiber. Maybe hard to believe there are houses in America without internet. All I had was a cell hotspot. The cable, phone, and such said our town did not have the density. So our neighborhood is part of a pilot that the city is bringing the infrastructure and will contract out the supply. Just like they do with gas and trash. So my bill will have a line item for water, sewer, gas, trash, and internet.

    in reply to: Second Sensor for One Door 2 Car #837

    penright
    Participant

    @lawrence_jeff Thanks. Bottom line on the sonic sensors. After a bit of testing, 2 can share the same trigger. I think even though the transmitters are firing at the same time, if they are close they act as one transmitter. I found angling a hard surface played with the readings more than how close they were. The thing I could not get to work is wiring a 4 pin HC-SR04 like a 3 pin sharing the trigger and echo such as http://andrewjkramer.net/ultrasonic-sensors/ In hindsight not sure how that would work, would not the echo single trigger the “trigger”?
    Anyway, I am now trying to dig into how you are using JP2 (3,4,6) / Options (23,24). I also bought a mag switch. I wonder about using it for door open and the two distance for cars preference. That way the home automations can make better decisions.
    Some of my parts are starting to roll in now, still missing some. Thats ok, it will take my some time to digest the code.

    in reply to: WPA2-Enterprise? #795

    penright
    Participant

    @keymaster, Still trying to find out for sure, but for now looks like there is a bug.
    Been emailing Holien, the step to hack the libwpa2.a file, If I understand right, is because espressif did not wire the user name.
    And espressif only distributes binary libraries, we have to wait for them to fix it.

    in reply to: WPA2-Enterprise? #793

    penright
    Participant

    Well I have have one and I am willing to test.

    Using Hallgeir Holien instruction I did get it to connect to the one in our building.
    Here is a thread of my trials

    My biggest issue was how to convert Holien instructions into windows.
    There could be still one issue. Holien instructions have you hack the libwpa2.a file. You have to change the [email protected] to your email address.
    I wonder why that is not part of config parameters?

    I going to see if I can keep OG from trying to config WIFI and see if it works otherwise.

    After following his instructions here is my hello world.

    
    extern "C" {
    #include "user_interface.h"
    #include "wpa2_enterprise.h"
    }
    #include <Arduino.h>
    #include <ESP8266WiFi.h>
    #include <ESP8266HTTPClient.h>
    
    // SSID to connect to
    static const char* ssid = "MySSID";
    // Username for authentification
    static const char* username = "MyUserName";
    // Password for authentification
    static const char* password = "MyPassword";
    const int ledPin = 0;
    
    void setup() {
    Serial.begin(115200);
    pinMode(ledPin, OUTPUT);
    
    Serial.print("Tryingonnect to ");
    Serial.println(ssid);
    
    wifi_station_disconnect();
    
    wifi_set_opmode(STATION_MODE);
    struct station_config wifi_config;
    
    memset(&wifi_config, 0, sizeof(wifi_config));
    strcpy((char*)wifi_config.ssid, ssid);
    strcpy((char*)wifi_config.password, password);
    wifi_station_set_config(&wifi_config);
    
    wifi_station_clear_cert_key();
    wifi_station_clear_enterprise_ca_cert();
    
    wifi_station_set_wpa2_enterprise_auth(1);
    wifi_station_set_enterprise_username((uint8*)username, strlen(username));
    wifi_station_set_enterprise_password((uint8*)password, strlen(password));
    wifi_station_connect();
    
    Serial.print("Status: ");
    Serial.println(wifi_station_get_connect_status());
    
    // Wait for connection AND IP address from DHCP
    while (WiFi.status() != WL_CONNECTED) {
    delay(2000);
    Serial.print("Status: ");
    Serial.print(wifi_station_get_connect_status());
    Serial.print("  IP: ");
    Serial.println(WiFi.localIP());
    }
    
    // Now we are connected
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
    
    } // setup
    
    void loop() {
    }
    in reply to: Compile OG failed looking for OpenGarage.h #789

    penright
    Participant

    My last couple of post have disappeared. I did get my HC-SR04 working. Then I did get it working with OG. Then I downloaded

    that @lawrence_jeff posted above. Got it working.

    Before I go to my next step, I want to mention that this project is not only teaching me ESP2866, how to compile, but also Github and pull request. It’s like going from 0 to 100 in 6 sec. Thanks in advance for the instruction.

    So our building has 3 SSID (Red, Blue, White). The Red is WPA Enterprise, which by the way is what my HA is connected to. So what will it take to connect to WPA Enterprise. I did find this thread for a feature request here

    . First question is it possible? If yes then what would it take to implement it into OG. Lets answer the first question, it could make everything else moot.
    After some searching I think the answer is yes. Since this thread was about compiling errors and where to put the OpenGarage.h, I going to use the WPA2 Enterprise thread for the first question. Then start a new thread on what it takes to implement a feature into OG.

    in reply to: WPA2-Enterprise? #788

    penright
    Participant

    Is this the support that is needed …

    I will start working on a hello world .ino to test the lib, but if it works then who can wire it into the OG app?

    in reply to: Compile OG failed looking for OpenGarage.h #780

    penright
    Participant

    I would recommend starting with my fork

    Thanks.
    I will do that.
    I had to put a lot of debug for me. My board is only a meg flash. So now I learned about flash memory and SPIFS. 🙂

    Right now I am waiting for my parts. I did have a dev board that had buzzer, led’s, relay, … But of course they are not pin the same. I did have some HC-SR04 that I bought laying around. I had someday envision using them for car sensing. Right now my Home Automation (HA) is Almond+. I am looking to switch to Home Assistant (HASS).
    HASS uses openzwave (OZW) for it’s zwave. OZW has a bug with barrier. That is when I found OpenGarage (OG).

    So, I have reassign the pin’s to fit my dev board.Everything works except for the HC-SR04. I cut the distance code out of OG and created a hello world .ino sketch. I may have a bad HC-SR04, it never toggles the echo line. I wish I had a scope :-). Anyway I had to put it away for today and get to my day job. Probably be Monday before I can look at it again. I need to google some on the HC-SR04 and make sure I am hooking it up right.

    • This reply was modified 7 years, 2 months ago by penright.
    in reply to: Compile OG failed looking for OpenGarage.h #773

    penright
    Participant

    I ran accross this post

    In it there was this line Also, copy Updater.h and paste it into C: |Users | (name of your computer user) | AppData | Local | Arduino15 | packages | esp8266 | hardware | esp8266 | 2.2.2 | cores
    Now I can verify/compile without errors.

    in reply to: Compile OG failed looking for OpenGarage.h #769

    penright
    Participant

    I have an update. I thought about editing the my original post, after further thought I will leave it in case someone else makes the same mistakes.

    As I suspected it was the directory tree. Since I am new to Github/Arduino/microcontroller world/C++/… Still building my skeleton little on starting to flesh it out.
    So the 3 steps were 60,000 foot and assumed more than basic knowledge.
    So when I found OpenGarage.h, then I had to figure out why IDE was not finding it. Found some examples on other sketch, moved the the OpenGarage folder into my ..\Arduino\libraries directory, then I got past that error and to the next one .

      C:\Users\Bradmin\Documents\Arduino\libraries\OpenGarage\main.cpp: In function ‘void on_sta_upload_fin()’:
      C:\Users\Bradmin\Documents\Arduino\libraries\OpenGarage\main.cpp:533:12: error: ‘class UpdaterClass’ has no member named ‘reset’
      Update.reset();

    So I found this read me in the Modification directory.

    This folder contains modifications to files in other libraries. Copy these files to the corresponding folders to overwrite the existing files there, or make changes according to the description below.
    * Updater.h: (under esp8266/x.x.x/cores/esp8266 folder)
    Added a public reset function to allow OTA update to abort and reset upon error.

    I can’t find the “exp8286” directory

    • This reply was modified 7 years, 2 months ago by penright.
    • This reply was modified 7 years, 2 months ago by penright.
    • This reply was modified 7 years, 2 months ago by penright.
Viewing 12 posts - 1 through 12 (of 12 total)