Author Topic: NodeMCU Step By Step  (Read 17863 times)

0 Members and 1 Guest are viewing this topic.

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
NodeMCU Step By Step
« on: February 26, 2017, 06:51:15 AM »
Hi guys,
I'm working on a step by step guide to using the NodeMCU for the eParrot.

Be sure to read this link first and then come back and Let's Get Started! 

http://eparrot.org/index.php/topic,440.msg5237.html#msg5237

We are going to take one small baby step at a time and tame this beast.

Stay calm and follow the screaming people.

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #1 on: February 26, 2017, 06:56:39 AM »
First is the Bill of Materials (BOM). 
This was listed in the previous link but I'll list the basic components again here:

NodeMCU, about 3 bucks or a little less
2 each breadboard, about 30 cents 
ds18b20, about a buck
one 4.7K resistor and some hook up wires, about 10 cents at most
4 AA batteries and case, maybe a buck-fifty
Food container enclosure, a few cents


***optional*** but very useful are:
20x4 LCD with 4 pin serial backpack module
breadboard power supply module with 9V DC (wall wort) power supply
4 each push buttons
a 5V buzzer or small speaker
6 pack of cold beer


My cheap little breadboards are not friendly for the width of the NodeMCU module so I use 2 breadboards.
They are easy to modify and hook together as shown.

BB1.pngNodeMCU Step By Step
* BB1.png (240.79 kB. 350x262 - viewed 2073 times.)

BB2.pngNodeMCU Step By Step
* BB2.png (248.9 kB. 350x262 - viewed 1392 times.)

BB3.pngNodeMCU Step By Step
* BB3.png (206.32 kB. 350x262 - viewed 1433 times.)

Stay calm and follow the screaming people.

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #2 on: February 26, 2017, 07:33:33 AM »
Naturally we want to test everything before reaching for the soldering iron!

And now we begin the journey.
We want to blink the onboard LED.

And we want to use the Arduino IDE to do it with, so we need to install the NodeMCU boards to the IDE.

Open your IDE and select File, then Preferences.
In the box labeled "Additional Board Manager URLs: " copy and paste this into the empty box:

http://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json

Select OK to close the window.

Now select Tools > Boards > Boards Manager
Under "Type" select Contributed
Select esp8266...  and click install.

Restart the IDE.

Go to Tools > Board and select NodeMCU 1.0

Then go to tools again to verify the following:
CPU: 80 MHz
Flash size: 4M
upload speed 115200
Port: Com2 (or whatever your port number is)
Programmer: ArduinoISP

Done!  You have successfully installed the NodeMCU board to the Arduino IDE and you can enjoy using the familiar coding and IDE.

Now let's blink an LED.

Go to File > Examples > ESP8266 > Blink

Upload the sketch to the NodeMCU. If you get an error try changing the Com Port to another number.

You will notice the NodeMCU language is exactly the same as the Arduino language that you are used to! 

This is the end of the Setup Step.
You have successfully programmed your first sketch to the NodeMCU.


Stay calm and follow the screaming people.

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #3 on: February 26, 2017, 09:23:54 AM »
Whew! That was a big one but it was also the most difficult. Now we get to DO STUFF!

This step is optional as it is not needed for a WiFi eParrot and it uses additional hardware.
But I like it because it gives instant gratification if you already have these optional parts on hand.
More importantly, it is easier to debug and see that everything is OK before making the leap to WiFi.

You'll need a 20x4 LCD, a breadboard power supply module and a 9V DC (wall wort) power supply.
The MCU board is exclusively 3.3V and the LCD needs 5V.
All of the optional parts can be had for about $5 to $6.

with 2004 LCD.pngNodeMCU Step By Step
* with 2004 LCD.png (250.59 kB. 350x262 - viewed 1410 times.)

You can skip this step if you desire.
If you decide to follow along then you will need to look at your Arduino "libraries" folder and it really may be best to move any libraries that are there into another folder. Starting with a clean libraries folder can solve a lot of problems.

Download the attached LiquidCrystal zip file. In the IDE select Sketch > Include library > Add .ZIP library  and navigate to the zip file you just downloaded, select it and press OK. The IDE has now installed the library in the "libraries" folder and you can delete the zip file that you downloaded if you want.

Download and unzip the attached file Code_FG-01_Node-BP.zip 
(+++ FG-01 is Step1, Node-BP is NodeMCU with 2004LCD with serial Backpack.) 

