Parking Sensor


  • Admin


  • Admin

    Video added


  • Hero Member

    @hek That is awesome!


  • Hardware Contributor

    Excellent!


  • Hero Member

    @hek Ultra cool!!!!



  • @hek Cool I figured you would come up with a practicle use for that LED ring! πŸ˜„


  • Hardware Contributor

    OK - that is very cool. My wife has just decided we have to have this (after she lightly crushed one of my garage cabinets of course).



  • Really cool project, IΒ΄m ordering today πŸ™‚


  • Hero Member

    awesome!



  • Awesome project but will the led always be on when your car is parked?
    Or is there a timeout after the measurement to switch it of?


  • Admin

    @Sander-Stolk

    Ha, yes, didn't think of that little detail.

    Guess you could add a timeout which turns off the leds after a minute when "parked".



  • @hek About to make this sensor, very cool! I had already brought a 12v traffic light before I saw this, so now ordered an LED ring, as that makes a lot more sense getting closer to the target area. But could you help out regarding the implementation of the timeout, as I'm pretty terrible at programing πŸ™‚



  • Super πŸ‘ πŸ‘



  • Great! This will be my first project with Arduino!
    Could you, please, post the wiring schematics.
    Thanks!


  • Admin



  • @hek Great Job. Just wondering if you could point us to instructions on to add the time out feature.

    Thanks!


  • Admin

    My rig is disassembled now.

    You could add timeout like this (please feedback if it works so I can check it into github):

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Created by Henrik Ekblad
     * 
     * DESCRIPTION
     * Parking sensor using a neopixel led ring and distance sensor (HC-SR04).
     * Configure the digital pins used for distance sensor and neopixels below.
     * NOTE! Remeber to feed leds and distance sensor serparatly from your Arduino. 
     * It will probably not survive feeding more than a couple of LEDs. You 
     * can also adjust intesity below to reduce the power requirements.
     * 
     * Sends parking status to the controller as a DOOR sensor if SEND_STATUS_TO_CONTROLLER 
     * is defined below. You can also use this _standalone_ without any radio by 
     * removing the SEND_STATUS_TO_CONTROLLER define.
     */
    
    #define SEND_STATUS_TO_CONTROLLER  // Put a comment on this line for standalone mode
    
    #include <Adafruit_NeoPixel.h>
    #include <NewPing.h>
    
    #ifdef SEND_STATUS_TO_CONTROLLER
    #include <SPI.h>
    #include <MySensor.h>
    #endif
    
    #define NEO_PIN      4 // NeoPixels input pin
    
    #define TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
    #define ECHO_PIN     5  // Arduino pin tied to echo pin on the ultrasonic sensor.
    
    #define NUMPIXELS      24 // Number of nexpixels in ring/strip
    #define MAX_INTESITY   20  // Intesity of leds (in percentage). Remeber more intesity requires more power.
    
    // The maximum rated measuring range for the HC-SR04 is about 400-500cm.
    #define MAX_DISTANCE 100 // Max distance we want to start indicating green (in cm)
    #define PANIC_DISTANCE 5 // Mix distance we red warning indication should be active (in cm)
    #define PARKED_DISTANCE 20 // Distance when "parked signal" should be sent to controller (in cm)
    
    #define PARK_OFF_TIMEOUT 20000 // Number of milliseconds until turning off light when parked.
    
    // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
    // example for more information on possible values.
    
    Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEO_PIN, NEO_GRB + NEO_KHZ400);
    
    NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
    
    #ifdef SEND_STATUS_TO_CONTROLLER
    #define CHILD_ID 1
    MySensor gw;
    MyMessage msg(CHILD_ID,V_TRIPPED);
    #endif
    unsigned long sendInterval = 5000;  // Send park status at maximum every 5 second.
    unsigned long lastSend;
    
    int oldParkedStatus=-1;
    
    unsigned long blinkInterval = 100; // blink interval (milliseconds)
    unsigned long lastBlinkPeriod;
    bool blinkColor = true;
    
    // To make a fading motion on the led ring/tape we only move one pixel/distDebounce time
    unsigned long distDebounce = 30; 
    unsigned long lastDebouncePeriod;
    int numLightPixels=0;
    int skipZero=0;
    
    void setup() {
      Serial.begin(115200);
      Serial.println("Starting distance sensor");
      pixels.begin(); // This initializes the NeoPixel library.
      Serial.println("Neopixels initialized");
    #ifdef SEND_STATUS_TO_CONTROLLER
      gw.begin();
      gw.sendSketchInfo("Parking Sensor", "1.0");
      gw.present(CHILD_ID, S_DOOR, "Parking Status");
    #endif
    }
    
    void loop() {
      unsigned long now = millis();
      
      int fullDist = sonar.ping_cm();
    //  Serial.println(fullDist);
      int displayDist = min(fullDist, MAX_DISTANCE);
      if (displayDist == 0 && skipZero<10) {
        // Try to filter zero readings
        skipZero++;
        return;
      }
      // Check if it is time to alter the leds
      if (now-lastDebouncePeriod > distDebounce) {
        lastDebouncePeriod = now;
    
        // Update parked status
        int parked = displayDist != 0 && displayDist<PARKED_DISTANCE;
        if (parked != oldParkedStatus && now-lastSend > sendInterval) {
          if (parked)
            Serial.println("Car Parked");
          else
            Serial.println("Car Gone");
    #ifdef SEND_STATUS_TO_CONTROLLER
          gw.send(msg.set(parked)); 
    #endif
          oldParkedStatus = parked;
          lastSend = now;
        }
    
        if (parked && now-lastSend > PARK_OFF_TIMEOUT) {
          // We've been parked for a while now. Turn off all pixels
          for(int i=0;i<NUMPIXELS;i++){
            pixels.setPixelColor(i, pixels.Color(0,0,0)); 
          }
        } else {
          if (displayDist == 0) {
            // No reading from sensor, assume no object found
            numLightPixels--;
          } else {
            skipZero = 0;
            int newLightPixels = NUMPIXELS - (NUMPIXELS*(displayDist-PANIC_DISTANCE)/MAX_DISTANCE);
            if (newLightPixels>numLightPixels) {
              // Fast raise
              numLightPixels += max((newLightPixels - numLightPixels) / 2, 1);
            } else if (newLightPixels<numLightPixels) {
              // Slow decent
              numLightPixels--;
            }
          }
      
          if (numLightPixels>=NUMPIXELS) {
            // Do some intense red blinking 
            if (now-lastBlinkPeriod > blinkInterval) {
              blinkColor = !blinkColor;
              lastBlinkPeriod = now;
            }
            for(int i=0;i<numLightPixels;i++){
              pixels.setPixelColor(i, pixels.Color(blinkColor?255*MAX_INTESITY/100:0,0,0)); 
            }              
          } else {
            for(int i=0;i<numLightPixels;i++){
              int r = 255 * i/NUMPIXELS;
              int g = 255 - r;     
              // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
              pixels.setPixelColor(i, pixels.Color(r*MAX_INTESITY/100,g*MAX_INTESITY/100,0)); 
            }
            // Turn off the rest
            for(int i=numLightPixels;i<NUMPIXELS;i++){
              pixels.setPixelColor(i, pixels.Color(0,0,0)); 
            }
          }
        }
        pixels.show(); // This sends the updated pixel color to the hardware.
      }
    }
    


  • Definitely, thanks



  • change the code a little bit and bingo you just made a light thermin .. cool for wearables πŸ™‚


  • Hero Member

    @hek Received my LED ring in the mail over the weekend. Hooked it up and ran your code. Everything looks to be working great, including the timeout code. Now need to mount and test under real world conditions, i.e,. in the garage with the car. Has anyone done that yet?


  • Admin

    Thanks for the feedback, pushed the timeout changes it to github now.



  • @Dan-S. I am going to do this but with a rgb led strip instead of a ring.


  • Hardware Contributor

    @Dan-S. said:

    Has anyone done that yet?

    Not yet, but I've got plans, big plans πŸ™‚ - I'm working on a leak detector now but when that board is done, I'm going to build an "ultimate garage" PCB that will have the the parking LED, distance sensor, temp/humidity, garage door location sensors, garage door open/close relay, and will automatically close the garage door after a timeout unless a button is pressed.

    Here's the way I think about the parking problem: the car moves through 3 different areas: 1) entering garage (not safe), 2) safe to park (far enough in, but not too far), 3) danger - too far. But how do you know what sensor values those correspond to? Especially since mounting the sensor in different areas, at different angles, and with different vehicles will change those values. So if you hold down a button on the sensor, it puts it into config mode. Move the car to the start of the safe area, and push the button to record that sensor reading. Then move the car to the end of the safe parking area and push the button again to record that sensor reading. Then have the software dynamically update the LED ranges to respond to those sensors. Something like: in area 1), illuminate more and more LED's as the car moves through the area. When the car hits area 2), flash the ring green 3 times, then fully illuminate all LED's in green. As the car moves through area 2), decrease the number of LED's illuminated until it hits area 3) where all the LED's flash red.



  • @Dan-S. Would you mind providing a little detail on your build? I'm totally new and having problems trying to figure out a few things

    Do I need a capacitor? If so will 22uf do and where do I hook it up.

    I really just looking for a few detailed pics so I can hook things up correctly

    Thanks



  • My brother just bought a house and I am going to sucker him into taking up this project by building this for him. I want to add some gas sensors and would like advice on best ones to add. I want to monitor CO, LPG, Butane, and fumes you would get off regular old automotive gas.


  • Admin

    @chilump

    Yes, a cap on the led ring won't hurt. I soldered mine directly on the ring between GND/VCC. 22uF is probably fine.


  • Hero Member

    @chilump I am moving from the prototype setup to the garage setup. The first picture shows the LED ring connections. I used solid copper wire because it facilitated what I wanted to do. I squeezed the ends of the wire to flatten them and bent them 90 degrees to make it a bit easier to solder to the solder pads on the led ring. The pads are marked D1,5V,GND and D0. D0 is not used in this application. These are the most difficult connections to make.

    Connections.jpg ```
    I mounted the ring on a square piece of 1/4 in particle board, drilling holes to feed the wires through. It only has a primer coat on it in the picture.
    mount1.jpg
    I will connect a 100uf between the 5v and ground connectors behind the board so it cannot be seen and then mount it on the garage wall.
    Mount2.jpg
    Hek's 22uf recommendation is probably good enough, but in reading about led ring applications an the internet 100uf was recommended for Adafruit neopixel rings. How much you need is dependent on the led intensity and how rapidly the signal will be changing--for this case 22uf should be ok.

    I put the distance sensor in one of the standard cases.
    distance.jpg

    As far as wiring to the Arduino is concerned Hek spells all that out on the mysensor home page if you click on parking sensor. DI of the led ring goes to D4 on Arduino, Trig and echo of the distance sensor got to D6 and D5 of the Arduino respectively. Don't wire the led 5V to the Arduino. It should come directly from the power supply since when the leds are full on they can consume more power than the Arduino can supply. I plugged the Vcc and grnd connections from the distance sensor directly into the Ardouino's pins that were so marked. To be on the safe side I plan on using a 5V 2A DC power supply for this application. All grounds must be common.



  • @Dan-S. Thank you very much for taking the time to take pics and write up your project! Can't wait to get home to try.

    Thanks!!!!

    @hek Thanks for the info on 22uf and thanks for thinking up this project. Great tool for me and my kids.



  • @Dan-S. Can a single 5v 2a adapter be used? In that case would everything be wired to the single power adapter?


  • Hero Member

    @chilump I hope so since that's exactly how I intend to use it. I will wire the arduino and the led ring directly (and separately ) to the adaptor. I don't want to have to deal with 2 separate power supplies.



  • @Dan-S. Thanks for the guidance! Looking forward to getting it working



  • This is looking great!
    But i'm not seeing any "sleeping" is there anyway to have this using the external interrupts on the arduino so it can be running on battery?
    ( sorry if i'm mistaken, i'm new to arduino πŸ˜„ )


  • Hero Member

    @leothlon that LED ring would burn through your batteries quite fast.



  • @korttoma
    Even if it's only active for about 3-4minutes per day?
    The problem is i got no way of getting power to where i want to place it.
    And also if i did it would have to be something like 230V to usb adapter.
    And plugging one of those in outside seems like a fire hazzard (even indoors they are known to start fires).

    What if i hook it up to a small solar panel to charge the batteries?

    Otherwise i guess i'll just have to stick with the old tennisball on a string method πŸ˜„


  • Hero Member

    @leothlon I'm not saying it can not be done but according to the datasheet the LED chip can consume up to 20mA ( http://www.adafruit.com/datasheets/WS2812.pdf ). So with 24 of them you will be looking at almost 500mA for just the LEDs.

    http://ncalculators.com/electrical/battery-life-calculator.htm

    btw, there is another thread about safe AC DC transformers here


  • Hero Member

    @korttoma The online documentation I read said:

    "The pin labeled PWR +5V is the power input pin, and should be connected to a suitable power supply. An input voltage of 5 V is used to power the ring, and each LED on the ring can draw up to 50 mA at 5 V when outputting white at full brightness. That means the ring could draw up to a maximum of around 1.2 A."

    Although Hek's code does not operate all the pixels at full white brightness, I decided to play extra safe and use a 2A supply.


  • Hero Member

    @Dan-S. Yeah I'm sure thats true. Please post a link to the documentation if you can find it. Anyhow I guess we can agree that running this device on batteries would be difficult.


  • Hero Member



  • @korttoma
    Yea from my calculations i would need to change batteries about once a month.
    And with the amount of sun here in sweden i don't think solar charger would help much sadly.


  • Admin

    But isn't the distance sensor rather power hungry as well?

    The dist-sensor but be awake all the time taking measurements (which needs to be interpreted by the MCU).. so sleep mode is not an option on this.


  • Contest Winner

    @hek said:

    But isn't the distance sensor rather power hungry as well?

    You could wake it with a reed switch attached to the garage door...

    door open, sense and display until steady state and go to sleep on a timeout or door closed interrupt


  • Hardware Contributor

    @BulldogLowell said:

    You could wake it with a reed switch attached to the garage door...

    door open, sense and display until steady state and go to sleep on a timeout or door closed interrupt

    I like that idea. I was planning on having garage door sensors tied in with this anyway. FYI here is a link to the ultrasonic module docs which list 15mA as the current draw.


  • Hero Member

    Just to add my two cents, as I have a window nearby, I'm planning to run my parking sensor with a solar battery bank, like this one.

    http://www.dx.com/p/solar-powered-13800mah-external-battery-charger-power-source-bank-silver-white-281953#.Ve8ICLTOmNM

    I'm waiting for the ring now. It is the last piece missing πŸ˜‰



  • This was fun to build πŸ™‚

    However, my HC-SR04 is making a high pitch sound when distance is close and a more static sound when distance is further. I have tried with 3 different modules and 2 different Nanos and 2 different power sources. Is this normal?


  • Hero Member

    @msebbe It's normal for a 🐢 or a bat. πŸ˜† Either you have really good hearing, or there's something wrong with your HC-SR04. The ultrasound is supposed to be well above human hearing range (40 KHz). My HC-SR04 is quiet and I don't hear any sound from it.


  • Contest Winner

    @msebbe

    building on @Sparkman , perhaps it is some kind of resonance... something attached with a natural frequency that is excited by the vibrations of the speaker.


  • Admin

    @msebbe

    I could hear mine as well when being close to it.



  • @Sparkman

    It is correct that I have really good hearing.. But if I use the distance sensor sketch the HC-SR04 is not making any sound at all, first now with this sketch I hear it. Could it have something to do with the LED-strip I got from china?


  • Hero Member

    Was checking out operation of parking sensor after changing MAX_Distance to 200 from original 100--wanted earlier start from wall. Also changed the Panic distance to 60--more space from wall during testing. Noticed that the led ring did not start from 1 pixel and increase from there as the distance closed. It started at 7 lit pixels. Examined the formula for newLightPixels and made a change which corrected this.

    The current newLightPixels formula is:

    int newLightPixels = NUMPIXELS - (NUMPIXELS*(displayDist-PANIC_DISTANCE)/MAX_DISTANCE);

    The portion of the newLightPixels formula (displayDist-PANIC_DISTANCE)/MAX_DISTANCE) is intended to map the interval between PANIC_DISTANCE and MAX_DISTANCE to the interval (0,1). In other words, when you are at the PANIC_DISTANCE it should calculate to 0 and when you are at MAX_DISTANCE it should calculate to 1, advancing linearly between the two values as the distance closes and vice versa. Clearly when a displayDist = PANIC_DISTANCE, the numerator of the division of the formula calculates to 0. However when displayDist = MAX_DISTANCE, it does not calculate to 1.

    In order to correct this I changed the portion of the formula to:
    (displayDist-PANIC_DISTANCE)/(MAX_DISTANCE-PANIC_DISTANCE))
    Note the only difference is subtracting the PANIC_DISTANCE from the MAX_DISTANCE in the denominator. Now when the displayDist = MAX_DISTANCE, the formula returns the value 1. So the proposed new newLightPixels formula is:

    int newLightPixels = NUMPIXELS - (NUMPIXELS*(displayDist-PANIC_DISTANCE)/(MAX_DISTANCE-PANIC_DISTANCE));

    I tested it both by plugging values into the formula and in operation of the Parking Sensor. Now the leds climb smoothly from 0 as you enter the MAX_DISTANCE zone. rather than starting at some number other than 1 (7 in my case).



  • Cool, I had this happen as well, so great fix! Now all I need it to do is talk to domoticz, not picking it up yet... πŸ™‚


  • Hero Member

    Have one more proposed change to parking sensor code. Noticed that even when I was standing still there seemed to be quite a few changes in number of leds lit. In checking the internet, learned that variability of distance readings was particularly a problem for those using the sensor in robots. The preferred solution seemed to be taking the median of several readings.
    See:
    http://blog.microcentertech.com/2013/05/minipingbot-construction.html

    Fortunately, the Newping library has a built in function to address this issue by taking the median of several readings (default = 5). So I modified the code as follows:

    // int fullDist = sonar.ping_cm(); original code
    unsigned int fullDist = (sonar.ping_median() / US_ROUNDTRIP_CM);
    // Get average distance for 5 pings, convert to cm
    // US_ROUNDTRIP_CM = distance sound travels in cm/sec

    As a result, the jumping around of the number of leds appears to have decreased significantly and the response is much more stable. Hope this helps others.



  • @Dan-S. Thanks for your investigation! I made the changes and it seems to work well!

    About the high pitch sound I mentioned earlier; I changed NEO_KHZ400.

    Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEO_PIN, NEO_GRB + NEO_KHZ400);
    

    to

    NEO_KHZ800
    

    This removed the annoying high pitch sound πŸ˜„


  • Hero Member

    @msebbe Glad everything worked out well for you. Your comment made me think about changing mine to 800 also. From what I could glean from looking on the internet, 800 is more appropriate for newer devices, e.g., the led ring. So I am going to change to 800 also. Thanks.



  • Just built this with my 4 year old. She loved it! She did the project management and directed me which wire goes where. Got to start them young!

    I was really shocked at the brightness of the LED ring. I mean, I knew it would be bright from looking at the videos, but wow.

    My setup was to connect my UNO to the PC, load code and branch power directly from the UNO's 5v pin. I had no cap or resistor in place either (neither was there a radio hooked-up). This was just a bench-top proof of concept and it worked right out the box (after I soldered leads to the ring). I went through all the adafruit example codes and worked without a hitch. I may, or may not, exceeded WAF level 10. Now she is giving me more projects for these "neopixel" lights.


  • Admin

    My girls like liked the neopixels as well πŸ˜‰


  • Hero Member

    Had some issues with the operation of my parking sensor which I resolved and now it seems to be working perfectly.
    Thought I would pass on what I did in the hope that it might help others having the same problem.

    There were 2 issues.

    The first issue was random lighting of the led ring after the car was pulled out of the garage and the door was closed. My guess was that the sensor, in the absence of having the solid car to bounce off of, was picking up stray sensor ping echoes from other objects in the garage. Checking on internet revealed that others using the HC-SR04 Distance sensor had experienced this problem. Checking further, I discovered that there were updates to the NewPing library, the latest being version V1.7 and specifically that V1.6 included an update to the sonar.ping_median function used for distance measurement in the parking sensor code. The MySensors library current version is V1.5. After I updated to V1.7 I no longer had random readings when the car was not in the garage. First problem solved.
    bolded textSo I would recommend updating to NewPing V1.7.

    I then reinstalled the parking sensor in the garage for further testing. Everything appeared to be going well but when I returned to park my car in the garage later in the day I was greeting by the led ring flashing bright red with all its leds which is supposed to be a panic signal that the car was parked as close as it should be. But I had just entered the garage and was not anywhere near the range of being parked. Took the sensor down and brought it in for testing. Found out that everything worked fine except if it was left on in the condition where it was not sensing any object in range for an extended period of time, it went into the flashing led mode. Too me it had the symptom that given enough time, a variable was being overrun (an integer variable exceeding its capacity). Checking over the code I noted the following lines:

    if (displayDist == 0) {
    // No reading from sensor, assume no object found
    numLightPixels--;}

    So everytime the displayDist = zero (and it is zero when no object is detected) numLightPixels is decremented by 1. So if there is no car in the garage (and since I had fixed the random detection problem), the sensor returns a steady stream of zeros to indicate there is no car in the garage and the numLightPixels is decremented with no limit. Given enough time it will eventually decrement to -32,768 at which point it rolls over to +32,767 and at that point the red leds will all flash in the panic mode. To fix this, I changed the above code to read:

    if (displayDist == 0) {
    // No reading from sensor, assume no object found
    //Make sure you don’t go below zero
    if (numLightPixels>0) {
    numLightPixels--;}

    So now it won’t decrement numLightPixels below 0. That solved the problem.

    There is also one related efficiency change I made. At the beginning of the loop there is code to skip 10 zero readings:

    if (displayDist == 0 && skipZero<10) {
    // Try to filter zero readings
    skipZero++;
    return;
    }

    I changed that code to skip all zero readings if numLightPixels is less the one (i.e., 0), since if numLightPixels is at zero all of the pixels are already off and if the sensor continues to read zeroes, they should all be skipped (don’t go through the rest of the loop) until a nonzero reading is obtained (something is found).

    if (displayDist == 0 && numLightPixels<1) {
    // Filter zero readings
    return;
    }

    Mounted the sensor in the garage again and now everything works perfectly. Hope this helps someone else.



  • Haven't had the chance to put this in the garage yet, but awesome work!



  • This sketch doesn't support MQTT right? Has anyone maybe a version of this sketch which outputs MQTT? Or could you guys maybe guide me on how I would do it?


  • Hardware Contributor

    @msev said:

    This sketch doesn't support MQTT right? Has anyone maybe a version of this sketch which outputs MQTT? Or could you guys maybe guide me on how I would do it?

    MySensors uses radios to communicate with a gateway over RF. The gateway can be set up to convert those messages to/from MQTT (or use software to convert the serial messages to/from MQTT). So there aren't going to be any sensor sketches with MQTT in them. If you use an ESP, then you could send MQTT directly but then you're on WIFI and don't need MySensors.



  • I meant for the esp8266.

    @TD22057 said:

    @msev said:

    This sketch doesn't support MQTT right? Has anyone maybe a version of this sketch which outputs MQTT? Or could you guys maybe guide me on how I would do it?

    MySensors uses radios to communicate with a gateway over RF. The gateway can be set up to convert those messages to/from MQTT (or use software to convert the serial messages to/from MQTT). So there aren't going to be any sensor sketches with MQTT in them. If you use an ESP, then you could send MQTT directly but then you're on WIFI and don't need MySensors.


  • Admin

    Should work, start with the MQTT ESP gateway (in development branch) and copy the relevant parts from the parking sensor example.



  • @hek I'll try, then I'll show the sketch for fixing mistakes :D...Also Newping library doesn't work on ESP, so I'll have to use Ultrasonic library. πŸ˜•



  • @chilump Do you have a picture of your final product (or a wiring schematic)? I just discovered this project and don't want to reinvent the wheel.


  • Hero Member

    The wiring should be quite strait forward and mentioned in form of comments in the sketch:

    #define NEO_PIN      4 // NeoPixels input pin
    
    #define TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
    #define ECHO_PIN     5  // Arduino pin tied to echo pin on the ultrasonic sensor.
    

    Basically pin 4 on the arduino goes to the input pin on the NeoPixel LED ring

    The distance sensor is also described here -> https://www.mysensors.org/build/distance

    Is there something else that is not clear how it should be connected?



  • @korttoma This is a total newb question, but it is all about the power. I've done stuff with Pi's before, but this is my first foray into the arudino world. Everything I've read says to power the ring apart from the Arduino (don't use the 5v pin). I am going to use an Uno and I thought I could get a 9v 2a wart and power the board through the barrel connector, using a regulator jumpered off the wart before the board to step down to 5v. However this is all guess work on my part. I figured people have done this, if I saw a finished product I could figure out the rest myself. Thanks for the help.


  • Hero Member

    @mjbok yeah, there is some discussion earlier in this tread about the current consumption of the LED ring and there is no way any 5V pin on the Arduino can deliver the current needed so yes a separate voltage regulator from a 9V wart sounds like a good plan. Just make sure you have common GROUND and some capacitors to filter out disturbance.

    btw, I found an article about powering NeoPixels here -> https://learn.adafruit.com/adafruit-neopixel-uberguide/power



  • @korttoma I plan to do something like this (quick and dirty with MSpaint). I've ordered all my parts, now just wait.

    0_1464757950042_parking sensor.jpg


  • Hero Member

    Yeah, that's how I would do it also, just make sure your 5V regulator can handle enough current.



  • Has anyone done this project without the neopixel? I am looking to use one or more LEDs to simulate... maybe green yellow red.

    I tried to start peeling off the neopixel sections, but ended up ruining the sketch.

    Care to share the code for the non-nepixel model?

    Thanks



  • Hey There, I'm getting ready to play around with this once a few more parts arrive to give me ideas on other potential uses for distance sensor and LEDs, but one thing i'm confused about.

    The sketch mentioned using pins 4, 5 and 6.

    Adafruit and all docs i've seen and played around with mention that neopixels need a PWM pin to operate.

    Pin 4 doesn't appear to be PWM (on pro mini)

    I see that trig and echo are typically wired to 5 & 6 in most cases which are PWM.
    so in short, not enough PWM pins .

    Are the neopixels still working because the signal is being sent at "full" brightness?


  • Hero Member

    Unlike the dumb rgb strips neopixels don't need a pwm pin to dim and mix colours. Each rgb led has its own controller chip.


  • MySensors Evangelist

    Received all the parts let's see if we can build a working 2.0.0 solution πŸ˜‰



  • Here a working example with a 16-Bit ring with radio because the misses hit the fence for the second time this year with the car.
    alt text
    alt text
    alt text
    Sensor in action <--Video


  • Admin

    Wooo, cool to see it live!


 

354
Online

8.0k
Users

8.8k
Topics

94.4k
Posts