TerraControl – with NodeMCU Webserver

UPDATE 3: Version 1.3

I’m working on making the code as user friendly as possible but it’s going to be a long run. I’d like to have separate html and css files but I’m still figuring it out. For now, few changes…:

  • ! ! ! included mDNS protocol, so from now on you don’t need IP address to connect to your NodeMCU, simply put terracontrol.local in your browser and you are done (you have to be on the same network, of course)
  • separate file for setting up the variables (setting.h). Unzip the file to your Projects folder, when you open the *.ino file, setting.h should be opened as well.

UPDATE 2: Version 1.2

  • improved graph displaying range
  • new values in graphs are moved to the end of array, not starting from the beginning again
  • improved light setting – it is now unlimited (ON time can now be later than OFF time)
  • code for manual defining your own server is in one place and commented by default (i.e. it is on automatic setting)
  • clearer information in serial monitor
  • unified function for min/max values in array
  • new function for printing out minute values

UPDATE 1: Please see the version 1.1 I got the graphs and statistics working! Well, sort of…the range is still not as I want it to be, but at least now it is correctly displaying min and max. Plus new mouseover feature for the individual values in the graph.

After my first attempt to create controlled terrarium using Arduino board I got my hands on NodeMCU 12E board and I knew it was going to be a big step up!

I took me a few days before I began to understand how this board works (thanks to a lot of instructables here and google of course) and the possibilities it had. It think I’m on the right path to create exactly what I was dreaming about for several years…

So what is TerraControl v1.2 capable of?

  1. 2 automatically controlled relays (light timer and heating)
  2. 2 manually controlled relays (fan, second heating)
  3. GMT time change
  4. Simple graphs with highest/lowest temperature/humidity over the last 24 hours
  5. Monitoring temperature and humidity in terrarium
  6. All accessible and adjustable through webserver using HTML and CSS

What is necessary:

  • given the nature of NodeMCU board (its output is only 3.3v) you will either have to buy 3.3V relay board, or modify 5v board, or buy I2C logic converter module – for example – $0.9
  • 5V source (I’m using older usb charger)
  • wires
  • solder
  • case/box
  • Arduino IDE

Step 1: Getting the Parts Together

Connecting these parts is easy, just look at the source code and keep in mind that GPIO’s of the NodeMCU board is different from the actual boards description (as seen on the trird picture):

//Define sensor pins
#define SENSOR_IN 15 //D8
#define SENSOR_IN_Type DHT22

//Define Relay pins
#define relayLight 5 //D1
#define relayHeat 4 //D2
#define relayFan 12 //D6
#define relayHeat2 14 //D5

i.e. DHT sensor pin goes to D8 (board’s D3, D4, D8 can’t be used as output but can be used as input), and the relay pins accordingly to the code. Remember, if you are using 5V relay, you need to modify the relay board or use I2C logic converter.

! ! ! IMPORTANT! When uploading the code to the board, you have to disconnect the DHT sensor, otherwise you will get an error when attempting to upload ! ! !

All parts can be powered with 5v power adapter

Step 2: Setup and Customization

Before we upload the code, there are few things that needs to be set up in setting.h:

//You WiFi AP
const char ssid[] = “SSID Name”; // insert your WiFi AP name
const char pass[] = “password”; // insert your WiFi password

// T E R R A R I U M S E T T I N G
float tempMin = 24; // temperature in Celsius for switching the heating ON
float tempMax = 30; // temperature in Celsius for switching the heating OFF

int humMin = 50; // minimum humidity in %
int humMax = 70; // maximum humidity in %

// hour and minute for light to go ON
int lightOn_hour = 7;
int lightOn_min = 0;

// hour and minute for light to go OFF
int lightOff_hour = 20;
int lightOff_min = 30;

// Central European Time (1 for winter time)
int timeZone = 2;

Uncomment the following part of the code if you know how to define your server manually or just run the code and get addresses from the serial monitor.

/*— UNCOMMENT THIS FOR MANUAL SETTING —
IPAddress ip(192, 168, 0, 111); //Node static IP
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip, gateway, subnet);
*/

All done? Great, let’s move on…

Step 3: Alwas ON/OFF Relay Connection

One thing I wanted was the relay board to be used as little as possible. As you probably know, relays have two possible ways of connection: ON when not used and ON when used. So I connected the light and heating to “ON when not used” (heating is almost always ON and lights are ON for about 13-14 hours every day) and fan and heating 2 to “ON when used” (I barely need to use one of them).

That is why the code for the same function is using different values:

if (heatVal == 1) {
client.println(“ON”);
} else {
client.println(“OFF”); }

AND

if (heat2Val == 1) {
client.println(“OFF”);
} else {
client.println(“ON”); }

You can of course modify the code according to your needs.

Now just connect the DHT sensor and let’s look at the result!

Step 4: Webserver

When you open the webserver you will see simple page with all information about your terrarium and some features:

  • Light ON/OFF time can be adjusted (step are: 1 hour for hour setting and 5 min for minute setting). At the moment ON time has to be earlier that OFF time (ON 22:30 and OFF 0:30 will not work – yet) – fixed in version 1.2
  • Temperature setting (steps are 0.5 degree Celsius)
  • Manualy turn ON/OFF other two relays – Fan and Heat 2 and adjust timezone when the time changes

if needed, change your timezones in following part of the code:

if (request.indexOf(“/TIMEZONE_SWITCH”) != -1) {
if (timeZone == 1) {
timeZone = 2;
setSyncProvider(getNtpTime);
} else {
timeZone = 1;
setSyncProvider(getNtpTime);
} }

  • Webserver is using automatic time synchronization

Step 5: Disclosure

I know that the HTML and CSS code could be much more simple and the coding is not really user friendly but for the moment it works as it is supposed to (only the graphs are not very accurate but I’m still working on them) and I will get to these points when I start working on version number two. I have already decided to use external power supply (in this version I just stripped the 5v adapter and soldered it inside the box) and I also want the power cables to be more accessible and easier to connect/disconnect. I hope you guys (and your pets) will appreciate this instructable, if you do, please leave a short comment. And of course, suggestions are more than welcome! Thank you

eX-Robot – ProfileBlock™ Robot Platform

[ Upload 20170424]
[ Upload design concept 20170418]
http://www.thingiverse.com/thing:2256715

ProfileBlock – Balancing Robot – DIY Robots Platform

3D Design Tool: SketchUp Pro

ProfileBlock’s robots are built on top of an open source Arduino-based(with ESP8266, Raspberry Pi) platform.

