Archive

Posts Tagged ‘nodemcu’

Karl’s Home Automation Project – Part 4: MQTT Bridge Updated to Use YS-IRTM IR Receiver & Transmitter with NodeMCU

April 20th, 2017 1 comment

In a previous article, I wrote about an MQTT bridge by 1technophile. I added a DHT temperature and humidity sensor as well as a light sensor. Previously it included a software decoder to decode the IR signal. I never did test the IR transmitter on the gateway, as I didn’t have the parts. But thanks to IC Station, who sent me over a small YS-IRTM hardware based decoder and NodeMCU that I am writing about today. I have replaced the software based version with the YS-IRTM module in the latest update.

Click to Enlarge

Click to Enlarge

I found this project challenging. I admit I am a little weak in my programming skills. It was difficult to find documentation but I found a forum talking about this device and basics of how it works. When an IR code is recognized it sends 3 hex codes via serial connection on the transmit pin. To transmit, it expects 5 hex codes: A1,F1,xx,xx,xx. A1,F1 tells it to send the following codes. You can also set the baud rate but I left default 9600.

It is simple wiring wise. It only takes 4 dupont wires. It took a bit of coding to get it working but I finally got it to communicate via software serial. I started on a Arduino Uno with the code and then migrated it over to the ESP8266 board. I did have a little trouble when I first moved to the ESP board. I initially thought I might need a level shifter but that didn’t help. I am a little surprised I didn’t need a level shifter because the ESP needs only 3.3 volts. I was getting some weird responses and finally figured out I had to put in a slight delay. Maybe the ESP’s speed comes into play.

The way to use this is fill out your SSID and password and your MQTT server with credentials. Flash the device. You will need to add the necessary libraries. 1technophile has good documentation in his wiki.

Once flashed and ready to find your IR codes you will need to subscribe to the topics with the Windows command below. Give the gateway a moment to connect and point your IR remote at the sensor and press a button to find out code.

In your window, you will get something like this “home/sensors/ir 4,fb,8,” which is my power button for my TV. To test the code:

With this code, the TV will toggle on and off.

Click to Enlarge

After this you can use your favorite home automation project and control your IR devices with automations. You can omit any sensors that you don’t need. You will get some erroneous MQTT data if not all sensors are used. Below are the bits of Arduino code added for the IR module, and here’s the link to the github code:

I plan on 3D printing an enclosure with CR-10 I am reviewing, and I will remove the IR LED, and move it to a more suitable position, as both facing the same way isn’t ideal for my setup.

I would like to thank IC Station for sending the NodeMCU ($5.81 shipped) and IR transmitter and receiver ($3.39 shipped) for review. You can get 15% discount with coupon Karics. I finally have a complete gateway.

Is NodeMCU ESP-32S Board Now Selling for $8.50 Shipped?

March 31st, 2017 8 comments

ESP32 SoC with WiFi and Bluetooth launched last September for around $3, followed soon after by ESP32 modules for $7, and a few weeks later, easier to use ESP32 development boards were introduced, but sold for around $20 likely due a mismatch between supply and demand. That’s not overly expensive, but in a world of $4 ESP8266 boards and $10 Raspberry Pi Zero W with Linux, WiFi and Bluetooth, it may feel that way. But today, I noticed DealExtreme sold GeekWorm ESP32 board with ESP-WROOM-32 module for just $11.64 shipped. That’s good progress, but surely Aliexpress must now have cheaper options, and sure enough, I could find NodeMCU ESP-32S board (now confirmed NOT to be an official NodeMCU devkit) sold for $6.95 + shipping, which brought the price up to about $8.50.

