PlatformIO IDE your IoT friend.

PlatformIO IDE your IoT friend.

Hi Readers,

Today I would like to show you PlatformIO IDE. It is easy to use and in my opinion much nicer and more sophisticated alternative to Arduino Studio. Maybe it is not so easy to use as it needs some configuration at first but it is a basic process that everybody can do. Also I have noticed that platformio is really working on improving whole environment.

 

What is the PlatformIO

 

platformio-logo-17fdc3bc

 

PlatformIO IDE is the next-generation integrated development environment for IoT:

Cross-platform build system without external dependencies to the OS software: 200+ embedded boards,15+ development platforms, 10+ frameworks

C/C++ Intelligent Code Completionand Smart Code Linter for rapid professional development

Multi-projects workflow with multiple panes and Themes support with dark and light colors

Built-in Terminal with PlatformIO CLI tool and powerful Serial Port Monitor

PlatformIO IDE is a IDE build on Atom “A hackable text editor” which you can find more about on their homepage : https://atom.io .

It supports number of boards and especially useful for us it supports all ESP8266 boards I know about. I am using it with my ESP6288-01 and Nodemcu ESP8266-12E boards.

Installation

What you need to do to install it? Just download platformio installation from: http://platformio.org/get-started and it is done. But if you will end-up with some errors which unfortunately I did twice on my laptop. Just reinstall it again it should help.

List of supported boards: http://platformio.org/boards

 

plotfio

Libraries

Probably from the begging you will miss some libraries but don’t be worry PlatformIO has hundreds libraries in their repository.

To find the right one you should run Library Manager (from menu) they console will popup. Then you need to type:

platformio lib search <name_of_missing_library>

platformio lib search 1-wire

After that you will see list of libraries which are consistent with your search.

PlatformioSearch

When you want to install one of found libraries you need to type:

platformio lib install <library_id>

platformio lib install 1

 

Configuration

Platformio has large number of possible settings we can customize. But most important is platformio.ini file which contains settings of your project.

Settings I am using for my Nodemcu are:

[env:nodemcuv2]
platform = espressif
framework = arduino
board = nodemcuv2
upload_speed = 115200
#upload_port = COM5

 

plotfi2o

 

Platformio.ini configuration: http://docs.platformio.org/en/latest/projectconf.html#upload-speed

You can find there much more settings you can choose it is a bit lecture bit it also mean that everybody will be well served by PlatformIO IDE.

Give it a try. I am sure you will like it as I did.

 

Github repository: https://goo.gl/ii9xsz

Be positive and stay calm!

Cheers,

Radek

Power supply modules and ESP8266 module types.

Power supply modules and ESP8266 module types.

Hi Readers,

Today I would like to share with you power supplies I am have tested and ESP8266 modules which I am currently using. I have done those tests as often when I was connecting one or another sensor to ESP8266 module it was loosing power and resetting itself.

Breadboard power supply modules

1) Breadboard power supply module

IMG_20160501_170231

This one I like the most. It fits well, doesn’t fell off easily. Can operate on DC 6V – 12V input and does 3.3V or 5V output. Has reset button also additional power pins which are usefull in most DIY projects. You can use e.g. 4 x AA or 4 x AAA batteries or 9V battery.

2) Breadboard power supply modules

IMG_20160501_170255

This is seconds breadboard power supply. It can be powered byt DC 7V to 12V. As a output has 3.3V or 5V. Has more common micro usb socket so could be powered up from any PC, laptop or power bank by any smartphone similar cable.

3) Additional elements

You can use external power supply, usb cable or any other type of power source. I have used batteries as they are cheap and portable.

IMG_20160501_170854IMG_20160501_170909IMG_20160501_171320IMG_20160501_170759IMG_20160501_170818IMG_20160501_170700IMG_20160501_110737

ESP8266 Modules

Modules I am using:

IMG_20160501_170455IMG_20160501_170503IMG_20160501_170513

Those are to basic and I think cheapest easy to use ESP8266 modules. You can simply find and order them from chine. They cost about 2$ per peace. Different between those is memory size blue modules has only 512kb where black has 1024kb.

IMG_20160501_170343IMG_20160501_170424IMG_20160501_170439IMG_20160501_170619IMG_20160501_170700

Those are nodemcu modules which has ESP12 modules. They are three version of it but V2 and V3 are most popular. I read that those modules are similar but even from hardware site there are similar their sizes are unfortunately different. V3 is just to big in my opinion as when installed on breadboard there is not holes left to connect anything to it. V2 is a les wide in compare to V3 and has 2 lines of wholes left when installed in breadboard. You can see it on attached pictures.

According to other types of ESP8266 modules. You can read more on esp8266 homepage under this like:

http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family

1610038_1722052748015043_1288277534162828799_n

