Close

Adding Ultrasonic Sensors

A project log for My Dalek Build

For next Halloween I want a Dalek for "Trick or Exterminate"

agpcooperagp.cooper 08/24/2016 at 09:360 Comments

Adding Ultrasonic Sensors

I thought it would be a good idea to add some ultrasonic senors to stop the Dalek from bumping into things, something like this:

Two problems:

  1. Some of the WiFi functions are the "blocking" type.
  2. I have only two digital pins and 1 analog pin left (excluding Rx and Tx).

So unless I rewrite the code to be timer/interrupt based (ticker perhaps?) then it would be a good idea to off-load the sensor processing to a slave MPU such as an ATTiny85. Actually if "ticker" works on the ESP8266 I should really be using that, I better have a look.

Port expansion is a problem because the SDA and SCL pins are in use! So I will need a software version of the SPI/\ or Wire library or similar it I go down that path.

Hooking Up the Ultrasonic Sensors

I bought some acrylic sensor mounts (now why every sensor mount type I have bought does not fit properly, I don't understand, but with a round file I made them fit). But I don't have any suitable mounting screws so it will have to wait until tomorrow.

Although I have plenty of Digispark ATTiny85s how do I mount it (there are no mounting holes)?

Now I could just drill a mounting hole in the USB connection (after programming) or even after using a programmer for the Digispark (I have one). I can jump some power and the two digital lines off the CNC board.

The Digispark has Vcc/Gnd and 6 usable pins. So two to tell the WeMos to turn left or to turn right, and two (trigger and echo) for each ultrasonic sensor (two sensors: one left and one right).

So no need for a SPI or Wire library but things have a way of coming back (when I want to add something else)!

The CNC Shield

The CNC shield sounded like a good idea at the time but really I should have just used strip-board or even had a custom PCB made. The port expansion (SPI) could have been built-in. And I am going to need SPI for other functions that I want to implement later.

AlanX

Discussions