NodeMCU ESP-32S specifications:

  • Wireless Module – ESP-WROOM-32 with Espressig ESP32 dual core processor with 802.11 b/g/n WiFi and Bluetooth 4.0 LE
  • Expansion – 2x 19 pin headers with GPIOs, Analog inputs (ADC), UART, I2C, VP/VN, etc…; breadboard compatible
  • USB – 1x micro USB port for power and programming
  • Misc – BOOT and EN buttons, red (power) and blue (GPIO2) LEDs
  • Power Supply – 5V via USB or Vin pin
  • Dimensions – 51.4 x 28.3 mm

The Aliexpress page directs to LuaNode github page, which explains how to build and flash the firmware (provided you want to use Lua) and use the board. The information does to refers to NodeMCU, but DOIT ESP32 development board instead sold on Aliexpress for just under $10 shipped. Both boards look exactly the same apart from marking, and you’ll find the schematics here. There are also some examples on the Wiki on github with an ESP32 camera, and Nokia5110 LCD screen.

As I was about to complete this post, I heard the postman motorbike’s horn, and it turns out I’ve just received my first ESP32 board from IC station today, which to my surprise did not come fully assembled, so I’ll have to solder eboxmaker ESP32-Bit module on the board. The price has increased since last time I checked, with the board now sold for $19.99, with some 15% discount possible using jeanics coupon.

Secure IoT Connectivity with NodeMCU ESP8266 Board, ATECC508A Crypto Chip, Mongoose OS, and AWS IoT

March 7th, 2017 16 comments

There are many examples of Internet of Things projects, but more often than not the implementation is not secure, either because the device is exposed to the Internet with minimum or no security (worst case), or a gateway (hopefully) provides secure connection to the Internet, but the communication between sensor nodes and the gateway in the local network is not secure, due to memory limitation of the nodes, for example it might be challenging to implement security on ESP8266. Mongoose OS is an open source operating system for the Internet of Things developed by Cesanta working on ESP32, ESP8266, STM32, and TI CC3200, and the developers have demonstrated a secure solution with Mongoose OS running on ESP8266 connecting over a TLS connection to AWS IoT (Amazon Web Service IoT) and using TLS credentials stored in Microchip ATECC508A CryptoAuthentication Device.

NodeMCU with ATCRYPTOAUTH-XPRO (Left) or barebone ATECC508A (Right)

The addition of ATECC508 chip either using “XplainedPro extension board for crypto products” (ATCRYPTOAUTH-XPRO) or ATECC508A chip itself, is to avoid storing private TLS credentials in NodeMCU’s flash memory, as anybody with physical access to the device could steal private keys and get access to the cloud. ATECC508A is connected via the I2C interface of the target board.

So I guess the crypto chip truly makes sense if you have sensor nodes on the field with information important enough that third parties may be interested in getting access to your sensor to try read your private key from ESP8266’s flash. It costs less than $1, so you may consider it anyway, although you can still get a secure TLS connection between NodeMCU and AWS IoT without it, but it adds another level of security.

Once you are done with the hardware connections, you’ll need to install Mongoose OS on the board, and follow the MQTT + AWS IoT tutorial to get started. Nothing complicated need to be done to leverage the crypto chip, as the command mgos aws-iot-setup should automatically detect ATECC508A chip and use it.

Karl’s Home Automation Project – Part 2: 433 MHz / WiFi MQTT Bridge, Door & PIR Motion Sensors

March 2nd, 2017 11 comments

Karl here again for part 2 of my home automation project. We will be looking at how to automate your lights based on time of day and motion. In the first part we setup Home Assistant and uploaded firmware to basic Sonoff Wifi switches. Today we will setup a 433 MHz to MQTT bridge and some sensors.

433 MHz

Depending on your country 433 MHz is an open frequency to use to communicate with. There are hundreds of different types of devices that use 433 MHz to communicate information. We will be focusing on 2 today from Gearbest: WMS07 motion sensor (left) and WDS07 door/window sensor (2 parts, right).

I am not taking the door/window sensor apart, since it is super basic, but I’ve included some photos of the PIR motion detector.

Click to Enlarge

Click to Enlarge

