2018 Controlling your Ambot

Controlling your Ambot

  • Your Ambot’s ESP8266 microcontroller is
    • a NodeMCU DevKit v2
    • mounted on a NodeMCU Motor Shield
    • running custom firmware
    • connected via WiFi
    • running an internal web server
    • controlled using HTTP commands
      • Send commands to the bot’s web server. For example:
        • http://esp_1a2b3c/status “Comm check”: returns “Operational” message if bot brain and connection are working
        • http://esp_1a2b3c/motor?m=500,1,500,1 tells motor 1 go at speed 500 in direction 1, motor 2 go at speed 500 in direction 1
        • http://esp_1a2b3c/motor?m=500,1,900,0 tells motor 1 go at speed 500 in direction 1, motor 2 go at speed 900 in direction 0
        • http://esp_1a2b3c/servo?a=90 tells servo to turn to angle 90
        • http://esp_1a2b3c/digitalwrite?d=14,1 turns on GPIO pin 14 (which is 5 on the motor board)
        • http://esp_1a2b3c/digitalwrite?d=16,0 turns off GPIO pin 16 (sending 0 to pin 16 turns on the onboard LED)
        • http://esp_1a2b3c/digitalwrite?d=16,1 turns on GPIO pin 16 (sending 1 to pin 16 turns off the onboard LED)
        • http://esp_1a2b3c/digitalwrite?d=2,0 turns off GPIO pin 2 (sending 0 to pin 2 turns on the other onboard LED)
        • http://esp_1a2b3c/analogwrite?d=14,150 turns on GPIO pin 14 to value 150
    • Supported commands:
      • /status
        • returns status report of bot (details sent only to serial port)
      • /motor?m=a1,a2,b1,b2
        • commands motor
        • speeds (a1, b1) are 0-1023
        • directions (a2, b2) are 0 and 1
      • /stopmotors
        • Stops motors
      • /runstop?m=a1,a2,b1,b2,t
        • commands motor to run for t milliseconds (1 second = 1000 milliseconds)
        • speeds (a1, b1) are 0-1023
        • directions (a2, b2) are 0 and 1
        • time (t) is milliseconds (250 = 1/4 second; 1000 = 1 second; 2000 = 2 seconds
      • /servo?a=a1
        • commands servo to move to angle a1 (0 <= a1 <=  180)
      • /servo_off
        • Logically disconnects servo (stops jitter). Servo automatically reconnects when /servo?a=x command is sent.
      • /distance or /dist
        • reads distance sensor
      • /temphumread or /tempHumRead or /temp
        • Reading temperature or humidity takes about 250 milliseconds!
        • Sensor readings may also be up to 2 seconds ‘old’ (is a very slow sensor)
      • /reset
        • reboots bot brain
    • We will control our bots using Snap! This template gets us started (right-click to download. Choose “Save link as…“):