Run the sketch.

Make sure your wiring is correct.
Connect a wire from the breadboard power supply module's Ground pin to the Ground pin of the NodeMCU (always tie the grounds together).
The rest of the 4 wires are this:

 BackPack > NodeMCU

 SDA > D2
 SCL > D1
 GND > GND
 VCC > +5V (from the breadboard power supply)


If all goes well, you get this...

it works.pngNodeMCU Step By Step
* it works.png (201.77 kB. 350x466 - viewed 1385 times.)

This is the end of Step One.
Stay calm and follow the screaming people.

Offline YHB

  • VS Moderator
  • Posts: 905
Re: NodeMCU Step By Step
« Reply #4 on: February 26, 2017, 11:55:45 AM »
I love it

 /thumbsUp /thumbsUp /thumbsUp

Keep it going

I have ordered 6 NodeMCUs and some other bits and pieces.

Will catch up as soon as I can.
Where Thrift Becomes An Art-Form

Offline YHB

  • VS Moderator
  • Posts: 905
Re: NodeMCU Step By Step
« Reply #5 on: February 26, 2017, 12:43:05 PM »
Shifu,

The zip files appear to be empty  ???
Where Thrift Becomes An Art-Form

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #6 on: February 26, 2017, 12:57:32 PM »
Shifu,

The zip files appear to be empty  ???

Oops, fixed now.

Also attaching the bare minimum sketch needed to display something to the 2004LCD-BP.
Stay calm and follow the screaming people.

Offline Eucyblues

  • Posts: 774
Re: NodeMCU Step By Step
« Reply #7 on: February 26, 2017, 05:05:51 PM »
ShiFu

Are yours the CH340 type or the CP2102 type.?

The latter are about twice the price of the CH340 type from my brief look

The CP2102 vendors claim that the CH340 versions are troublesome??

Offline YHB

  • VS Moderator
  • Posts: 905
Re: NodeMCU Step By Step
« Reply #8 on: February 26, 2017, 05:14:42 PM »
Just had a panic attack but the ones I have ordered are CP2102 and cost £4.00 each.
Where Thrift Becomes An Art-Form

Offline Eucyblues

  • Posts: 774
Re: NodeMCU Step By Step
« Reply #9 on: February 27, 2017, 02:35:18 AM »
Just squizzed ShiFu's photo.. The USB  chip looks like the CP2102  type

I've ordered a few to try

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #10 on: February 27, 2017, 05:46:42 AM »
Doggone hard to see even with magnification but it is a 2102.

Glad you are joining in Eucyblues.
Stay calm and follow the screaming people.

Offline YHB

  • VS Moderator
  • Posts: 905
Re: NodeMCU Step By Step
« Reply #11 on: February 28, 2017, 12:25:26 AM »


And we want to use the Arduino IDE to do it with, so we need to install the NodeMCU boards to the IDE.

Open your IDE and select File, then Preferences.
In the box labeled "Additional Board Manager URLs: " copy and paste this into the empty box:

http://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json

Select OK to close the window.



Tonight I got off to a flying halt.  :(

I am using IDE 1.7.11

When I go File:Preferences - I get

pref.jpgNodeMCU Step By Step
* pref.jpg (52.22 kB. 350x326 - viewed 1013 times.)

No sign of a box labeled "Additional Board Manager URLs: "

It is late and I have had a few glasses of cornflakes.  ::)

Will have another look tomorrow when I get up.

Goodnight  :)
Where Thrift Becomes An Art-Form

Offline YHB

  • VS Moderator
  • Posts: 905