433 MHz Bridge

While contemplating how to get presence on a per room basis I ran across this project. It monitors 433 MHz signals and publishes it to the MQTT server. It is a really an easy project. It also has an IR to MQTT feature. I did have an IR receiver and tested it but have not implemented it. He has some good instructions on his page so I won’t go over too much. You can do the bare bones version and just leave off the unused sensors. I also went an extra step and added a light intensity sensor and DHT sensor to the project. It can be found here. I am not going to add those to this write up because trying to keep costs down.

What you will need is

  1. NodeMCU $5.69
  2. H3V4F Receiver Module $1.21
  3. Prototyping board $2.88

That is all that is needed. For about $10 you have an inexpensive 433 MHz bridge. You can put in a box if you want and hide it in a central location away from interference. I would suggest soldering headers to your board just in case something goes bad. I didn’t at first and made my life a pain. There are a ton of 433 MHz receivers. I purchased all the ones on Gearbest and this is by far the best. I did upgrade to a superheterodyne but I am not sure it is any better. I upgraded because I wanted to put the door sensor on my mailbox and get a notification when the mail was delivered. It is about 200’ away and is a little spotty even with a new 433 MHz receiver. I used this antenna design (see picture on right), as it seemed to work the best

Coverage is the biggest concern.  I have a brick single story ranch style home about 2000 square feet and it covers the inside with ease and a lot of the area around the house. If you have a multi-story house or would need multiple receivers you would need to change the MQTT topics to avoid getting duplicates. Below is the final project. To be honest temperature is really the only thing that is useful to me, but wanted to see what could be done. I purchase the DHT11 and the readings are not good. If you want to do this go with the DHT22. Below is a mostly loaded bridge. I don’t have an infrared transmitter yet. I have a different one coming that does the encoding/decoding on a chip and will follow up when I receive it. I am hoping it will be easier/better than using the Arduino library.

Motion Sensor

The motion sensor itself is really easy to setup with jumpers. I suggest turning the LED off, and the time to 5 min after finished setting up with the jumpers. If you notice there is a micro switch in the top left of this picture. It is meant to be a tamper switch but I use it as a toggle switch to quickly turn off the lights. The motion sensor is meant to be used for a security system but I just have them sitting on night stands and corner tables. It works really well to override or turn a light on when Home Assistant ignores the motion. A little squeeze of the box and the light will toggle states on or off.

After your bridge is set up and connected take the motion sensor out and put some batteries in it. Run your batch file to see what code is being sent. For this one we need 2: motion and tamper. Write these codes down.

Home Assistant

Below is the YAML code that I am using with Home Assistant. I made it find and replace friendly. If you copy and find the 4 items below it should work. I think it is relatively easy to follow. It is the typical timed lamp on motion that is on Home Assistant website with some slight modifications. I had to add the turn off motion script because the motion sensors only sends when it senses motion. I also had to add the tamper toggle switch. When you are adding multiple sensors you can only have one “binary_sensor:” group and one “automation:” group etc.

Find/Replace Explanation
generic use livingroom or masterbedroom etc no spaces
5555555 use the motion number you found earlier
8888888 make up a number around your tamper/motion number
9999999 use the tamper number you found earlier.

 

Door Sensor

For the mailbox sensor here is an example. Same thing on this one run the batch file and find the open and closed codes. I have it send me a notification via pushbullet.

Almost there

We are almost there. Lights are turning on and off magically. Life is good. But there is one situation where it’s not so good. The gloomy day. With the automations above we cannot determine if the blinds are pulled or it is gloomy. We still need the lights to come on under those circumstances to make it really cool. In the next installment we are going to take the motion sensors above and add a light intensity sensor to them. We will be able to do this cheap. We still have a pretty good budget. With the bridge above you open yourself to a bunch of battery operated sensors. You can also control devices, as well, with a transmitter. Any of the transmitters should work on GearBest. You can get the one linked and throw away the receiver. It’s only $1.25.  If you have any questions or concerns feel free to leave a comment.