Github repository: https://goo.gl/ii9xsz

Be positive and stay calm!

Cheers,

Radek

Thermometer = Nodemcu ESP8266 + DS18B20

Thermometer = Nodemcu ESP8266 + DS18B20

Hi Readers,

Today I would like to show you how we can use our nodemcu as a simple thermometer.

What you need:

  1. Nodemcu (esp8266)
  2. DS18B20
  3. Arduino studio
  4. Serialport monitor (for example the one from Arduino studio)

You can also use:

  1. Breadboard
  2. Couple connectors
  3. 4.7k ohms resistor

How it should be connected?

Untitled Sketch_bb

As you can see on attached picture you need to first connect 3.3V and GND on your breadboard to edge breadboard. Then you simply should connect DS18B20 sensor legs to 3.3V and GND plus its DQ to Nodemcu D4 and also connect it by 4.7k ohm resistor to the 3.3V.

This is how it looked for me

IMG_20160424_191928

I am sure you have manage to connect everything so let’s do some coding.

I have created example code (based on ajaran source code) which you can build and upload by Arduino studio (I used it) and test and use device you have just created! If you haven’t noticed that you have just build basic and simple thermometer :). In example source code gathered temperate I am printing to the serial port. So you can use really any serial monitor to read current temperature.

#include
#include
#include

#define myPeriodic 15 // Seconds
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float prevTemp = 0;
const char* MY_SSID = “ssid”;
const char* MY_PWD = “password”;
int sent = 0;
void setup() {
Serial.begin(115200);
}

void loop() {
float temp;
DS18B20.requestTemperatures();
temp = DS18B20.getTempCByIndex(0);
Serial.print(String(sent)+” Temperature: “);
Serial.println(temp);
sent++;
int count = myPeriodic;
while(count–)
delay(1000);
}

I have hope you enjoyed this post. I did!

12832321_1215052848518740_5770579544392527095_n

Github repository: https://goo.gl/ii9xsz

Be positive and stay calm!

Cheers,

Radek

Lua programming language

Lua programming language

Hi Readers,

Today I would like to tell you another way of programming and controlling ESP8266. This time instead of using ‘AT’ commands I will show you simple application which uses Lua programming language which will be uploaded directly to our ESP8266.

What Lua is? (from ESP8266 wiki)

There are 2 “branches:” of Lua now for ESP8266, and both are now open source. Confusingly, both use the word Node in their name – NodeMCU and NodeLua. As lua.org says, Lua is a powerful, fast, lightweight, embeddable scripting language. Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics.

Lua is small: the Lua interpreter easily fits in under 100 kilobytes including the base libraries.
Lua is fast: independent benchmarks show that Lua is often amongst the fastest interpreted dynamic languages. The Lua interpreter has been extensively tuned for high performance.

What LUA means?