Re: NodeMCU Step By Step
« Reply #12 on: February 28, 2017, 08:32:20 AM »
Apparently there are two Arduino sites both offering the latest IDE. >:( >:(

One of which does not have a board manager.  :-\

To confuse things even more the version with the highest revision number is not the one needed here.  >:( >:(

Quote

arduino.cc and arduino.org are two separate companies.
arduino.org was created after a big rift occurred between the original "arduino" people.

The arduino.cc are primarily the original s/w people and the arduino.org are primarily the original h/w people that were doing the original manufacturing of the boards.

arduino.org forked the arduino.cc IDE to create the IDE you see on the arduino.org site.
(remember it is open source and anybody can create a fork if they want to)

The arduino.org IDE is quite a bit behind the arduino.cc IDE in terms of features.
For example, you won't find the library or board manager in the arduino.org IDE.

The arduino.cc IDE has done quite a bit of updating to the IDE build system and it now does a much better job when converting .ino files to .cpp files. It also now automatically supports sub library dependencies so that if a library includes a header for a dependent library the IDE will handle it, whereas in the past the user sketch had to have an include for it.

Also, there are cases where the arduino.org will improperly insert the Arduino.h header and function prototypes which can break sketch code that uses types declared in header files.
https://github.com/arduino-org/Arduino/issues/68

IMO, at this point in time, I would not mess with the arduino.org IDE. It is too far behind the arduino.cc IDE and so it lacks too many very useful features.

--- bill
Where Thrift Becomes An Art-Form

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #13 on: February 28, 2017, 09:22:57 AM »
I'm using V 1.8.0 but no idea if it came from one site or the other.
Its up to 1.8.1 now on the .CC site so I'll upgrade.
Maybe, hopefully, it will offer more NodeMCU support.

I'm hitting a wall that I can't get past. One library that works great, for example, LiquidCrystal_I2C suddenly refuses to compile if another library (in this case DallasTemperature) is in the sketch.
I had the two working together just once and added something else and now cannot find my way back to a working instance of:

Step 2.pngNodeMCU Step By Step
* Step 2.png (206.46 kB. 350x466 - viewed 991 times.)
Stay calm and follow the screaming people.

Offline YHB

  • VS Moderator
  • Posts: 905
Re: NodeMCU Step By Step
« Reply #14 on: February 28, 2017, 10:39:41 AM »
It took me a few hours but got there in the end.

Several downloads and a few reboots later I managed to install 1.8.1 without errors and I now have the required board manager.

my NodeMCU's should be here in a couple of days so I will be able to join in with your frustration.

Hope you can resurect the configuration that worked. At least you know it can work, we have all seen the picture. :D
Where Thrift Becomes An Art-Form

Offline YHB

  • VS Moderator
  • Posts: 905
Re: NodeMCU Step By Step
« Reply #15 on: February 28, 2017, 11:40:11 AM »

I'm hitting a wall that I can't get past. One library that works great, for example, LiquidCrystal_I2C suddenly refuses to compile if another library (in this case DallasTemperature) is in the sketch.
I had the two working together just once and added something else and now cannot find my way back to a working instance of:


Shifu,

I am reading conflicting articles about the signal voltage between the LCD & the NodeMCU - have you added any protection to the NodeMCU from receiving 5v from the LCD?

t=301s
Where Thrift Becomes An Art-Form

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #16 on: February 28, 2017, 12:05:46 PM »
The MCU never got 5V from the LCD, the LCD got 5V from the breadboard power supply.
The MCU got power from the USB cable and steps that down to 3.3V

The worst thing is the MCU was supplying 3.3V to SCL and SDA going into the LCD.
That works but far better to use a level shifter which I've now added.
(Adds 8 strands of spaghetti.)

Perhaps I wrong? The SCL or SDA are uni-directional? I assumed they were one-way -- both clock (SCL) and Data (SDA) going from the MCU to the LCD.


No change so far. Can't get back to the LCD with one sensor  :(
Latest IDE and level shifter are no help.

The LCD contrast is better with the level shifter and scrolling text is much smoother.

no help.pngNodeMCU Step By Step
* no help.png (1012.64 kB. 350x466 - viewed 997 times.)

Stay calm and follow the screaming people.

Offline Edwin Croissant

  • Global Moderator
  • Posts: 428
Re: NodeMCU Step By Step
« Reply #17 on: March 01, 2017, 12:23:33 AM »
ShiFu, the NewliquidCrystal library conflicts original lcd library so when you installed the new Arduino software did you remove the original one ?

 

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #18 on: March 01, 2017, 07:00:10 AM »
Thanks for the heads up, Edwin.
I did remove everything from the documents / library folder (several times and tried different libraries)
but failed to remove LiquidCrystal from Program files(x86) > Arduino > libraries folder.

Doing that now!
Stay calm and follow the screaming people.

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: NodeMCU Step By Step
« Reply #19 on: March 02, 2017, 06:30:55 PM »
I have not given up. But I did hit a wall.
Still trying to resolve the Arduino library issues with the NodeMCU.
Stay calm and follow the screaming people.