Here’s how to set up serial comms between a NodeMCU V1 (ESP-12E) and Arduino Nano. Note, you could replace the Nano with any Arduino board but I have only tested with a Nano.
Here are parts required:
Here’s the diagram:
And the source code is available here: https://github.com/coytar/Snippets/tree/master/NodeMCU_To_Nano
Good luck! 🙂
This is the tutorial for programming the NodeMCU CP1202 board using the Arduino IDE. The code that will be used is the Blink example. And the board that I’m using looks like this.
Here are the steps I followed:
- Install the drivers from https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
- Download the ESP8266 board information for Arduino
- Open the Arduino IDE
- Click on the File menu and then Preferences
- In the Additional Boards Manager URLs, enter this: http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Click Ok
- Click on the Tools menu, click Boards and then click Boards Manager
- Wait for it to download the new boards information
- Search for ESP8266 and install it
- From the Tools menu, select the following:
- Board: NodeMCU 1.0 (ESP-12E Module)
- Flash Size: 4M (3M SPIFFS)
- CPU Frequency: 80MHz
- Upload Speed: 115200
- Port: (whichever COM port it is)
- Erase Flash: Sketch Only
- From the File menu, click Examples, click ESP8266 and then click Blink
- Compile and download
- Voila! 🙂
Another demo for interfacing an Arduino with the DS1307 Real Time Clock. The board I used (see here) also has an integrated 24C32 32K EEPROM which we won’t worry about in this demo.
Here’s a picture of my setup:
- Arduino Uno R3
- 16×2 LCD Shield
- DS1307 board (I used this one) but you could use this one too
- CR2032 button cell
(NOTE: If you’re using the same board as me then wire to the side of the board with the pins SQ, DS, SCL, SDA, VCC, GND & BAT)
- Uno’s 5V (via LCD Shield) to RTC’s 5V
- Uno’s GND (via LCD Shield) to RTC’s GND
- Uno’s Analog Pin 4 (via LCD Shield) to RTC’s SDA
- Uno’s Analog Pin 5 (via LCD Shield) to RTC’s SCL
- Leave the other pins unconnected
- Put the button cell in!
You can find the code here. And voila! 🙂
I wanted to try an Ultrasonic sensor so I bought the cheapest one I could find, the HR-SR04. I used this tutorial to learn about the ultrasonic. Basically I thought the Ultrasonic would provide an analog signal with the distance…well I was wrong. Distance is calculated based on the time taken for an echo signal to be sent and received.
Here’s a picture of my setup.
Wiring is easy:
- Uno’s 5V (via LCD Shield) to sensor’s 5V
- Uno’s GND (via LCD Shield) to sensor’s GND
- Uno’s Digital Pin 0 (via LCD Shield) to sensor’s ECHO
- Uno’s Digital Pin 1 (via LCD Shield) to sensor’s TRIG
You can find the code here. And voila! 🙂
I think the serial pins on my Sparkfun Pro Micro are fried. I have tried everything and they just don’t work. Wasted 3 nights on this…sigh!
Ok the original Arduino IDE is good but not great. It’s pretty basic as it’s intended to be. I needed something better, something advanced. I didn’t try every alternative out there. I tried using Eclipse (it’s actually an eclipse plugin, see here) but I couldn’t get it work. I believe it didn’t work because I needed 32 bit Java. Anyways, I tried Visual Micro. This is something I liked. It’s also a plugin for Visual Studio. (FYI Visual Studio now comes in a free community edition, see here) Two things I didn’t like:
1) Creates too many files, that’s just how Visual Studio works. It creates several folders and files which I don’t need.
2) Some of the compilation errors didn’t show up. I was pulling my hair trying to figure out the cause of the error. I eventually figured out it after I compiled it using the original Arduino IDE.
The other “problem” for me was that I’m using a PC and laptop (it’s one of those convertible tablet/laptop) for development. I wanted to same the software on both systems. I didn’t want to install a big IDE like Visual Studio (with Visual Micro) on my laptop (it doesn’t have much space).
So I have decided to use Notepad++ for development and then use the original Arduino IDE with the “External editor” option activated.
I bought an XBee USB Adaptor (looks exactly this one but I bought from eBay) with an FTDI chip for USB to Serial comms and I noticed that the RX & TX lights are reversed. Don’t worry it can be fixed 🙂
- Download the “FT_Prog” program from here.
- Extract and install it
- Connect your FTDI board to your PC
- Run FT_Prog
- From the FT_Pro window, click on “Devices” and then “Scan and Parse”
- Go this:
- Notice C0 & C1 has RXLED# & TXLED# (your setup might be the other way), swap them around.
- Click on “Devices” and then “Program”. This will bring up a new window.
- Click the “Program” button. It only takes a few seconds. It will provide a success message at the bottom of the window. Don’t ask me what to do if it shows an error message (sorry!).
- Press “Close” and close FT_Prog.
- Unplug the board from your PC and plug it back in.
- Voila! 🙂
NOTE: Each time you flash the FTDI, the port number changes and the serial number.