“Lua” (pronounced LOO-ah) means “Moon” in Portuguese. (from https://www.lua.org/about.html)

More about Lua?

If you want to know more about LUA language it’s history, strong and weak points and everything you also would like to know you can visit lua homepage: http://www.lua.org

What editors should I use?

You can use number of tools to user Lua and upload it to ESP8266 I used free tools:

LuaLoader: https://gettoknowthebob.wordpress.com/2016/04/11/lualoader-unknown-but-surprisingly-useful-tool/

ESplorer: https://gettoknowthebob.wordpress.com/2016/04/17/esplorer-probably-best-lua-editor/

And arduino studio, this one I liked the most. Also I have just tried Atom so I don’t want to give you my opinion on it after couple minutes spend together but I believe after spending some time on configuration it. It maybe coolest IDE I ever used for ESP8266.

Of course if you didn’t change your firmware from orginal ATfirmware you will need to replace it with another firmware which you can find with whole description on my blog: https://gettoknowthebob.wordpress.com/2016/04/08/flashing-esp8266-nodemcu-with-latest-firmware/

Examples!

First and the basic example I used is this simple code which turns on and off Nodemcu LED. Here you can see how clear and easy this code looks like. Pin number, Pin mode, Write 1 or 0 and fine. It works!

lighton=0
pin=4
gpio.mode(pin,gpio.OUTPUT)
tmr.alarm(1,3000,1,function()
if lighton==0 then
lighton=1
gpio.write(pin,gpio.HIGH)
else
lighton=0
gpio.write(pin,gpio.LOW)
end
end)

But you can do much more. As we know that all about ESP8266 is Wifi then let’s try connect our board with one or another network:

wifi.setmode(wifi.STATION)
wifi.sta.config("ssid","password")
wifi.sta.connect()
print(wifi.sta.getip())

Or from nodemcu simplest http server:

srv=net.createServer(net.TCP) 
srv:listen(80,function(conn) 
    conn:on("receive",function(conn,payload) 
    print(payload) 
    conn:send("

Hello, NodeMCU.

)
    end) 
end)

I hope you had nice time playing with Lua language as I did 🙂

Github repository: https://goo.gl/ii9xsz

Be positive and stay calm!

Cheers,

Radek

ESPlorer – probably best Lua editor

ESPlorer – probably best Lua editor

Hi Readers,

Today I would like to present you ESPlorer. If you read my previous post about LuaLoader. I believe that this is another tool which is worth to be used and learned by everybody who somehow starts his journey with ESP8266.

 

So first interesting thing I was surprised to see was Basic AT Commands Panel.

esplorer2

It contains common wifi commands which you can use to set up Station or Access point mode, HDHCP or not. You can simply query list of around WiFi networks (AT+CWLAP).

 

Second and the main feature is Lua editor. Basic, with nice syntax coloring.

esplorer6

 

You can of course save, compile, run and upload code. It also contains Commands panel which can restart your ESP8266 and do couple more things.

esplorer5

 

I didn’t spend much time using it as most of this what this tool offer I tried before with other or my own tools (ATManager on my Github repository). But if you are beginner or even you are not this is useful tool to control ESP8266 module plus offers everything we need to programmer ESP8266 with Lua programming language.

 

Also as you probable have noticed. There is Frankenstein tab. I am really curious what author of ESPlorer has in mind but it is not yet ready and we will need to wait.

esplorer3

 

Try it, test it and play with it. Really nice tool.

 

You can download it from here: http://esp8266.ru/esplorer/

 

Github repository: https://goo.gl/ii9xsz

 

Be positive and stay calm!

Cheers,

Radek

LuaLoader – Unknown but surprisingly useful tool!

LuaLoader – Unknown but surprisingly useful tool!

Hi Readers,

Today I would like to present LuaLoader. Surprisingly useful tool which I wasn’t aware for too long. To be honest I believe everybody who starts his journey with ESP8266 should at least try LuaLoader.

Of course after testing and learning basic ESP8266 functionality using AT commands. And after changing ESP8266 firmware from AT command firmware to Lua firmware. (Which you can find on my blog).

 

123456
LuaLoader

 

As you can see on attached picture LuaLoader has many different interesting features.

(Skin colour section) Starting with interactive real-time main console window. You will see there everything incoming from ESP8266 board and you can still type this what you want to send to the board.

(Blue section) You can change GPIO settings or check current settings.

(Green section) You get restart it get chip Id or more.

(Orange section) You will be also able to create Access point or get list of other access points near your module.

(Yellow section) You can do everything related to Lua programming language. You can upload source code file, download existing file. Compile. Format. Remove, cat or any toher

Try it. Play with it. Hopefully it will make ESP8266 more easy for you!

 

Apologize Readers I am so brief today but yesterday I tried LuaLoader and as you know really I liked it! But I didn’t had much time to work on a new post. I planned to do it today and guess what it doesn’t work for me. I tried everything but it have a problem to connect LuaLoader connecting with my Nodemcu. I am able to connect to the board with other tools but not LuaLoader.

 

Still I hope you will like LuaLoader and you will have fun a bit with it before my next lesson which will be about another Lua tool which I am planning to test tomorrow.

 

Github repository: https://goo.gl/ii9xsz

Be positive and stay calm!

Cheers,

Radek

 

 

 

AtManager (Cool AT commands software with some Reactive Extension)

AtManager (Cool AT commands software with some Reactive Extension)

Hi Readers,

Today I would like to introduce application I have created to tests and learn how to control ESP8266 using AT commands. It is software tool written in C#.

I called it “AtManager”.

Based on AtManager I have created two basic tools PCoordinator and PEndDevice both are basically AtManager with new sequence of first commands send to ESP8266.

What is cool about this application what I tried to achieve is having really basic application which simply sends AT commands and after that is waiting for response. Response which returns as enumerate within response string.

I called it AtCommandService class. It contains SendCommand() command which sends AT command string we want to send and has a timeoutPeriod in which will wait for response.

What could be interesting for you instead of registering SerialDataReceivedEventHandler function I used Reactive Observable to which later I am Subscribing ProcessIncomingData() function which is processing the incoming data. It could be done in classic easy C# way but I have decided it would be cool doing it with reactive a bit simplifying the source code.

      private IObservable<object> _dataReceivedSubscription
{
get
{
return Observable
.FromEventPattern<SerialDataReceivedEventHandler, SerialDataReceivedEventArgs>(x => _serialPort.DataReceived += x, x => _serialPort.DataReceived -= x)
.Select(x => x.Sender);
}
}

Have fun with it. It should make your testing and learning ESP8266 module much easier.

Whole project you can find on my github repository.

 

Github repository: https://goo.gl/ii9xsz

Be positive and stay calm!

Cheers,

Radek