Item Qty Price Total
Initial Setup Sonoff Basic 5 $4.85 $24.25
Headers 1 $1.50 $1.50
USB to TTL 1 $2.54 $2.54
$28.29
Motion Sensors NodeMCU 1 $5.69 $5.69
H3V4F Receiver 1 $1.21 $1.21
Prototyping board 1 $2.88 $2.88
Motion Sensor 4 $7.03 $28.12
$37.90
Grand Total $66.19

Continue reading “Part 3: Adding Light Detection to a Motion Sensor“.

$10 RTLDuino is an Arduino Compatible WiFi IoT Board based on Realtek RTL8710AF WiSoC

January 4th, 2017 2 comments

Last summer, we discovered a cheap RTL8710AF WiFi module with many of the same function as ESP8266, but with an ARM Cortex M3 core instead. The only problem is that it was not quite as easy to play with as ESP8266 boards, as at the time I started by playing with AT commands with B&T RTL00 RTL8710AF module, and later on, I got a more convenient PADI IoT Stamp with breakout board, but if you wanted to change the firmware you had to play with the SDK and a J-Link SWD debugger. Realtek RTL8710AF did not offer the convenience of Arduino IDE program like its big brother “RTL8195AM” from the same Ameba family. I know mbed is being worked on, but in the meantime things have changed for the better, as kissste informed me that RtlDuino implementation added Arduino support to RTL8710AF and RTL8711AM modules, and an NodeMCU-like board with the same name was also sold for less than $10 including shipping.

rtlduinoRTLduino board specifications:

  • WiSoC – Realtek RTL8710AF ARM Cortex-M3 micro-controller @ 83 MHz
  • Connectivity – 802.11 b/g/n WiFi
  • USB – 1x micro USB port for programming and power
  • Expansion – 2x 16-pin breadboard friendly headers with GPIOs, UART, SPI, I2C, PWM, I2S, power signals….
  • Misc – Reset and test button, RGB LED
  • Power Supply – 5V via micro USB port or Vin pin
  • Dimensions – 49 x 24.5 mm (same as NodeMCU)

As you can see from the picture above,the board is actually based on the B&T RTL-00 module I previously tested. This is obviously quite easier to use since you don’t need to solder any cables to connect a USB to TTL board since RTLduino is equipped with CH340g and a micro USB port.

rtlduino-board-rtl8710af

The Aliexpress page has some claims about 5 function that accordingly to kissste are not quite all correct:

  1. Function 1 – “Mbed debugging mode” over micro USB cable -> you won’t get – this is a different board (at least for now)
  2. Function 2 – “JTAG debugging mode” over micro USB cable -> you won’t get – this is a different board
  3. Function 3 – “Simple & fast by OTA to upgrade debugging” -> you will get partially – no debugging, but you can OTA upload new sketch
  4. Function 4 – “Serial data directly to the network transceiver function” (serial console via UART) -> OK
  5. Function 5 – “Smartconfig mode” -> yes, will work – OTA upload new sketch

If you want to do debugging, I understand you’ll still need a JTAG or SWD programmer. If you want to get started with Arduino on the board:

  • Install Arduino IDE and Ameba SDK
  • Go to Arduino IDE installation directory
  • Clone github.com/pvvx/RtlDuino into hardware/development/rtl87xx directory
  • Restart Arduino

I could not find anything in English where other people tested the implementation, but you’ll find a forum thread (in Russian) on esp8622.ru, and other person mentioned the project on hackaday.io, but has not reported on details about it yet.

Beside Aliexpress, RTLduino board can also be found on ICStation for $9.99, and Amazon US for $10.99.

ESP32 Updates – ESP32-S Module Replaces ESP3212, ESP32 DevBoards for Sale, Arduino & NodeMCU Support