Self Balancing Robot (eX-Robot, B-Robot, Roverbot, …

Hardware_____

Base Plate(Parts):

6 x ProfileBlock™ DF 2020 85mmAcrylic Plate (t = 3mm)1 x Top Plate1 x Bottom Plate
2 x Step Motor Mount Plate
1 x Front Plate
1 x Rear Plate3D Printing Parts
2 x Servo Mount ProfoleBlock
12 x Knob M5 Hexaheard
2 x Wheels 100mm or Inline Wheels 70mm(with 2 x Inline Wheels Hub)
2 x Tire Mudguards
1 x Stand1 x Battery Holder

Step Motor:

2 x Nema 17 Stepper Motor bipolar 4 leads 34mm 12V 1.3A 26Ncm(36.8oz.in) 3D printer motor 42SHD0001
2 x NEMA 17 – Phase: 4, Step Angle: 1.8 Deg/Step, Holding Torque: 2.6Kg.cm

Servo:

1 x Standard Servo or SG90 Metal Servo
1 x Standard Servo (Option) or SG90 Metal Servo

12 x M5 10mm Nylon Bolts
12 x M5 8mm Nylon Bolts
12 x M5 Nylon Nuts
8 x M3 8mm Bolts
4 x M3 10mm Bolts
4 x M3 15mm Bolts
8 x M3 Nuts

Electrical______

Control Board:


1 x ESP8266 Witty Cloud or WeMos (eX-Robot)

1 x HC-SR04 ultra sonic module
1 X MPU6050
2 x A4988 Step Motor Drive
1 x LM1117-5.0 5,0V 1A Regulator
1 x LM1117-3,3 3,3V 1A Regulator
6 x 100uF 25V Capacitor
4 x 0.1uF Capacitor
1 x 220KOhm Resistor
1 x 100KOhm Resistor
4 x 10KOhm Resistor
7 x 8P Female Pin Header Connector 2.54mm Pitch
3 x 4P Male Pin Header Connector 2.54mm Pitch
2 x 3P Male Pin Header Connector 2.54mm Pitch
3 x 2P Male Pin Header Connector 2.54mm Pitch
1 x 2EDGK 5.08mm 2P Plug-in terminal connectors set
1 x Right Angle SPDT 4 Pin On-On I/O Boat Rocker Switch
1 x Interface Mother boardPower Requirements:8.4VDC
12 VDCBattery:2 x 18650 Litum Ion Battery = 7.2 VDC ~ 8.4 VDCSoftware:

ESP8266 WeMos D1 mini code: Coming soon…
WiFi UDP Control TouchOSC Layout file: Coming soon…

Arduino IDE (ESP8266 ESP-12E/F)Support SoftAP and StationSupport OTA (at Local network)Support mDNS (at Local network)

The open source ProfileBlock hardware and software is free and made with love. Please show your level of support with a voluntary donation.

Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RDN7ZGAVFS5UE

MobBob V2 Remix Upgrade – Smart Phone Controlled Robot

[Update 20160212]
Add MobBob2_Remix_PowerBank_Hook.stl
Add MobBob2_Remix_Jacket.stl
Add MobBob2_Remix_Nano_Shield_Mount.stl

[Update 20160120]
Add Test #3 Video

[Update 20160119]
Add Test #1, #2 Video
Add MobBob2_Remix_Hand_Back_L.stl, MobBob2_Remix_Hand_Front_L.stl
Add MobBob2_Remix_Arm_Back_L.stl, MobBob2_Remix_Arm_Front_L.stl
Add MobBob2_Remix_Shoulder_L.stl
Add MobBob2_Remix_Hand_Back_R.stl, MobBob2_Remix_Hand_Front_R.stl
Add MobBob2_Remix_Arm_Back_R.stl, MobBob2_Remix_Arm_Front_R.stl
Add MobBob2_Remix_Shoulder_R.stl

[Update 20160105]
Printing errors corrected
MobBob2_Remix_Foot_L_Top.stl, MobBob2_Remix_Foot_R_Top.stl

[Upgrade 20160104]
Redesign Foot
MobBob2_Remix_Foot_L_Top.stl, MobBob2_Remix_Foot_L_Floor.stl
MobBob2_Remix_Foot_R_Top.stl, MobBob2_Remix_Foot_R_Floor.stl
Base Design: http://www.thingiverse.com/thing:1232619


Smart Phone Controlled Robot – MobBob V2 Remix Upgrade


3D Design Tool: SketchUp Pro
Design concept: RAPIRO – The Humanoid Robot and Gundam

This is an upgrade version of my MobBob V2 Remix robot.

MobBob is a smart phone controlled robot. By harnessing the power of your smart phone, MobBob is a walking, talking robot with voice recognition and computer vision that you can build for around $35. I will be continuing to extend his features over time. I want MobBob to be a companion robot that everyone can afford and have fun with.

You can see videos of MobBob V2 Remix upgrade in action here:
https://youtu.be/8nO0kziJvsk – 3D Design
https://youtu.be/ehrsIDJcVZY – Test #1
https://youtu.be/j0oz8OPYhNs – Test #2
https://youtu.be/5z4Ps11t-vE – Test #3
…..
Coming soon!!

The main aims of the V2 remix were to:

Support standard 9g servos [previously I was using Tower Pro SG90 servos]
Make everything easier to assemble [no more need for glue]
Make it easier to adapt/modify for other phones. The new bracket system made it easier to exchange a new phone / the battery holder.

Also, in my V2 Remix Upgrade build, I’m also using the Arduino Nano instead of the DIY Nano shield, so the entire build is smaller and tidier. 🙂

MobBob V2 Remix Upgrade uses the same software as the original RAPIRO.

You can find the latest Arduino code here: https://github.com/Ishiwatari/RAPIRO
The modified code is included: http://www.thingiverse.com/thing:1235865

You can download the latest version of the Android from Google Play – it is free, ad-free, and without IAP:
https://play.google.com/store/apps/details?id=com.github.luzhuomi.rapicommand

You can find more detailed build and wiring instructions here:
…coming soon…

The parts that you need to print:

1 x Leg Left
1 x Leg Right
1 x Foot Left Floor
1 x Foot Right Floor
1 x Foot Left Top
1 x Foot Right Top
1 x Waist
1 x Arduino Nano Holder
1 x Phone Mount Base
2 x Phone Mount Side
1 x Phone Mount Gear
1 x Phone Mount Back Plate
1 x Phone Mount Conn
2 x Phone Mount Bolt
2 x Phone Mount Nut
1 x Battery Bank Rack [18650 x 2] or Power Bank
1 x Battery Mount Cover or PowerBank Hook
1 x Jacket
1 x Cap
1 x Hand Back Left
1 x Hand Front Left
1 x Arm Back Left
1 x Arm Front Left
1 x Shoulder Left
1 x Hand Back Right
1 x Hand Front Right
1 x Arm Back Right
1 x Arm Front Right
1 x Shoulder Right

The non-3D printed parts you need are:

6 x Tower Pro SG90 servos [for Shoulders, Arms and Hands]
4 x EMAX ES08MA II Mini Metal Gear Analog Servo [Strengthening the power of the Legs and Foots]
1 x Arduino Nano ATmega328 [see note below]
1 x HM-10 BLE Bluetooth 4.0 CC2540 CC2541 Serial Wireless Module [or HC-05]
1 x 5V Micro USB 1A Lithium Battery Charging Board [see note below]
1 x DC-DC Converter Step Up Boost Module 2-5V to 5V 1.2A
1 x Rectangle On/Off Long Rocker Switch SPST
2 x Snap-In Single ‘A’-‘AA’ Battery Contacts 209 [KEYSTONE ELECTRONICS CORP.]
2 x Snap-In Single ‘A’-‘AA’ Battery Contacts 228 [KEYSTONE ELECTRONICS CORP.]
2 x 18650 Lithium ion Batteries
1 x 300mm USB 2.0 A Male to Micro USB B 5pin + Mini B Male Y Splitter Cable
1 x Smart Phone [see note below]
4 x M3 5mm [for Foot Cover]
2 x M2 10mm [for Phone Connect]
4 x M2 5mm [for Phone Mount Back Plate]
2 x 2mm 5mm Tapping screw [for Foot servos]
2 x 2mm 8mm Tapping screw [for Hip servos]
2 x 1mm 5mm Tapping screw [for Foot servos hone]
2 x 1mm 8mm Tapping screw [for Hip servos hone and Shoulder]
2 x M3 15mm [for Jacket]
2 x M3 Nut [for Jacket]
4 x 2mm 15mm Tapping screw [for Jacket]
12 x M2 15mm [for Arm and Hand]
[Note: I got the servos, Arduino Nano, Bluetooth Module and Battery for under $30.]

Arduino Nano:

This is a small, Arduino compatible ATmega328 board with DIY extension board. MobBob V2 app connects to the Bluetooth module using its Bluetooth LE service. The app to support other Bluetooth cards.

Battery Extender:

You can use other batteries that provide 5V with a steady current. If you use other batteries, you may need to adapt the battery rack for your battery’s size.
Use 18650 Lithium Battery Charging Board With Protection Charger Module and Step Up Boost Module 3.7V to 5V for Smart Phone
http://www.thingiverse.com/thing:1235749

Smart Phone:

You can use other Android Smart Phones with This app.
You do not need to adapt the size of the phone holder for your phone. The app has been successfully tested with Nexus and Samsung, LG phones, but should work on other Android phones.

Instructions:

Print all the required parts
Get all the non-3D printed parts
Assemble as per the photos – I’ll be writing some more detailed instructions on my website soon!
Install the Arduino code from the GitHub link in the description – You will need to update the Arduino pins in the code to match yours, and probably update the centering values for the servos.
Install the Android app from the link in the description.

Have fun!

If you hit any problems, please post a question on this website: [http://www.rapiro.com], here, or on YouTube channel. A few people have built RAPIRO now, so there are people around who can help.

Coming soon update!!

The open source Mobbob V2 software and hardware is free and made with love. Please show your level of support with a voluntary donation.

Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RDN7ZGAVFS5UE

Post-Printing

How I Designed This

Design Tool

Google SketchUp Pro 8

Print Settints

Printer Model: PANDORA DXs – DIY 3D Pronter
Slicer: Cura 15.04.2


Layer height (mm): 0.1
Shell thickness (mm): 0.8

Bottom/Top thickness (mm): 1.2
Fill Density (%): 00

Print speed (mm/s): 50
Print temperature: 200
Bed temperature: 70

Support type:

  • Touching buildplate:
    MobBob2_Remix_Phone_Mount_Side.stl,
    MobBob2_Remix_Phone_Mount_Nut_L.stl, MobBob2_Remix_Phone_Mount_Nut_R.stl,
    MobBob2_Remix_Phone_Mount_Conn.stl,
    18650_Battery_Bank_2x_Cover_swC_r01.stl
  • Everywhere:
    MobBob2_Remix_Nano_Shield_Holder.stl,
    MobBob2_Remix_Battery_Mount_Cover.stl,
    MobBob2_Remix_Jacket.stl,
    MobBob2_Remix_Hand_Back_L.stl, MobBob2_Remix_Hand_Front_L.stl,
    MobBob2_Remix_Arm_Back_L.stl, MobBob2_Remix_Arm_Front_L.stl,
    MobBob2_Remix_Shoulder_L.stl,
    MobBob2_Remix_Hand_Back_R.stl, MobBob2_Remix_Hand_Front_R.stl,
    MobBob2_Remix_Arm_Back_R.stl, MobBob2_Remix_Arm_Front_R.stl,
    MobBob2_Remix_Shoulder_R.stl

Platform adhesion type: Brim

Filament: PLA
Filament Diameter (mm): 1.75


3D Files:

https://www.thingiverse.com/thing:1235865

Custom Section

Source code

by ShotaIshiwatari is licensed under the Creative Commons – Public Domain Dedication license.
modified by Zalophus

on the command line, enter:
// #M1 – robot will move forward
// #M2 – robot will move backward
// #M3 – robot will turn right
// #M4 – robot will turn left
// #M5 – robot will raise his hand and wave the left hand. LED will become green and flashing
// #M6 – robot will lower his left hand. LED will become Yellow
// #M7 – robot will move both arm and contract his hands. LED will become Blue
// #M8 – robot will wave goodbye with his left arm. LED will become RED.
// #M9 – robot will raise its right arm and move its waist. LED will become BLUE
// #M0 – robot will go to initial position

CAPS LOCK is important when you input a command via the serial monitor..
Reading through the source code.
Each movement of the preset (# M1 ~ # M9), consists of pattern of 8 frames.
Each frame is defined values ​​uint8_t type sixteen (motion).
This can be changed modifying the number of frame per pattern.MAXFN
Lets take #M0 for example:

uint8_t motion[MAXMN][MAXFN][16]={
{ // 0 Stop
{ 90, 90, 0,130, 90,180, 50, 90, 90, 90, 90, 90, 0, 0,255, 10},
{ 90, 90, 0,130, 90,180, 50, 90, 90, 90, 90, 90, 0, 0, 0, 0},
{ 90, 90, 0,130, 90,180, 50, 90, 90, 90, 90, 90, 0, 0, 0, 0},
{ 90, 90, 0,130, 90,180, 50, 90, 90, 90, 90, 90, 0, 0, 0, 0},
{ 90, 90, 0,130, 90,180, 50, 90, 90, 90, 90, 90, 0, 0, 0, 0},
{ 90, 90, 0,130, 90,180, 50, 90, 90, 90, 90, 90, 0, 0, 0, 0},
{ 90, 90, 0,130, 90,180, 50, 90, 90, 90, 90, 90, 0, 0, 0, 0},
{ 90, 90, 0,130, 90,180, 50, 90, 90, 90, 90, 90, 0, 0, 0, 0}
},

I put numbers so you can visualy make sense of what a pattern is, and what a frame contain.
Movements consist of pattern. Pattern are made of frames. Each frame contrain the rotation angle of every servo, the values of the RGB LED and a Time to perform the action.

Head horizontal rotation angle (Head yaw) (left) 180 <—> 0 (right)
Hip horizontal rotation angle (Waist yaw) (left) 180 <—> 0 (right)
Right shoulder up and down angle (R Shoulder yaw) (bottom) 0 <—> 180 (above)
Open right shoulder angle (R Shoulder pitch) (closed) 90 <—> 180 (open)
Right hand opening and closing angle (R Hand grip) (closed) 50 <—> 110 (open)
Left shoulder up and down angle (L Shoulder yaw) (bottom) 180 <—> 0 (top)
Open left shoulder angle (L Shoulder pitch) (closed) 90 <-> 0 (open)
Left hand opening and closing angle (L Hand grip) (closed) 130 <—> 70 (open)
Right foot horizontal rotation angle (R Foot yaw) (left) 0 <—> 180 (right)
Twist angle of the right foot ankle (R Foot pitch) () 0 <—> 180 (outside)
Left foot horizontal rotation angle (L Foot yaw) (left) 0 <—> 180 (right)
Twist angle of the left foot ankle (R Foot pitch) (within) 180 <—> 0 (outside)
Red component of the eye (R) 0 <—> 255
Green component of the eye (G) 0 <—> 255
Blue component of the eye (B) 0 <—> 255

Here are some other helpful commands that can be used to control the LED and each servos individually.

LED CODE sample

// #PR000G255B000T010 – MAX GREEN COLOR
R,G,B values between 0 and 255
T is the time component to get to desired color

LIMBS MOVEMENT
Sxx refers to one of the 12 motors (from S00 to S11),
A000 up to A180 is the angle where to servo incline,
Txxx is the time to perform the movement.
you can combine two commands, i tried more but it didn’t work..

// #PS00A000T010#PS00A180T010 – full head movement from side to side
// #PS01A000T010#PS01A180T010 – Waist
// #PS02A000T010#PS02A180T010 – r Shoulder
// #PS03A050T010#PS03A180T010 – r Arm
// #PS04A030T010#PS04A140T010 – r HAND
// #PS05A000T010#PS05A180T010 – l Shoulder
// #PS06A130T010#PS06A010T010 – l Arm
// #PS07A030T010#PS07A180T010 – l hand
// #PS08A000T010#PS08A180T010 – r Foot yaw
// #PS09A000T010#PS09A180T010 – r Foot pitch
// #PS10A000T010#PS10A180T010 – l Foot yaw
// #PS11A000T010#PS11A180T010 – l Foot pitch

// #PS00A090S01A090S02A000S03A090S04A090S05A180S06A090S07A090S08A090S09A090S10A090S11A090R000G000B000T005

TerraControl – With NodeMCU Webserver

UPDATE 3: Version 1.3

I’m working on making the code as user friendly as possible but it’s going to be a long run. I’d like to have separate html and css files but I’m still figuring it out. For now, few changes…:

  • ! ! ! included mDNS protocol, so from now on you don’t need IP address to connect to your NodeMCU, simply put terracontrol.local in your browser and you are done (you have to be on the same network, of course)
  • separate file for setting up the variables (setting.h). Unzip the file to your Projects folder, when you open the *.ino file, setting.h should be opened as well.

UPDATE 2: Version 1.2

  • improved graph displaying range
  • new values in graphs are moved to the end of array, not starting from the beginning again
  • improved light setting – it is now unlimited (ON time can now be later than OFF time)
  • code for manual defining your own server is in one place and commented by default (i.e. it is on automatic setting)
  • clearer information in serial monitor
  • unified function for min/max values in array
  • new function for printing out minute values

UPDATE 1: Please see the version 1.1 I got the graphs and statistics working! Well, sort of…the range is still not as I want it to be, but at least now it is correctly displaying min and max. Plus new mouseover feature for the individual values in the graph.

After my first attempt to create controlled terrarium using Arduino board I got my hands on NodeMCU 12E board and I knew it was going to be a big step up!

I took me a few days before I began to understand how this board works (thanks to a lot of instructables here and google of course) and the possibilities it had. It think I’m on the right path to create exactly what I was dreaming about for several years…

So what is TerraControl v1.2 capable of?

  1. 2 automatically controlled relays (light timer and heating)
  2. 2 manually controlled relays (fan, second heating)
  3. GMT time change
  4. Simple graphs with highest/lowest temperature/humidity over the last 24 hours
  5. Monitoring temperature and humidity in terrarium
  6. All accessible and adjustable through webserver using HTML and CSS

What is necessary:

  • given the nature of NodeMCU board (its output is only 3.3v) you will either have to buy 3.3V relay board, or modify 5v board, or buy I2C logic converter module – for example – $0.9
  • 5V source (I’m using older usb charger)
  • wires
  • solder
  • case/box
  • Arduino IDE

Step 1: Getting the Parts Together

Connecting these parts is easy, just look at the source code and keep in mind that GPIO’s of the NodeMCU board is different from the actual boards description (as seen on the trird picture):

//Define sensor pins
#define SENSOR_IN 15 //D8
#define SENSOR_IN_Type DHT22

//Define Relay pins
#define relayLight 5 //D1
#define relayHeat 4 //D2
#define relayFan 12 //D6
#define relayHeat2 14 //D5

i.e. DHT sensor pin goes to D8 (board’s D3, D4, D8 can’t be used as output but can be used as input), and the relay pins accordingly to the code. Remember, if you are using 5V relay, you need to modify the relay board or use I2C logic converter.

! ! ! IMPORTANT! When uploading the code to the board, you have to disconnect the DHT sensor, otherwise you will get an error when attempting to upload ! ! !

All parts can be powered with 5v power adapter

Step 2: Setup and Customization

Before we upload the code, there are few things that needs to be set up in setting.h:

//You WiFi AP
const char ssid[] = “SSID Name”; // insert your WiFi AP name
const char pass[] = “password”; // insert your WiFi password

// T E R R A R I U M S E T T I N G
float tempMin = 24; // temperature in Celsius for switching the heating ON
float tempMax = 30; // temperature in Celsius for switching the heating OFF

int humMin = 50; // minimum humidity in %
int humMax = 70; // maximum humidity in %

// hour and minute for light to go ON
int lightOn_hour = 7;
int lightOn_min = 0;

// hour and minute for light to go OFF
int lightOff_hour = 20;
int lightOff_min = 30;

// Central European Time (1 for winter time)
int timeZone = 2;

Uncomment the following part of the code if you know how to define your server manually or just run the code and get addresses from the serial monitor.

/*— UNCOMMENT THIS FOR MANUAL SETTING —
IPAddress ip(192, 168, 0, 111); //Node static IP
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip, gateway, subnet);
*/

All done? Great, let’s move on…

Step 3: Alwas ON/OFF Relay Connection

One thing I wanted was the relay board to be used as little as possible. As you probably know, relays have two possible ways of connection: ON when not used and ON when used. So I connected the light and heating to “ON when not used” (heating is almost always ON and lights are ON for about 13-14 hours every day) and fan and heating 2 to “ON when used” (I barely need to use one of them).

That is why the code for the same function is using different values:

if (heatVal == 1) {
client.println(“ON”);
} else {
client.println(“OFF”); }

AND

if (heat2Val == 1) {
client.println(“OFF”);
} else {
client.println(“ON”); }

You can of course modify the code according to your needs.

Now just connect the DHT sensor and let’s look at the result!

Step 4: Webserver

When you open the webserver you will see simple page with all information about your terrarium and some features:

  • Light ON/OFF time can be adjusted (step are: 1 hour for hour setting and 5 min for minute setting). At the moment ON time has to be earlier that OFF time (ON 22:30 and OFF 0:30 will not work – yet) – fixed in version 1.2
  • Temperature setting (steps are 0.5 degree Celsius)
  • Manualy turn ON/OFF other two relays – Fan and Heat 2 and adjust timezone when the time changes

if needed, change your timezones in following part of the code:

if (request.indexOf(“/TIMEZONE_SWITCH”) != -1) {
if (timeZone == 1) {
timeZone = 2;
setSyncProvider(getNtpTime);
} else {
timeZone = 1;
setSyncProvider(getNtpTime);
} }

  • Webserver is using automatic time synchronization

Step 5: Disclosure

I know that the HTML and CSS code could be much more simple and the coding is not really user friendly but for the moment it works as it is supposed to (only the graphs are not very accurate but I’m still working on them) and I will get to these points when I start working on version number two. I have already decided to use external power supply (in this version I just stripped the 5v adapter and soldered it inside the box) and I also want the power cables to be more accessible and easier to connect/disconnect. I hope you guys (and your pets) will appreciate this instructable, if you do, please leave a short comment. And of course, suggestions are more than welcome! Thank you

ESPway | 로봇 제어 세그웨이 스타일 와이파이 ESP8266 구축

내가 아두 이노와 임베디드 시스템 땜질 시작 이후로, 나는 자기 밸런싱, 세그웨이 같은 로봇을 구축하는 방법에 대해 매우 흥분했습니다. 인터넷의 주위에 유사한 프로젝트 및 리소스는 매우 풍부하다.

첫 번째 프로토 타입은 플라스틱 도시락 상자 안에 지어졌습니다. 그것은 아두 이노 나노 사용 원격 제어를 적외선. 그것은 사용 MPU6050 로봇의 방향을 검출하기위한 관성 측정 유닛. 균형은 매우 잘 작동하지만, 적외선 원격 제어는 매우 비실용적이고 신뢰할 수 있었다.

내가 대해 알게되었을 때이 프로젝트는 부활 ESP8266 , 매우 강력한 코어의 저렴한, 와이파이 활성화 마이크로 컨트롤러. 웹 개발에 대한 배경을 갖는, 와이파이 연결이 나에게 가능성의 세계처럼 보였다.

전통적 아두 이노 커뮤니티 원격 제어 로봇은 블루투스 통신을 이용하여 구현되어왔다. 그러나, 이것은 실질적으로 컨트롤러 소프트웨어를 각 플랫폼에 개별적으로 구현되어야한다는 것을 의미한다 (안드로이드, 아이폰 OS, PC 등)

HTML과 자바 스크립트로 구현 웹 애플리케이션은 점점 더 인기를 끌고있다. 이유 중 하나는 휴대 성이다. 웹 응용 프로그램을 한 번 작성되면, 그것은 충분히 좋은 웹 브라우저가있는 모든 플랫폼에서 실행할 수 있습니다.

ESP8266은 WiFi 액세스 포인트로 구성 될 수있다. 하나는 웹 응용 프로그램 서비스를 제공하기 ESP8266이 가능하고, 정적 페이지를 제공하는 HTTP 서버를 설정할 수 있습니다. 로봇 제어 소프트웨어는 웹 응용 프로그램으로 구현 된 경우 이제 상상! 그건 내 프로젝트 ESPway 뒤에 키 생각이다.

이 작은 로봇에 대한 코드와 회로도를 찾을 수 있습니다 GitHub의에 . 구축 개발 및 소프트웨어 사용에 대한 사전 설명이 있습니다. 또한이 사용자 설명서의 어떤 종류를 짓고 있어요. 이 프로젝트는 또한 한 레딧에 논의 나는 비디오를 게시 할 때 얼마 전에.

안전 제일

깊은 기술적 인 세부 사항에 다이빙하기 전에, 그래도 난 당신이 스스로를 구축하려고하는 경우 안전에 대해 경고한다.

전자 및 소프트웨어는이 글을 쓰는 현재의 (저전압 차단 제외) 안전 기능이 포함되어 있지 않습니다. ESP8266의 펌웨어 (이것은 아마도 수 / 노점을 충돌하는 경우  일), 회전에서 모터를 중지 아무것도 없다. 이 로봇은 작은 및 그 주변을 손상하지 충분히 빛이 내 경우에는 특별한 문제가되지 않습니다. 그러나,이 로봇의 크고 무거운 버전을 제작하기 전에 안전을 고려하시기 바랍니다. 하나는 아마도 소프트웨어 오류의 경우에 모터를 차단 할 몇 가지 안전 장치 시스템을 구현할 수 있습니다.

전자 및 기계

이 로봇 부품의 대부분은 이베이 나 AliExpress에서 공급된다. 전체 회로도는 GitHub의에서 찾을 수 있습니다. 이 프로젝트의 목표 중 하나는 가능한 한 간단하고 저렴한 전자를 유지했다.

로봇의 핵심은 ESP8266 마이크로 컨트롤러가있다. 그것은 독립 구성 요소로 사용되지하지만 거기 WEMOS D1 미니보드. 그것은 USB 커넥터와 펌웨어를 업로드하기위한 USB-에-UART 컨버터를 가지고있다.

MPU6050는 방위 센서로서 사용된다. 그것은 I2C를 통해 통신, 사용 가능한 저렴한 브레이크 아웃 보드의 많음이있다. 나는 GY-521라는 하나를 데 사용합니다.

모터는 통합 금속 기어 박스와 평범한 오래된 DC 모터입니다. 공칭 회전 속도는 300 rpm으로, 그리고 그들은 6V에 대한 평가된다. 하나는 “N20의 300RPM”또는 “12ga의 300RPM”를 검색하여 이러한 모터를 찾을 수 있습니다.

모터가 구동되어 L293D 듀얼 H 브리지 모터 드라이버 IC. 그 로봇을 구축 할 때 내가 손에 가지고 무엇 때문에이 IC는 주로 선택되었다. 바이폴라 트랜지스터의 출력은 다리를 건너 큰 전압 강하를 생산 이제 나는 배웠다. 결국 내가 가진 드라이버 교체 할 수 있습니다 DRV8833 MOSFET 출력을 가지고있다.

나는 로봇에 전력을 공급하기 위해 2 셀 리튬 폴리머 배터리를 사용하고 있습니다. 완전히 충전 된 때 ~ 8.4 볼트를 제공합니다. 전지 전압은 ESP8266의 아날로그 입력을 통해 모니터되고, 배터리 전압이 소정의 임계 값 아래로 떨어질 때, 모터를 차단하는 선택적인 특징이있다. 즉 리튬 폴리머 배터리를 사용하는 것이 일반적이다. 아날로그 입력 범위는 0-1 볼트이다. 3.3 다음 D1 미니 보드, 이미 1의 비율로 분압기있다. 따라서 I은 아날로그 입력 범위에 적합하도록 배터리 전압 스케일링 1:10 비율로 수정 한 저항을 추가했다.

마지막으로,이 WS2812B의 NeoPixels은 로봇의 “눈”으로 추가됩니다. 그들은 (OTA 업데이트 등을 진행있을 경우이 떨어진 경우) 로봇의 현재 상태를보고 매우 유용 증명

크기와 무게의 최적화를 설계 목표로 설정 한 것을 다른 역학에 대해 말을 많이가 아니다. 프로토 타입 몸은 4mm 합판의 일부 조각의 내장 및 에폭시와 함께 붙어있다.

로봇의 일반보기

소프트웨어 플랫폼

현재 자원과 ESP8266에 소프트웨어를 개발하기위한 지원의 재산이있다. 제조업체 Espressif하는 RTOS없이 운영 체제와 다른 하나 하나가 제공하는 두 개의 SDK가 있습니다. 도있다 아두 이노 코어 의 심바 크로스 플랫폼 RTOS 프레임 워크와 MicroPython은 . 새로운 언어와 프레임 워크가 큰 인 지금 가끔씩 튀어 나올 것 같다!

이 로봇에 대한 몇 가지 프로토 타입을 사용하여 아두 이노 코어에서 수행 된 PlatformIO를 빌드 시스템으로. 프로토 타입 작업은에서 찾을 수 있습니다 해당 지점 GitHub의의 REPO의.

그러나 최대의 유연성과 제어를 위해, 나는 제조업체의 “비 OS”SDK로 전환. 하나는이 마이크로 컨트롤러와 함께 얻을 수있는 즉 약으로 기본입니다. 나는 특히,이 SDK에 사용할 멋진 도서관이 있었다 찾을 수 기쁘게 생각 libesphttpd 간단한 HTTP 서버와 파일 시스템을 구현한다. 그것은 또한 웹 소켓 통신 시설을 갖추고으로이 프로젝트를위한 안성맞춤이었다.

모바일 웹 UI

로봇에 전원을 공급하고, WiFi 액세스 포인트에 클라이언트 장치를 연결 한 후, 하나는 기본 IP 주소에서 웹 브라우저 사용자 인터페이스를 열 수 있습니다 192.168.4.1.

나는 가능한 한 간단하게 UI를 유지하기 위해 노력했다. 그것은 본질적으로 HTML5 캔버스에 그려진 가상 “조이스틱”로 구성되어 있습니다. 터치 디바이스에서 휴대 전화 등, 꽤 직관적 인 느낌.

조정에 사용되는 사용자 인터페이스.

의 URL에서 로봇의 PID 매개 변수의 온라인 튜닝을위한 UI도 있습니다 /pid. 그것은 진행중인 작품이지만, 반 사용 가능한 상태에서 이미. 그것은 본질적으로 펌웨어를 매개 변수가 변경 될 때마다 다시 깜박하지 않고 한 번에 로봇을 조정 할 수 있습니다. 하나는 UI를 통해 플래시 메모리에 조정 매개 변수를 저장할 수 있습니다.

초기 PID 튜닝 사용자 인터페이스를 제공합니다.

웹 소켓을 통해 대기 시간이 짧은 통신

아마이 프로젝트의 가장 흥미로운 부분은 낮은 지연 시간 원격 제어를 달성하는 방법이다.

전통적으로 사람들은 ESP8266에 HTTP API가 어떤 종류의를 구현하고있다. 그것은 각 명령에 대해 별도의 URL가 있다는 것을 의미한다. 예는 로봇 차, 같은 URL이있을 것 /forward/backward/stop/turn-left/turn-right등 다음 만들 것 클라이언트 응용 프로그램 AJAX의 로봇을 제어하는 요청을. 그러나, TCP 연결을 열고 모든 명령에 구문 분석 HTTP 헤더가있을 것입니다 의미합니다. 즉, 불필요한 오버 헤드 및 지연을 도입한다. 이 컨트롤은 그런 식으로 매우 부드러운 없을 것이다.

더 나은 대안은 열려있는 TCP 소켓을 유지하고 두 방향으로 그것을 통해 정보를 전송하는 것입니다. ESP8266 원시 TCP 통신을위한 일류 지원을하고 있지만, 자바 스크립트 하나는 원시 TCP 소켓을 열 수 없습니다. 대신있다 WebSockets를 정의 된 핸드 쉐이킹 프로토콜 및 데이터 프레임 포맷 첨가 TCP 소켓이다. 때문에 libesphttpd웹 소켓 구현을 가지고, 나는이 세부 사항에 대해 걱정하지 않았지만, 단지 데이터 패킷을 교환한다.

데이터 패킷의 첫 번째 바이트에 해당되는 명령을 표시하고, 이후의 추가 바이트 데이터이다 : 거기 로봇와 UI 사이에 통신하는 매우 단순한 프로토콜이다. 부가 데이터의 길이는 각각의 명령에 대한 알려진 고정된다. 예를 들어, 클라이언트에 의해 전송 된 “스티어링”데이터 패킷은 3 바이트로 구성 첫 번째 바이트 (즉, 같은 코드로 정의되어 제로 STEERING). 두번째 바이트는 원하는 속도를 나타내고, 세 번째는 회전 속도를 나타내는 (네거티브 = 좌, 포지티브 = 우측). 이 경우, 두 번째 및 세 번째 바이트는 8 비트 부호있는 정수로 해석된다. 데이터 바이트의 해석은 문제의 명령에 따라 달라집니다.

부드러운 양방향 통신을 감안할 때, 하나는 멋진 모든 종류의 것들을 구현할 수 있습니다. 예를 들어, 로봇은 클라이언트 웹 응용 프로그램에서 배터리 모니터링을 허용, 연결된 모든 클라이언트에 현재 배터리 독서를 보낼 수 있습니다. 또한, 가장 실용적인 것들 중 하나는 PID 컨트롤러 매개 변수의 온라인 튜닝이다.

데이터 바이트의 C 코드, 조작 및 천연 재 해석된다. 자바 스크립트에서는, 이진 데이터는로 표현되는 ArrayBuffer원시 이진 데이터의 블록의 표현은 본질적이다. 액세스 및 수정하려면, 하나는 사용할 수 있습니다 DataView기본 바이너리 버퍼에 바이트 수준의 액세스를 제공한다. 하나는 예를 들어 “바이트의 16 비트 부호없는 정수 (리틀 엔디안)로 13 쓰기 버퍼의 처음부터 오프셋 2″라고 할 수있다. 나는 자바 스크립트 API를 제공 낮은 수준의 제어가 찾을 수 놀랐다.

고정 소수점 센서 퓨전

I2C를 통해 MPU6050와 통신하는 것은 쉽다. 하나는 1 kHz에서 업데이트되는 세 축의 가속도와 자이로 측정치를 포함하는 하드웨어 레지스터를 판독 할 수있다. 배향으로이 값을 변환하는 과정은 “센서 퓨전”라고한다. 거기를 수행하는데 사용될 수 센서 자체로 신호 처리 코어이고,이 우수한 I2Cdevlib것을 구현한다. 그러나, 내가하고 싶지 않은 무언가 센서에 바이너리 펌웨어 덩어리를 업로드해야합니다. 또한, 그 알고리즘은 미가공 데이터는 1 kHz에서 사용할 경우에도 200 Hz의 샘플링 레이트만을 할 수있다.

주어진 ESP8266가 가진 32 비트 코어를 가지고 16 * 16 -> 32 비트 곱셈 확대, I 센서 융합하는 대신에 구현 될 수 있다고 생각. 가장 특히, 선택할 수있는 많은 알고리즘이 있습니다 보완 필터 , 칼만 필터 와 Madgwick 필터 . 후자는 독창적으로 작동 최첨단 신규 알고리즘 쿼터니온 방향의 표현. 또한이 시작하는 데 사용할 수 몇 가지 예제 코드이었다, 그래서 Madgwick 알고리즘이 선택되었다.

ESP8266는 부동 소수점 유닛이 골대를 벗어났습니다하고, 부동 소수점 연산은 소프트웨어로 구현해야합니다. 즉, 복잡한 비즈니스 컴파일러 지원 라이브러리에서 수행되었지만, 그것은 아주 느리다. 따라서, 나는 완전히 알고리즘의 부동 소수점 숫자의 사용을 방지하기 위해 원했다. 따라서 나는 Q16.16에 샘플 코드를 번역하기로 결정했습니다 고정 소수점 숫자 표현을 . 고정 점은 우리가 기본적으로 정수를 위해 노력하고 있지만, 16 최하위 바이트가 소수 부분으로 촬영 한 것을 의미한다.

구현에 대한 하나 개의 좋은 실용적인 세부 다음 Madgwick 알고리즘에, 하나는 어떤 경우에 벡터와 사원 수를 정상화해야한다. 이 경우 정규화는 제곱근으로 나눈 것을 의미한다. ESP8266의 핵심은 하드웨어 부문을 가지고 있지 않기 때문에이 소프트웨어에서 구현 될 필요가 있습니다. 동일은 제곱근에 적용됩니다. 우리는 어떻게 든 그것을 피할 수있는 경우에 따라서는 개별적으로 두 작업을 수행하는 것이 훨씬 이해가되지 않습니다. 반면에, 곱셈 연산의 측면에서 상대적으로 저렴합니다. 제곱근 나누면 제곱근의 역수를 곱한 것과 같다. 즉 여기에서 이루어졌다 무슨 – 상호 제곱근 함수의 라인을 따라 구현 이 StackOverflow의 대답 .

캐스케이드 PID 제어

어떻게 로봇이 실제로 균형을 유지합니까? 지금까지 우리는 로봇의 방향의 좋은 평가가 있습니다. 어떻게 든 적합한 모터 출력 신호로 변환되어야한다.

대답 할 두 가지 질문이 있습니다 :

  1. 로봇의 기울기 각도는 균형을 유지하기 위해 무엇을해야 하는가?
  2. 어떤 모터 출력 전력은 소정 경사각을 달성해야 하는가?

캐스 캐 이드 :이 자연스럽게 종종 자기 밸런싱 로봇에 구현 된 제어 전략에 이르게 PID 컨트롤러 . PID 제어에 대한 소개, 나는 기사 추천 박사 학위없이 PID를 팀 웨스콧에 의해. 본질적으로, 제 제어부는 입력으로서 원하는 속도를 취득하는 속도를 달성하기 위해 경사 각도를 제어한다. 바람직한 경사각은 그 각도를 달성하기 위해 모터 출력을 조정하는 제 제어기에 공급된다.

물론, 상기 제 2 제어부는 MPU6050 관성 측정 유닛을 통해 피드백을 얻는다. 한편, 현재 속도의 피드백을 얻는 것은 사소한 일이 아니다. 하나는 모터 샤프트에 회전 인코더를 설치하여 그것을 달성 할 수있다. 비용을 최소화하고 회로를 단순화하기 위해, 나는 그것을 밖으로 떠났다. 대신에, 내 코드에 사용되는 조 근사있다 : 속도 피드백이 단기 변동을 취소하기 위해 평활화 모터 구동 신호로부터 취해진 다. 이 사실은 놀라 울 정도로 잘 작동합니다!

또한, 단순한 형태의 게인 스케줄링은 로봇이 낙하하려고하는 상황에서 사용된다. 높은 비례 이득 PID 계수들의 상이한 세트는 다시 안정성을 달성하기 위해로드된다. 아래의 비디오 (일부 fallovers와 함께) 당신은 행동에서 볼 수 있습니다.

여기에 설명 된 제어 방식은 자기 밸런싱 로봇을 구현하는 유일한 방법은 아니다. 참고 이 문서 로봇의 동적 모델을 기반으로 제어 방식과 비교합니다.

소프트웨어 드라이버

마지막으로을의이 ESP8266 프로그래밍의 일부 실용성을 논의하자.

이 마이크로 컨트롤러에 하나의 문제는 하드웨어 주변의 부족이다. 특히, 칩상의 I2C 또는 PWM 어떠한 하드웨어 구현은 없다. 그들은 소프트웨어로 구현되어야한다. 문제는 매우 동일한 프로세서 코어 끊임없이 무선 통신을 처리하는 것으로한다. 그래서, 다른 소프트웨어 루틴은 와이파이 인터럽트에 의해 중단 얻을 수 있습니다. I2C 및 PWM 모두 타이밍에 대한 중요하기 때문에 그것은 약간의 문제입니다.

PWM 및 I2C의 소프트웨어 구현은 Espressif SDK와 함께 번들로 제공됩니다. 그러나 글을 쓰는, 그들은 어떤 식 으로든하거나 비효율적에 결함이 있습니다. 다행히, 지역 사회에서 어떤 똑똑한 사람들은 자신의 드라이버를 출시했다. I 사용하여 결국 ESP8266_new_pwm정확한 타이밍 안정된 PWM 신호를 실현할 NMI 인터럽트를 사용 스테판 브루엔스 의해. 모터는 2 kHz에서 PWM으로 공급된다.

I2C를 들어,라는 빠른 조립 구현 brzo_i2c파스칼 커턴스키으로 사용 하였다. 나는 I2C 거래 중에 완전히 비활성화 인터럽트 때문에 처음에는 I2C 드라이버에 약간의 문제가 있었다. 이는 결국 일부 WiFi를 발사 할 수없는 방해 아마도에, 펌웨어 충돌로했다. 즉, 쉽게 인터럽트를 비활성화 명령을 주석에 의해 수정되었습니다. 즉, I2C 타이밍을 타협하지만, 실제로는 모든 것이 매우 잘 작동하고있다.

피드백

이 문서에서 설명하는 무언가의 더 정교한 설명을 좋아하거나 해결하기 위해 발견 뭔가를했을 경우,이 사이트에 문제를 제기하십시오 GitHub의의의 repo . 당신은 또한에 연락처 찾을 수 있습니다 이 페이지를 . 모든 의견은 매우 환영하고 감사합니다.

ESPway | A Segway-style WiFi controlled robot built on ESP8266

Ever since I started tinkering with Arduino and embedded systems, I’ve been pretty excited about building a self-balancing, Segway-like robot. There’s a wealth of similar projects and resources around the Internet.

The first prototype was built inside a plastic lunch box. It used an Arduino Nano and infrared remote control. It used the MPU6050 inertial measurement unit for detecting the orientation of the robot. The balancing worked very well, but the infrared remote control was quite impractical and unreliable.

The project was revived when I learned about ESP8266, a cheap, WiFi enabled microcontroller with a pretty powerful core. Having some background in web development, the WiFi connectivity looked like a world of possibilities to me.

Traditionally in the Arduino community, remote controlled robots have been implemented using Bluetooth for the communication. However, this practically means that the controller software has to be implemented separately on each platform (Android, iOS, PC, etc.)

Web applications implemented with HTML and JavaScript are becoming more and more popular. One of the reasons is the portability. When the web app has been written once, it can be run on any platform which has a good enough web browser.

The ESP8266 can be configured as a WiFi access point. One can set up a HTTP server serving static pages, making the ESP8266 able to serve web apps. Now imagine if the robot control software was implemented as a web application! That is the key idea behind my project ESPway.

The code and schematics for this little robot can be found on GitHub. There are preliminary instructions on building, developing and using the software. I’m also building some kind of a user manual there. The project was also discussed on Reddit a while ago when I posted the video.

Safety first

Before diving deeper in the technical details, I though I should warn you about safety in case you are going to build this yourself.

The electronics and software don’t contain any safety features (except low voltage cutoff) as of writing this. If the firmware on the ESP8266 crashes / stalls (it can and probably will happen), there’s nothing stopping the motors from spinning. This is not a particular issue in my case where the robot is small and light enough to not damage its surroundings. However, please consider the safety before building a larger and heavier version of this robot. One could probably implement some failsafe system which would shut off the motors in case of a software failure.

Electronics and mechanics

Most of the parts for this robot are sourced from eBay or AliExpress. The complete schematic can be found on GitHub. One of the goals of this project was to keep the electronics as simple and cheap as possible.

At the core of the robot there is the ESP8266 microcontroller. It is not used as a standalone component but there’s a WEMOS D1 mini board. It has a USB connector and a USB-to-UART converter for uploading the firmware.

The MPU6050 is used as the orientation sensor. It communicates via I2C, and there’s a plenty of affordable breakout boards available. I used one called GY-521.

The motors are plain old DC motors with an integrated metal gearbox. The nominal revolution rate is 300 rpm, and they are rated for 6V. One can find these motors by searching for “n20 300rpm” or “12ga 300rpm”.

The motors are driven by the L293D dual H-bridge motor driver IC. This IC was chosen mostly because that’s what I had at hand when building the robot. Now I’ve learned that the bipolar transistor outputs produce a significant voltage drop across the bridge. Eventually I’ll replace the driver with a DRV8833 which has MOSFET outputs.

I’m using a 2-cell LiPo battery for powering the robot. It gives ~8.4 volts when fully charged. The battery voltage is monitored via the analog input of the ESP8266, and there’s an optional feature to cut off the motors when the battery voltage falls under a certain threshold. That’s common practice used with LiPo batteries. The analog input range is 0-1 volts. On the D1 mini board, there already is a voltage divider with a ratio of 1:3.3. Hence I only had to add one resistor to modify the ratio to 1:10, which scales the battery voltage to fit the analog input range.

Finally, two WS2812B NeoPixels are added as the “eyes” of the robot. They have proven quite useful for reporting the current state of the robot (if it has fallen, if there’s OTA update in progress etc.)

There’s not much to say about the mechanics, other that that optimization of size and weight were set as design goals. The prototype body was built out of some pieces of 4mm plywood and glued together with epoxy.

A general view of the robot

Software platform

Nowadays there is a wealth of resources and support for developing software on the ESP8266. There are two SDKs offered by the manufacturer Espressif, one with a RTOS and the other one with no operating system. There is also an Arduino core, the Simba cross-platform RTOS framework and MicroPython. New languages and frameworks seem to pop out every now and then, which is great!

Some prototyping for this robot was done on the Arduino core, using PlatformIO as the build system. The prototyping work can be found in the corresponding branch of the GitHub repo.

However, for maximum flexibility and control, I switched to the manufacturer’s “non-OS” SDK. That is about as native as one can get with this microcontroller. I was pleased to find there were some great libraries available for this SDK, particularly libesphttpd which implements a simple HTTP server and a filesystem. It was a great fit for this project as it also features WebSocket communication facilities.

Mobile web UI

After powering on the robot and connecting a client device to the WiFi access point, one can open the user interface with a web browser at the default IP address 192.168.4.1.

I tried to keep the UI as simple as possible. It essentially consists of a virtual “joystick” drawn on a HTML5 canvas. On a touch device such as a mobile phone, it feels quite intuitive.

The user interface used for steering.

There is also a UI for on-line tuning of the robot’s PID parameters at the url /pid. It is a work in progress, but it’s already in a semi-usable state. It essentially allows tuning the robot in one pass without re-flashing the firmware every time the parameters are changed. One can save the tuned parameters to the flash memory via the UI.

The initial PID tuning user interface.

Low latency communications via a WebSocket

Probably the most interesting part of this project is the method of achieving low latency remote control.

Traditionally people have been implementing some kind of HTTP APIs on the ESP8266. It means that there’s a separate URL for each command. E.g. for a robot car, there would be URLs like /forward/backward/stop/turn-left/turn-right etc. The client application would then make AJAX requests to control the robot. However, that means there would be a TCP connection opened and a HTTP header parsed on every command. That introduces unnecessary overhead and latency. The control would not be very smooth that way.

A better alternative is to keep the TCP socket open and send information over it in two directions. While the ESP8266 has first-class support for raw TCP communication, in JavaScript one can’t open raw TCP sockets. Instead there are WebSockets which are TCP sockets added with a defined handshaking protocol and a data frame format. Because libesphttpd has a WebSocket implementation, I didn’t have to care about these details but just exchange data packets.

There’s a very simple protocol in the communication between the robot and the UI: the first byte of a data packet indicates which command is in question, and the subsequent bytes are additional data. The length of the additional data is known and fixed for each command. For example, a “steering” data packet sent by the client consists of three bytes: the first byte is zero (that’s defined in the code as STEERING). The second byte indicates the desired speed and the third one indicates turning rate (negative = left, positive = right). In this case the second and third byte are interpreted as 8-bit signed integers. The interpretation of the data bytes depends on the command in question.

Given smooth two-way communication, one can implement all kinds of cool things. For example, the robot can send the current battery reading to all connected clients, allowing battery monitoring in the client web app. Also, one of the most practical things is on-line tuning of the PID controller parameters.

In the C code, manipulation and reinterpretation of the data bytes is natural. In JavaScript, binary data is represented as an ArrayBuffer which is essentially a representation of a block of raw binary data. To access and modify it, one can use a DataView, which gives byte level access to the underlying binary buffer. One can e.g. say “write 13 as a 16-bit unsigned integer (little Endian) at byte offset 2 from the beginning of the buffer”. I was actually surprised to find there is such low level control available in the JavaScript APIs.

Fixed-point sensor fusion

Communicating with the MPU6050 via I2C is easy. One can read the hardware registers which contain acceleration and gyro readings on three axes that are updated at 1 kHz. The process of translating these values into an orientation is called “sensor fusion”. There is a signal processing core in the sensor itself that could be used to do that, and the excellent I2Cdevlib implements that. However, that requires uploading a binary firmware blob on the sensor, which is something I did not want to do. In addition, that algorithm is only capable of 200 Hz sample rate even though the raw data is available at 1 kHz.

Given that the ESP8266 has a 32-bit core with 16*16 -> 32-bit widening multiplication, I thought the sensor fusion could be implemented on that instead. There are many algorithms to choose from, most notably the complementary filterKalman filter and Madgwick filter. The latter is a state-of-the-art novel algorithm which works cleverly with the quaternion representation of the orientation. Additionally there was some sample code available to get started with, so the Madgwick algorithm was chosen.

The ESP8266 misses a floating point unit, and the floating point operations must be implemented in software. That complex business has been done in the compiler support libraries, but it is quite slow. Hence, I wanted to entirely avoid the usage of floating point numbers in the algorithm. Therefore I chose to translate the sample code to the Q16.16 fixed point number representation. Fixed point means that we’re essentially working integers but the 16 least significant bytes are taken to be the fractional part.

One nice practical detail about the implementation: in the Madgwick algorithm, one has to normalize vectors and quaternions on some occasions. Normalization in this case means dividing by a square root. ESP8266’s core doesn’t have hardware division, so it has to be implemented in the software. The same applies for the square root. Thus it doesn’t make much sense to do both operations individually if we could avoid it somehow. On the other hand, multiplication is relatively cheap in terms of operations. Dividing by the square root is equivalent to multiplying by the reciprocal of the square root. That’s what was done here – a reciprocal square root function was implemented along the lines of this StackOverflow answer.

Cascade PID control

How does the robot actually maintain the balance? So far we have a nice estimate of the orientation of the robot. It has to be somehow translated to a suitable motor output signal.

There are two questions to answer:

  1. What should the tilt angle of the robot be in order to stay balanced?
  2. What should the motor output power be to achieve the desired tilt angle?

This naturally leads to a control strategy that is often implemented in self-balancing robots: a cascaded PID controller. For an introduction on PID control, I recommend the article PID without a PhD by Tim Wescott. Essentially, the first controller gets the desired velocity as an input and controls the inclination angle to achieve that velocity. The desired inclination angle is fed to a second controller which regulates the motor output power to achieve that angle.

Naturally, the second controller gets feedback via the MPU6050 inertial measurement unit. On the other hand, getting feedback of the current velocity is not a trivial task. One could achieve that by installing rotation encoders on the motor shafts. In order to minimize the cost and simplify the circuitry, I left that out. Instead, there’s a crude approximation used in my code: the velocity feedback is taken from the motor drive signal which is smoothed in order to cancel short-term variations. This actually works surprisingly well!

In addition, a simple form of gain scheduling is used in situations where the robot is about to fall. A different set of PID coefficients with higher proportional gain is loaded in order to reach stability again. You can see this in action (along with some fallovers 😉 in the video below.

The control scheme described here is not the only way to implement self-balancing robots. See this articlefor comparison with a control scheme based on a dynamic model of the robot.

Software drivers

Last but not least, let’s discuss some practicalities of programming the ESP8266.

One problem with this microcontroller is the lack of hardware peripherals. In particular, there are no hardware implementations of I2C or PWM on the chip. They have to be implemented in software. The problem is that the very same processor core has constantly handle the WiFi communication. So, any other software routine might get interrupted by the WiFi interrupts. That’s a bit of a problem since both I2C and PWM are critical about timing.

Software implementations of PWM and I2C are bundled with the Espressif SDK. However, as of writing, they are flawed in some way or just inefficient. Luckily, some smart people in the community have rolled their own drivers. I ended up using ESP8266_new_pwm by Stefan Bruens, which uses NMI interrupts to realize a stable PWM signal with correct timing. The motors are fed with 2 kHz PWM.

For I2C, a fast assembly implementation called brzo_i2c by Pascal Kurtansky was used. I had some problems with the I2C driver at first since it completely disabled interrupts during I2C transactions. That eventually led to the firmware crashing, probably due to some WiFi interrupt not being able to fire. That was easily fixed by commenting out the instruction that disabled the interrupts. That compromises the I2C timing, but in practice everything has been working very well.

Feedback

If you would like a more elaborate description of something described in this article or have found something to fix, please file an issue on this site’s GitHub repo. You can also find contact details on this page. Any feedback is very welcome and appreciated.

LED Matrix Bar Weather Station V1

Features:
– ESP8266 WeMos Dq mini module which I finally found good application for (now you can buy better cheap ESPs)
– 6 x LEDMatrix module with MAX7219 driver
– supplied directly from USB port with USB plug
– all data are synchronized every 7-8 minutes
– time and date are taken from google.com
– weather informations are grabbed from openweather.org JSON api
– in the future also other news and infos grabbing can be possible
– no hardware RTC clock is necessary
– responsive web(UI) design

+ internal temperature, humidity sensor (options – DS18B20, DHT22, DHT12)
+ ESP8266 setup as a Wi-Fi Web Server (WiFiManager, OTA, mDNS)
+ receives a message input from a User Input page, then displays the message on a scrolling LED matrix display.

– 6 x MAX7219 8 x 8 LED Matrix module
– 1 x WeMos D1 mini
– 1 x Interface Shield

Source code is available here:
The code is being cleaned up. Please wait… I’ll share it soon.

3D Parts:
https://www.thingiverse.com/thing:2650808

 

NOTE: Recently added support for rotated LED Matrices

Inspired by and source code from:
https://www.youtube.com/watch?v=2I_us…

저장저장

저장저장

ESP8266 and Visuino: Control Servo Remotely over Wi-Fi with Rotary Encoder

ESP8266 modules are great low cost stand alone controllers with built in Wi-Fi. In this Instructable I will show you how you can control a Servo remotely over Wi-Fi with a Rotary Encoder. The Instructable is a similar but more advanced version of the “Arduino Nano and Visuino: Control Servo with Rotary Encoder” Instructable.

In the Instructable, I will use 2 NodeMCUmodules. One version 0.9, and the other 1.0. The NodeMCU are the easiest way to program and experiment with ESP8266controllers. This Instructable however can easily be done with other modules, and the Servo module can even use ESP-01 module as it needs only one GPIO pin to connect to the Servo.

Step 1: Components

  1. NodeMCU ESP8266 boards (I used both NodeMCU 0.9, and NodeMCU 1.0 versions, but any other combination, or even stand alone ESP-12 will work)
  2. One Rotary Encoder module I got from this cheap 37 sensors set.
  3. 1 Small Servo
  4. 8 Female-Female jumper wires
  5. 3 Male-Female jumper wires

Step 3: Connect the Servo to the second NodeMCU ESP8266 Module

Connect the Servo to the second NodeMCU ESP8266 Module
56ac0dec15be4d97d90007e9.jpeg 56ac0e234fbadef83c00027d.jpeg 56ac14164936d4a6440009e1.jpeg

To simplify this Instructable, we will connect the Power from the NodeMCU to the Servo, In real projects, you will need to have a dedicated power supply for the servo! Please look at this Instructable to see how you can connect the Servo to external power.

  1. Connect Ground(Black wire),Power(Red wire), and Control(Orange wire) to the Servo (Picture 1)
  2. Connect the other end of the Power wire(Red wire) to the 5V(Called “Vin” in NodeMCU version 1.0) Power pin of the ESP8266 NodeMCU module (Picture 2)
  3. Connect the other end of the Ground wire(Black wire) to the Ground pin of the ESP8266 NodeMCU module (Picture 2)
  4. Connect the other end of the Control wire(Orange wire) to the Digital pin 2of the ESP8266 NodeMCU module (Picture 3)
  5. Picture 4 shows where are the Ground, 5V(Vin) Power, and Digital 2 pins of the NodeMCU 0.9

Step 4: Start Visuino, and select the ESP8266 Board type

Start Visuino, and select the ESP8266 Board type
ESP8266.png

To start programming the Arduino, you will need to have the Arduino IDEinstalled from here: http://www.arduino.cc.

Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work!

If you have not done follow the steps in this Instructable to setup the Arduino IDE to program ESP 8266!

The Visuinohttps://www.visuino.com also needs to be installed.

  1. Start Visuinoas shown in the first picture
  2. Click on the “Tools” button on the Arduino component (Picture 1) in Visuino
  3. When the dialog appears, select “NodeMCU ESP-12” as shown on Picture 2

Step 5: In Visuino: Setup the module as Access Point

In Visuino: Setup the module as Access Point
AccessPointConfigEnable.png AccessPointConfigIP.png
  1. In the Object Inspector, expand the “Modules” property, then the “WiFi” sub property, then the “AccessPoint: sub property (Picture 1)
  2. Set the value of the “SSID” sub property of the “AccessPoint”, to “ServoRemote” (Picture 1)

To make sure the Access Point will be on the 200.200.200.X subnet, we need to assign a fixed address.

  1. In the Object Inspector, expand the “Config” sub property of the “AccessPoint” property (Picture 2)
  2. Set the value of the “Enabled” sub property of the Config to “True” (Picture 2)
  3. Set the value of the “IP” sub property to “200.200.200.100” (Picture 3)

Step 6: In Visuino: Add an UDP Socket for the communication

In Visuino: Add an UDP Socket for the communication
SocketsAddUDP.png SocketsRemoteIP.png SocketsRemotePort.png

Next we need to add an UDP socket for the communication.

  1. In the Object Inspector, click on the “…” button next to the value of the “Sockets” sub property of the “WiFi” property (Picture 1)
  2. In the Sockets editor select “UDP Socket”, and then click on the “+” button (Picture 2)
  3. In the Object Inspector, set the value “RemoteIPAddress” property to “200.200.200.200” (Picture 3) – this is the fixed IP address that we will assign to the other module later on
  4. In the Object Inspector set the value of the “RemotePort” to “8888” (Picture 4)
  5. Close the “Sockets” editor.

Step 7: In Visuino: Add and connect Rotary Encoder component

In Visuino: Add and connect Rotary Encoder component
ComponentRotaryConnect1.png
ComponentRotaryConnect2.png
  1. Type “rotar” in the Filter box of the Component Toolbox then select the “Rotary Encoder Sensor” component (Picture 1), and drop it in the design area
  2. Connect the “Out” pin of the Digital[ 2 ] channel of the “NodeMCU ESP-12″component to the “Clock(A)” pin of the RotaryEncoderSensor1(Picture 2)
  3. Connect the “Out” pin of the Digital[ 3 ] channel of the”NodeMCU ESP-12″

    component to the “Direction(B)” pin of the RotaryEncoderSensor1(Picture 3)

Step 8: In Visuino: Add and connect Up/Down Counter component

In Visuino: Add and connect Up/Down Counter component
ComponentCounterInitialValue.png
ComponentCounterMinRollOver.png
ComponentCounterMinValue.png
ComponentCounterMaxRollOver.png
ComponentCounterMaxValue.png

We need a counter to count the Up/Down rotations from 0 to 100, and we need to set in in the middle/neutral 50:

  1. Type “count” in the Filter box of the Component Toolbox then select the “Up/Down Counter” component (Picture 1), and drop it in the design area
  2. In the Object Inspector set the value of the InitialValue property to 50(Picture 2)
  3. In the Object Inspector expand the Counter’s Min property
  4. In the Object Inspector set the value of the RollOver sub property to False(Picture 3)
  5. In the Object Inspector set the

    value of theValue sub property to 0 (Picture 3)

  6. In the Object Inspector expand the Counter’s Max property(Picture 5)
  7. In the Object Inspector set the

    value of theRollOver sub property to False(Picture 5)

  8. In the Object Inspector set the value of the Value sub property to 100(Picture 6)

Step 9: In Visuino: Connect the Up/Down Counter component

In Visuino: Connect the Up/Down Counter component
ComponentCounterConnect2.png
ComponentCounterConnect3.png
PullUp.png
  1. Connect the “Down” pin of the RotaryEncoderSensor1 component to the “Down” pin of the UpDownCounter1 component (Picture 1)
  2. Connect the “Up” pin of the RotaryEncoderSensor1 component to the “Up” pin of the UpDownCounter1 component (Picture 2)
  3. Connect the “Out” pin of the” Digital[ 4 ]” channel of the “NodeMCU ESP-12” component to the “Reset” pin of the UpDownCounter1 (Picture 3)

The Rotary encoder module switch that I have does not have pull up resistor. The ESP8266 however has built-in optional pull-up resistors for the pins. To enable the pull-up resistor for the Digital pin 4:

  1. In the Object Inspector expand the “Digital” property, then the “Digital[ 4 ]” sub property (Picture 4)
  2. In the Object Inspector set the value of the IsPullUp sub property to True(Picture 4)

Step 10: In Visuino: Add and connect Integer To Analog component

In Visuino: Add and connect Integer To Analog component
ComponentIntToAnalogScale.png
ComponentIntToAnalogConnect.png

The servo needs analog value in the range between 0 and 1.0, so we need to convert the count to Analog and multiply it by 0.01 to convert the 0 to 100 range into Analog 0 to 1.0:

  1. Type “To Analo” in the Filter box of the Component Toolbox then select the “Integer To Analog” component (Picture 1), and drop it in the design area
  2. In the Object Inspector set the Scale property to 0.01 (Picture 2) . This will convert the counter values from the integer range of 0 to 100, to the analog range of 0.0 to 1.0.
  3. Connect the “Out” pin of the UpDownCounter1 to the “In” pin of the IntegerToAnalog1 component (Picture 3)

Step 11: In Visuino: Add and Make Structure component, and add Analog channel to it

In Visuino: Add and Make Structure component, and add Analog channel to it
ComponentMakeStructTools.png
ComponentSplitAddChannel1.png
ComponentSplitAddChannel2.png

We need to send the analog value over the UDP. To do that we will make a structure with analog value and will send it over the UDP socket.

  1. Type “make” in the Filter box of the Component Toolbox then select the “Make Structure” component (Picture 1), and drop it in the design area
  2. Click on the “Tools” button (Picture 2) to open the “Elements” editor (Picture 3)
  3. In the “Elements” editor select the “Analog” element, and then clickon the “+” button (Picture 3) to add an Analog element (Picture 4)
  4. Close the “Elements” editor.

Step 12: In Visuino: Connect the Make Structure component

In Visuino: Connect the Make Structure component
ComponentMakeStructConnect2.png
ComponentMakeStructConnect3.png
  1. Connect the “Out” pin of the MakeStructure1 component to the “In” pin of the “Modules.WiFi.Sockets.UDPSocket1” of the “NodeMCU ESP-12” component (Picture 3)
  2. Connect the the “In” pin of the “Elements.Analog1” element of the MakeStructure1 component to the “Out” pin of the IntegerToAnalog1component (Picture 3)

Step 13: Generate, Compile, and Upload the ESP8266 code for the Rotary Encoder Module

Generate, Compile, and Upload the ESP8266 code for the Rotary Encoder Module
Arduino IDE.png
  1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
  2. Connect the first NodeMCU module (The one with the Rotary Encoder) with USB cable to the computer
  3. Select the board type and serial port as I have shown you in this Inctructable
  4. Make sure you have installed the latest staging version of the ESP support! The stable release does not have some of the latest features, and you will have errors when you try to compile!
  5. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

Step 14: In Visuino: Select the ESP8266 Board type, and configure it to connect to the Access Point

 In Visuino: Select the ESP8266 Board type, and configure it to connect to the Access Point
AccessPointsAdd.png
AccessPointsSSID.png
AccessPointsConfigEnable.png
AccessPointsConfigIP.png

Now lets program the Servo module.

  1. Start new project.
  2. Click on the “Tools” button on the Arduino component, and when the dialog appears, select “NodeMCU ESP-12” as you did in Step 4 for the Rotary Encoder module

Next we need to configure the module to connect to the Access Point of the Thermometer module, and use a fixed IP Address of 200.200.200.200

  1. In the Object Inspector, expand the “Modules” property, then the “WiFi” sub property, then the “AccessPoints” sub property, and click on the “…” button next to its value (Picture 1)
  2. In the “AccessPoins” editor, select “WiFi Access Point”, and then click on the “+” button to add the access point (Picture 2)
  3. In the Object Inspector, set the value of the “SSID” property to “ServoRemote” (Picture 3)
  4. In the Object Inspector, expand the “Config” property, and set the value of the “Enabled” sub property to “True” (Picture 4)
  5. In the Object Inspector, set the value of the “IP” sub property to “200.200.200.200” (Picture 5)

Step 15: In Visuino: Add an UDP Socket for the communication

In Visuino: Add an UDP Socket for the communication
SocketsAddUDP.png
SocketsAddUDPPort.png

Next we need to add an UDP socket for the communication.

  1. In the Object Inspector, click on the “…” button next to the value of the Sockets sub property of the WiFi (Picture 1)
  2. In the Sockets editor select “UDP Socket”, and then click on the “+” button (Picture 2)
  3. In the Object Inspector, set the value “RemoteIPAddress” property to “200.200.200.200” (Picture 3)
  4. In the Object Inspector set the value of the “Port” to “8888” (Picture 4)

Step 16: In Visuino: Add Split Structure component, and add Analog channel to it

In Visuino: Add Split Structure component, and add Analog channel to it
ComponentSplitAddChannel.png
ComponentSplitAddChannel1.png
ComponentSplitAddChannel2.png

The Remote Control module sends the servo position in binary floating point form as a packet. We need to decode it properly. For this we need a “Split Structure” component with “Analog” element in it.

  1. Type “struct” in the Filter box of the Component Toolbox then select the “Split Structure” component (Picture 1), and drop it in the design area
  2. Click on the “Tools” button (Picture 2) to open the Elements editor (Picture 3)
  3. In the “Elements” editor select the “Analog” element, and then click on the “+” button (Picture 3) to add an Analog element (Picture 4)
  4. Close the Elements editor.

Step 17: In Visuino: Add and connect Servo component

In Visuino: Add and connect Servo component
Connect1.png
Connect2.png
Connect3.png
  1. Type “servo” in the Filter box of the Component Toolbox then select the “Servo” component (Picture 1), and drop it in the design area
  2. Connect the “Out” pin of the Servo1 component to the “Digital” input pin of Digital[ 2 ] channel of the Arduino component (Picture 2)
  3. Connect the “In” pin of the Servo1 component (Picture 3) to the “Out” pin of the “Elements.Analog1” of the SplitStructure1 component (Picture 4)

Step 18: Generate, Compile, and Upload the ESP8266 code for the Servo

Generate, Compile, and Upload the ESP8266 code for the Servo
Arduino IDE.png
  1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
  2. Connect the second NodeMCU module (The one with the Servo) with USB cable to the computer
  3. Select the board type and serial port as I have shown you in this Inctructable
  4. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

Step 19: And play…

And play...
VisuinoDiagramCrop.png
VisuinoDiagramCrop.png

Congratulations! You have completed the project.

Picture 1 shows the connected and powered up project.

If you rotate the Rotary Encoder back and forth, the Servo will move in the same direction, as you can see in the video. If you press the Rotary Encoder shaft down, the Servo will move to neutral center position.

On Picture 2 you can see the complete Visuino diagram for the Rotary Encoder Remote Control module.

On Picture 3 you can see the complete Visuino diagram for the Servo module.

Also attached are the Visuino projects, that I created for this Instructable. You can download and open them in Visuinohttps://www.visuino.com