October 29th, 2016 6 comments

There have been some developments with regards to Espressif ESP32 in the last month since my post about upcoming ESP32 development boards. First ESP3212 module is no more, and has been replaced with ESP32-S module with about the same features, but it’s not pin-to-pin compatible, so the new module won’t work with older breakout boards made for ESP3212. ESP32-S is now out of stock on Seeed Studio, but you’ll find it on IC Station, Banggood, and others shops.

One good news is that it’s now easier to buy – or at least pre-order – ESP32 development boards, although stock may still be an issue, as the platform is very popular.

sparkfun-esp32-thingIf you live in the US, you can now backorder “Sparkfun ESP32 Thing” for $19.95. ESP32 board can be powered by either a micro USB power supply or a LiPo battery, and exposes close to 30 I/O pins. ESP32 developer board is still listed on Adafruit for $15, but you can’t pre-order it now, only asked to be notified once it becomes available.

Olimex ESP32-Coreboard

Olimex ESP32-Coreboard

Europeans may prefer purchasing from ESP32-Coreboard from Olimex for 17 Euros, but again it’s out of stock right now. Another option is Pycom WiPy 2.0 breadboard-friendly module going for 19.95 Euros, but you may consider getting the expansion board too for a total of 35.99 Euros if you want to easily power it through a USB power supply or a battery, and add storage via a micro SD slot. You’ll find both options in Pycom online store. WiPy 2.0 board also differs from competitors, as it’s designed to be programmed with (micro) Python.

In South East Asia, Gravitech sells their NANO32 IoT development board for 690 Baht / $20. Like most (all?) other boards mentioned here, NANO32 is breadboard friendly, it includes two user buttons, and can be powered via its micro USB port.

All shops above will also ship all around the world, but if you want to pay less in shipping, and potentially avoid custom fees, it’s always good to check for local options.  If you live in other continents, or the board you want is out of stock, buying directly from China is also an option.

A.I. Thinker NodeMCU-32S

A.I. Thinker NodeMCU-32S

A.I Thinker has just listed their NodeMCU-32S on Aliexpress for $24.50 including shipping, with basically the same features as ESP8266 based NodeMCU 1.0, but upgraded to ESP32 providing both WiFi and Bluetooth LE connectivity.

Widora AIR is also up for sale for $14.88, but once shipping is included it adds up to $22.25. The board is also powered via its micro USB port, comes with two user buttons, and 2x 20-pin headers. It should be noted it’s quite cheaper on Taobao where the company offers it for 60 CNY ($8.88), so I think due to the mismatch between demand and supply, ESP32 boards are quite more expensive than they’d be in a few months, and I’m guessing price with shipping should eventually conerge towards $12 to $15 for NodeMCU types of boards.

If got most of the links to the boards through ESP32.net main page, where the community currently keeps tab of sellers of ESP32 modules and development boards.

One the software side, Espressif has now published Arduino core for ESP32 on their github account, which may not have all the new features of ESP32 yet, such as Bluetooth support, and it requires a “manual” installation, but you should be able to program ESP32 boards through Arduino IDE like you do on ESP8266 boards.

If you prefer NodeMCU / Lua programming, some progress has been made for NodeMCU firmware for ESP32, and while development is taking longer than expected since Espressif moved from RTOS- SDK used with ESP31B beta board to IDF SDKm you can get mostly working code through dev-esp32 branch, and follow the status on github.

Some ESP32 Development Boards to Look Out For: NodeMCU, Widora-air, Nano32, Noduino Quantum, and Wemos

September 24th, 2016 16 comments

Espressif ESP32 WiFi + BLE SoC launched at the very beginning of the month, shortly followed by ESP3212 module, and while Adafruit sold a few breadboard-friendly ESP32 development boards to developers for $15 a few days ago, stock was limited, and it’s not possible to easily purchase ESP32 boards today, and that’s OK because firmware and software support is still in progress. Several companies are working on such ESP32 boards however, and they tend to show the development progress on social networks, so I thought it would be fun to look at what’s coming…

Amica (NodeMCU) ESP32 Board

The current NodeMCU board is one of the most popular ESP8266 development platform, and that’s not surprising they are working on an ESP32 version. I don’t have pictures nor full  specs of the board yet, but the company showcased their early work on ESP32 last June.

Widora-air

I only discovered Widora recently via their NEO WiFi board running OpenWrt, but they are also working on Widora-air ESP32 board.

widora-air

There’s no product page yet, but we can see the board is powered through a micro USB port, comes with reset and user buttons, a PCB antenna, and two 20-pin headers for IOs.

Gravitech / MakerAsia Nano32

Nano32 clearly wins the best picture award of this post… It’s made by South East Asia based Gravitech, and combines ESP32 with an FTDI chip for USB to serial programming through the micro USB port. It also includes two buttons, and breadboard-friendly headers.

Click to Enlarge

Click to Enlarge

A chip antenna can be found on the top left of the picture. You can follow their progress on Twitter.

Noduino Quantum Board

Noduino Quantum has a different form factor from the other boards in this list, as they’ve built an Arduino compatible ESP32 board, meaning compatible with Arduino shields.

Click to Enlarge

Click to Enlarge

ESP32 can be programmed through the micro USB port (Silicon Labs CP2102 chip), the board can also be powered via a power jack, and includes a PCB antenna. The company had also made an ESP8266 board called Noduino Falcon with the same design. More details can be found on Noduino.org.

Wemos ESP32 Board

Wemos has made both an Arduino compatible D1 board and a tiny D1 mini board based on ESP8266 in the past, and according to a forum post, the company is working on one or more ESP32 boards:

WeMos have confirmed an ESP32 board is in development.
Now whether it has a D1 form factor, D1 mini, or something new is still unknown.

If you are aware of other interesting ESP32 development board in development, feel free to let everybody know in the comments section.

$5 Wemos D1 mini Pro ESP8266 Board includes 16MB Flash

September 5th, 2016 15 comments

Wemos D1 mini is one of my favorite ESP8266 development boards thanks to its small size, shield support, and low $4 price tag. There’s now a new version of the board – dubbed Wemos D1 mini Pro – with 16MB flash instead of 4MB for the original version, and a few other modifications.

Wemos_D1_mini_ProWemos D1 mini Pro specifications:

  • WiFi 802.11 b/g/n module based on ESP8266EX with 16 MB flash, chip antenna and external antenna connector
  • Expansion – Through holes with
    • 11x digital input/output pins (3.3V) supporting interrupt/PWM/I2C/one-wire (except D0 pin)
    • 1x analog input (3.3V max input)
    • Reset and power signals (5V, 3.3V, GND)
  • USB – micro USB port
  • Misc – Reset button
  • Power – 5V via micro USB or 5V pin
  • Dimensions – 34.2 x 25.6 mm
  • Weight – 2.5 grams

Wemos-D1-mini-Pro-ESP8266-BoardBeside the larger flash,  the main differences are listed in a Wemos forum post:

  • External antenna connector – switch by re-soldering resistor 0(zero) ohm
  • Built-in ceramic antenna – good!
  • New CP2104 USB-TO-UART IC – why? more stable?
  • Same size as D1 mini, but more light (3.9g -> 2.5g) – for flying devices? 🙂

Wemos D1 mini had a PCB antenna for WiFi, which may explain the lighter weight too, and CH340G instead of CP2104. The Pro board can run both NodeMCU or Arduino firmware like the original D1 mini board, and I understand the shields are still compatible.

Wemos D1 mini Pro is sold on Aliexpress for $5 plus shipping ($1.36 in my case) with male and female headers. The product is not listed on Wemos.cc website yet, but soon should be.

Thanks to Zoobab for the tip.